/**
 * DigiTechPak Live Chat — Frontend Widget Stylesheet (Ledger Theme)
 */

:root {
    --dtplc-w-primary: #059669;
    --dtplc-w-primary-dark: #047857;
    --dtplc-w-primary-light: #ecfdf5;
    --dtplc-w-accent: #f59e0b;
    --dtplc-w-text-main: #0f172a;
    --dtplc-w-text-muted: #64748b;
    --dtplc-w-bg-white: #ffffff;
    --dtplc-w-border: #e2e8f0;
    --dtplc-w-radius: 16px;
    --dtplc-w-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.15), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
}

/* Widget Wrapper Container */
.dtplc-widget-wrapper {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.5;
    box-sizing: border-box;
}

.dtplc-widget-wrapper *,
.dtplc-widget-wrapper *::before,
.dtplc-widget-wrapper *::after {
    box-sizing: inherit;
}

/* Floating Trigger Button */
.dtplc-trigger-btn {
    position: relative;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--dtplc-w-primary);
    color: #ffffff;
    border: none;
    box-shadow: 0 4px 14px 0 rgba(5, 150, 105, 0.39);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), background 0.2s ease, box-shadow 0.2s ease;
    outline: none;
}

.dtplc-trigger-btn:hover {
    transform: scale(1.06);
    background: var(--dtplc-w-primary-dark);
    box-shadow: 0 6px 20px 0 rgba(5, 150, 105, 0.45);
}

.dtplc-trigger-btn:active {
    transform: scale(0.96);
}

.dtplc-badge-indicator {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid #ffffff;
}
.dtplc-badge-indicator.is-online { background: #10b981; }
.dtplc-badge-indicator.is-away { background: #f59e0b; }

.dtplc-unread-badge {
    position: absolute;
    top: -4px;
    left: -4px;
    background: #ef4444;
    color: #ffffff;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 9999px;
    border: 2px solid #ffffff;
}

/* Chat Window Box */
.dtplc-chat-window {
    position: absolute;
    bottom: 74px;
    right: 0;
    width: 380px;
    max-width: calc(100vw - 32px);
    height: 560px;
    max-height: calc(100vh - 110px);
    background: #ffffff;
    border-radius: var(--dtplc-w-radius);
    box-shadow: var(--dtplc-w-shadow);
    border: 1px solid var(--dtplc-w-border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: dtplcSlideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes dtplcSlideUp {
    from {
        opacity: 0;
        transform: translateY(16px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Chat Window Header */
.dtplc-header {
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
    color: #ffffff;
    padding: 16px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 4px rgba(0,0,0,0.06);
}

.dtplc-header-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.dtplc-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    flex-shrink: 0;
}

.dtplc-title {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    color: #ffffff;
}

.dtplc-status-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.9);
    margin-top: 1px;
}

.dtplc-status-pill .dtplc-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
}
.dtplc-status-pill.is-online .dtplc-dot { background: #34d399; }
.dtplc-status-pill.is-away .dtplc-dot { background: #fbbf24; }

.dtplc-header-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.dtplc-btn-icon {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.85);
    padding: 6px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease, color 0.15s ease;
}

.dtplc-btn-icon:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #ffffff;
}

/* Chat Window Body */
.dtplc-body {
    flex: 1;
    overflow-y: auto;
    background: #f8fafc;
    position: relative;
    display: flex;
    flex-direction: column;
}

.dtplc-view {
    padding: 16px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* Welcome Banner */
.dtplc-welcome-banner {
    background: #ffffff;
    border: 1px solid var(--dtplc-w-border);
    border-radius: 12px;
    padding: 14px;
    margin-bottom: 14px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.03);
}

.dtplc-welcome-text {
    margin: 0;
    font-size: 13px;
    color: var(--dtplc-w-text-main);
    line-height: 1.45;
}

/* FAQ Suggestion Chips */
.dtplc-faq-section {
    margin-bottom: 16px;
}

.dtplc-faq-title {
    display: block;
    font-size: 11px;
    font-weight: 700;
    color: var(--dtplc-w-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.dtplc-faq-chips {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.dtplc-faq-chip {
    text-align: left;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 12px;
    font-weight: 500;
    color: #334155;
    cursor: pointer;
    transition: all 0.15s ease;
}

.dtplc-faq-chip:hover {
    border-color: var(--dtplc-w-primary);
    background: var(--dtplc-w-primary-light);
    color: var(--dtplc-w-primary-dark);
}

/* Forms */
.dtplc-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #ffffff;
    border: 1px solid var(--dtplc-w-border);
    border-radius: 12px;
    padding: 14px;
}

.dtplc-form-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.dtplc-form-group label {
    font-size: 11px;
    font-weight: 600;
    color: var(--dtplc-w-text-muted);
}

.dtplc-input,
.dtplc-textarea {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 13px;
    font-family: inherit;
    color: var(--dtplc-w-text-main);
    background: #ffffff;
    transition: border-color 0.15s ease;
}

.dtplc-input:focus,
.dtplc-textarea:focus {
    border-color: var(--dtplc-w-primary);
    outline: none;
    box-shadow: 0 0 0 2px rgba(5, 150, 105, 0.15);
}

.dtplc-textarea {
    resize: none;
}

.dtplc-auth-notice {
    font-size: 12px;
    color: #475569;
    background: #f1f5f9;
    padding: 6px 10px;
    border-radius: 6px;
    margin: 0;
}

.dtplc-btn-primary {
    background: var(--dtplc-w-primary);
    color: #ffffff;
    border: none;
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: background 0.15s ease;
    margin-top: 4px;
}

.dtplc-btn-primary:hover {
    background: var(--dtplc-w-primary-dark);
}

/* Messages Log Container */
.dtplc-messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.dtplc-w-msg-row {
    display: flex;
    flex-direction: column;
    max-width: 82%;
}

.dtplc-w-msg-row.is-visitor {
    align-self: flex-end;
}

.dtplc-w-msg-row.is-agent {
    align-self: flex-start;
}

.dtplc-w-msg-row.is-system {
    align-self: center;
    max-width: 95%;
    text-align: center;
}

.dtplc-w-msg-sender {
    font-size: 10px;
    font-weight: 600;
    color: var(--dtplc-w-text-muted);
    margin-bottom: 2px;
}

.dtplc-w-msg-bubble {
    padding: 9px 12px;
    border-radius: 12px;
    font-size: 13px;
    line-height: 1.45;
    word-break: break-word;
}

.dtplc-w-msg-bubble p { margin: 0; }
.dtplc-w-msg-bubble p + p { margin-top: 4px; }

.dtplc-w-msg-row.is-visitor .dtplc-w-msg-bubble {
    background: var(--dtplc-w-primary);
    color: #ffffff;
    border-bottom-right-radius: 2px;
}

.dtplc-w-msg-row.is-agent .dtplc-w-msg-bubble {
    background: #ffffff;
    color: var(--dtplc-w-text-main);
    border: 1px solid var(--dtplc-w-border);
    border-bottom-left-radius: 2px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}

.dtplc-w-msg-row.is-system .dtplc-w-msg-bubble {
    background: #f1f5f9;
    color: #64748b;
    border: 1px dashed #cbd5e1;
    font-size: 11px;
    padding: 6px 10px;
}

.dtplc-w-msg-time {
    font-size: 9px;
    color: #94a3b8;
    margin-top: 2px;
}
.dtplc-w-msg-row.is-visitor .dtplc-w-msg-time { text-align: right; }

/* Typing Indicator */
.dtplc-typing-indicator {
    padding: 6px 14px;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: var(--dtplc-w-text-muted);
}
.dtplc-typing-dots {
    display: inline-flex;
    gap: 3px;
}
.dtplc-typing-dots span {
    width: 4px;
    height: 4px;
    background: #94a3b8;
    border-radius: 50%;
    animation: dtplcDotPulse 1.2s infinite ease-in-out;
}
.dtplc-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.dtplc-typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes dtplcDotPulse {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

/* Chat Footer / Live Input */
.dtplc-footer {
    padding: 10px 14px;
    background: #ffffff;
    border-top: 1px solid var(--dtplc-w-border);
}

.dtplc-attachment-preview {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #ecfdf5;
    border: 1px solid #a7f3d0;
    border-radius: 6px;
    padding: 4px 10px;
    margin-bottom: 8px;
    font-size: 11px;
    color: #065f46;
}
.dtplc-attachment-preview button {
    background: none;
    border: none;
    font-size: 16px;
    color: #047857;
    cursor: pointer;
    line-height: 1;
}

.dtplc-chat-input-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.dtplc-btn-attach {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: #f1f5f9;
    color: #64748b;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s ease;
    flex-shrink: 0;
}
.dtplc-btn-attach:hover {
    background: #e2e8f0;
    color: var(--dtplc-w-primary);
}

.dtplc-message-input {
    flex: 1;
    resize: none;
    border: 1px solid #cbd5e1;
    border-radius: 20px;
    padding: 8px 14px;
    font-size: 13px;
    line-height: 1.4;
    max-height: 90px;
    outline: none;
    font-family: inherit;
}

.dtplc-message-input:focus {
    border-color: var(--dtplc-w-primary);
}

/* Attachments inside message bubbles */
.dtplc-msg-attachment {
    margin-top: 6px;
    display: block;
}
.dtplc-msg-attachment-img {
    max-width: 100%;
    max-height: 180px;
    border-radius: 8px;
    display: block;
    cursor: pointer;
    transition: opacity 0.15s ease;
}
.dtplc-msg-attachment-img:hover { opacity: 0.9; }

.dtplc-msg-attachment-doc {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 6px;
    font-size: 12px;
    color: inherit;
    text-decoration: none;
}
.dtplc-msg-attachment-doc:hover { text-decoration: underline; }

.dtplc-btn-send {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--dtplc-w-primary);
    color: #ffffff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease;
    flex-shrink: 0;
}

.dtplc-btn-send:hover {
    background: var(--dtplc-w-primary-dark);
}

/* Offline Banner */
.dtplc-offline-banner {
    text-align: center;
    margin-bottom: 12px;
}
.dtplc-offline-icon {
    width: 48px;
    height: 48px;
    margin: 0 auto 8px;
    background: #fef3c7;
    color: #d97706;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}
.dtplc-offline-banner h4 {
    margin: 0 0 4px;
    font-size: 15px;
    color: var(--dtplc-w-text-main);
}
.dtplc-offline-desc {
    margin: 0;
    font-size: 12px;
    color: var(--dtplc-w-text-muted);
}

/* Rating Screen */
.dtplc-rating-container {
    text-align: center;
    padding: 10px 4px;
}
.dtplc-rating-icon {
    margin-bottom: 8px;
}
.dtplc-rating-container h4 {
    margin: 0 0 4px;
    font-size: 16px;
    color: var(--dtplc-w-text-main);
}
.dtplc-rating-subtitle {
    margin: 0 0 12px;
    font-size: 12px;
    color: var(--dtplc-w-text-muted);
}

.dtplc-star-rating {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-bottom: 10px;
}
.dtplc-star {
    background: none;
    border: none;
    font-size: 26px;
    color: #cbd5e1;
    cursor: pointer;
    transition: color 0.15s ease, transform 0.15s ease;
    padding: 0 2px;
}
.dtplc-star:hover,
.dtplc-star.is-selected {
    color: #f59e0b;
    transform: scale(1.15);
}

.dtplc-checkbox-group {
    margin: 10px 0;
    text-align: left;
}
.dtplc-checkbox-group label {
    font-size: 12px;
    color: #475569;
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}

.dtplc-alert-success {
    background: #dcfce7;
    color: #15803d;
    padding: 10px;
    border-radius: 8px;
    font-size: 12px;
    margin-top: 10px;
    text-align: center;
}
