/* ── Chat Widget ── Matches 1st Choice Fingerprinting brand ──── */

/* Brand Colors:
   --dark-navy:   #120138
   --deep-purple: #1e025b
   --purple:      #9148F9
   --button-blue: #4012E4
   --footer-dark: #0d0033
   --gradient:    linear-gradient(90deg, #1e025b, #9148F9)
   --font:        "Roboto", sans-serif
*/

/* ── Floating Button ─────────────────────────────────────────── */

.chat-widget-btn {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    width: 58px;
    height: 58px;
    border-radius: 50%;
    background: linear-gradient(135deg, #1e025b, #9148F9);
    color: #fff;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(30, 2, 91, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, box-shadow 0.2s;
}

.chat-widget-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 24px rgba(30, 2, 91, 0.6);
}

.chat-widget-btn svg {
    width: 26px;
    height: 26px;
    fill: currentColor;
}

/* ── Panel ─────────────────────────────────────────────────────── */

.chat-widget-panel {
    position: fixed;
    bottom: 94px;
    right: 24px;
    z-index: 9999;
    width: 380px;
    height: 520px;
    max-height: calc(100vh - 120px);
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(18, 1, 56, 0.22);
    display: none;
    flex-direction: column;
    overflow: hidden;
    font-family: "Roboto", sans-serif;
    border: 1px solid rgba(145, 72, 249, 0.15);
}

.chat-widget-panel.open {
    display: flex;
    animation: chat-slide-up 0.3s ease-out;
}

@keyframes chat-slide-up {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ── Header ────────────────────────────────────────────────────── */

.chat-widget-header {
    background: linear-gradient(90deg, #1e025b, #9148F9);
    color: #fff;
    padding: 16px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.chat-widget-header h4 {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 0.2px;
}

.chat-widget-header .chat-close-btn {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: #fff;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    padding: 0;
    line-height: 1;
}

.chat-widget-header .chat-close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* ── Start Form ────────────────────────────────────────────────── */

.chat-widget-start {
    padding: 20px 16px 16px;
    text-align: center;
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.chat-widget-start p {
    margin: 0 0 14px;
    font-size: 13px;
    color: #444;
    line-height: 1.5;
}

.chat-widget-start input {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid #e0dce8;
    border-radius: 8px;
    font-size: 13px;
    font-family: "Roboto", sans-serif;
    margin-bottom: 10px;
    outline: none;
    box-sizing: border-box;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.cw-category-select {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid #e0dce8;
    border-radius: 8px;
    font-size: 13px;
    font-family: "Roboto", sans-serif;
    margin-bottom: 10px;
    outline: none;
    box-sizing: border-box;
    background: #fff;
    color: #333;
    appearance: auto;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.cw-category-select:focus {
    border-color: #9148F9;
    box-shadow: 0 0 0 3px rgba(145, 72, 249, 0.12);
}

.cw-category-select option[value=""] {
    color: #999;
}

.chat-widget-start input:focus,
.chat-widget-start textarea:focus {
    border-color: #9148F9;
    box-shadow: 0 0 0 3px rgba(145, 72, 249, 0.12);
}

.chat-widget-start textarea {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid #e0dce8;
    border-radius: 8px;
    font-size: 13px;
    font-family: "Roboto", sans-serif;
    margin-bottom: 10px;
    outline: none;
    box-sizing: border-box;
    resize: vertical;
    min-height: 60px;
    max-height: 100px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.cw-quick-links {
    margin-top: auto;
    margin-bottom: 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.cw-quick-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 11px;
    font-weight: 500;
    color: #1e025b;
    text-decoration: none;
    background: #f8f7fc;
    transition: background 0.2s, color 0.2s;
}

.cw-quick-link:hover {
    background: #e0dce8;
    color: #120138;
}

.cw-quick-link svg {
    flex-shrink: 0;
    color: #9148F9;
}

.chat-widget-start button {
    flex-shrink: 0;
    width: 100%;
    padding: 11px;
    background: #4012E4;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    font-family: "Roboto", sans-serif;
    cursor: pointer;
    transition: background 0.2s, box-shadow 0.2s;
}

.chat-widget-start button:hover {
    background: #1e025b;
    box-shadow: 0 2px 8px rgba(30, 2, 91, 0.3);
}

.chat-widget-start button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ── Chat Body & Area ──────────────────────────────────────────── */

.chat-widget-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

#cw-chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

/* ── Status Banner ─────────────────────────────────────────────── */

.chat-widget-status {
    padding: 10px 18px;
    font-size: 13px;
    font-weight: 500;
    text-align: center;
    background: #f0ebfa;
    color: #1e025b;
    border-bottom: 1px solid rgba(145, 72, 249, 0.1);
}

.chat-widget-status .cw-countdown {
    display: inline-block;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    min-width: 28px;
}

.chat-widget-status.active {
    background: #e8f5e9;
    color: #2e7d32;
}

/* ── Messages ──────────────────────────────────────────────────── */

.chat-widget-messages {
    flex: 1;
    overflow-y: auto;
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 0;
    background: #f8f7fc;
}

.chat-msg {
    max-width: 78%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 13px;
    line-height: 1.45;
    word-wrap: break-word;
}

.chat-msg.visitor {
    align-self: flex-end;
    background: linear-gradient(135deg, #1e025b, #4012E4);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.chat-msg.agent {
    align-self: flex-start;
    background: #fff;
    color: #120138;
    border: 1px solid #e0dce8;
    border-bottom-left-radius: 4px;
}

.chat-msg .chat-msg-meta {
    font-size: 10px;
    margin-bottom: 3px;
    font-weight: 500;
}

.chat-msg.visitor .chat-msg-meta {
    color: rgba(255, 255, 255, 0.65);
}

.chat-msg.agent .chat-msg-meta {
    color: #9148F9;
}

.chat-msg-system {
    text-align: center;
    font-size: 11px;
    color: #999;
    padding: 4px 0;
}

/* ── Typing Indicator ──────────────────────────────────────────── */

.cw-typing-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 16px;
    font-size: 12px;
    color: #9148F9;
    background: #f8f7fc;
    border-top: 1px solid #e0dce8;
}

.cw-typing-text {
    font-weight: 500;
}

.cw-typing-dots {
    display: inline-flex;
    gap: 3px;
    align-items: center;
}

.cw-typing-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #9148F9;
    animation: cw-dot-bounce 1.4s infinite ease-in-out both;
}

.cw-typing-dots span:nth-child(1) { animation-delay: 0s; }
.cw-typing-dots span:nth-child(2) { animation-delay: 0.16s; }
.cw-typing-dots span:nth-child(3) { animation-delay: 0.32s; }

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

/* ── Input Area ────────────────────────────────────────────────── */

.chat-widget-input {
    display: flex;
    padding: 12px 14px;
    border-top: 1px solid #e0dce8;
    gap: 8px;
    background: #fff;
}

.chat-widget-input input {
    flex: 1;
    padding: 10px 14px;
    border: 2px solid #e0dce8;
    border-radius: 24px;
    font-size: 13px;
    font-family: "Roboto", sans-serif;
    outline: none;
    box-sizing: border-box;
    transition: border-color 0.2s;
}

.chat-widget-input input:focus {
    border-color: #9148F9;
}

.chat-widget-input button {
    padding: 10px 18px;
    background: #4012E4;
    color: #fff;
    border: none;
    border-radius: 24px;
    font-size: 13px;
    font-weight: 600;
    font-family: "Roboto", sans-serif;
    cursor: pointer;
    transition: background 0.2s;
    white-space: nowrap;
}

.chat-widget-input button:hover {
    background: #1e025b;
}

/* ── End Chat Button ───────────────────────────────────────────── */

.chat-widget-end-btn {
    display: block;
    width: calc(100% - 28px);
    margin: 0 14px 12px;
    padding: 7px;
    background: none;
    border: 1px solid #ccc;
    color: #888;
    border-radius: 8px;
    font-size: 12px;
    font-family: "Roboto", sans-serif;
    cursor: pointer;
    transition: background 0.2s, color 0.2s, border-color 0.2s;
}

.chat-widget-end-btn:hover {
    background: #120138;
    color: #fff;
    border-color: #120138;
}

/* ── Feedback ──────────────────────────────────────────────────── */

.chat-widget-feedback {
    padding: 24px 20px;
    text-align: center;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.chat-widget-feedback p {
    margin: 0 0 14px;
    font-size: 15px;
    font-weight: 500;
    color: #120138;
}

.chat-widget-feedback .star-rating {
    display: inline-flex;
    gap: 6px;
    margin-bottom: 14px;
    justify-content: center;
}

.chat-widget-feedback textarea {
    margin-top: auto;
}

.chat-widget-feedback .star-rating span {
    font-size: 30px;
    color: #e0dce8;
    cursor: pointer;
    transition: color 0.15s, transform 0.15s;
}

.chat-widget-feedback .star-rating span.active {
    color: #9148F9;
}

.chat-widget-feedback .star-rating span:hover {
    transform: scale(1.15);
}

.chat-widget-feedback textarea {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid #e0dce8;
    border-radius: 8px;
    font-size: 13px;
    font-family: "Roboto", sans-serif;
    resize: vertical;
    min-height: 60px;
    margin-bottom: 12px;
    outline: none;
    box-sizing: border-box;
    transition: border-color 0.2s;
}

.chat-widget-feedback textarea:focus {
    border-color: #9148F9;
}

.chat-widget-feedback button {
    width: 100%;
    padding: 10px;
    background: #4012E4;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    font-family: "Roboto", sans-serif;
    cursor: pointer;
    transition: background 0.2s;
}

.chat-widget-feedback button:hover {
    background: #1e025b;
}

.chat-widget-feedback .skip-btn {
    background: none;
    color: #999;
    border: none;
    font-size: 12px;
    font-family: "Roboto", sans-serif;
    cursor: pointer;
    margin-top: 10px;
    display: block;
    width: 100%;
    text-align: center;
    transition: color 0.2s;
}

.chat-widget-feedback .skip-btn:hover {
    color: #1e025b;
}

/* ── Unavailable Screen ────────────────────────────────────────── */

.chat-widget-unavailable {
    padding: 28px 20px;
    text-align: center;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.cw-unavail-icon {
    margin-bottom: 14px;
}

.chat-widget-unavailable h5 {
    margin: 0 0 10px;
    font-size: 16px;
    font-weight: 700;
    color: #120138;
}

.chat-widget-unavailable p {
    margin: 0 0 20px;
    font-size: 13px;
    color: #555;
    line-height: 1.55;
    flex: 1;
}

.cw-unavail-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 11px 14px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    font-family: "Roboto", sans-serif;
    text-decoration: none;
    margin-bottom: 10px;
    transition: background 0.2s, color 0.2s;
    box-sizing: border-box;
    cursor: pointer;
}

.cw-unavail-phone {
    background: #4012E4;
    color: #fff;
    border: none;
}

.cw-unavail-phone:hover {
    background: #1e025b;
    color: #fff;
}

.cw-unavail-zoom {
    background: #fff;
    color: #1e025b;
    border: 2px solid #1e025b;
}

.cw-unavail-zoom:hover {
    background: #1e025b;
    color: #fff;
}

.cw-unavail-close {
    display: block;
    width: 100%;
    margin-top: 6px;
    padding: 8px;
    background: none;
    border: none;
    color: #999;
    font-size: 12px;
    font-family: "Roboto", sans-serif;
    cursor: pointer;
    transition: color 0.2s;
}

.cw-unavail-close:hover {
    color: #1e025b;
}

/* ── Custom Dialog ─────────────────────────────────────────────── */

.cw-dialog-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(18, 1, 56, 0.45);
    backdrop-filter: blur(3px);
    display: none;
    align-items: center;
    justify-content: center;
    font-family: "Roboto", sans-serif;
}

.cw-dialog-overlay.visible {
    display: flex;
    animation: cw-fade-in 0.2s ease-out;
}

@keyframes cw-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

.cw-dialog {
    background: #fff;
    border-radius: 16px;
    padding: 28px 24px 22px;
    width: 340px;
    max-width: calc(100vw - 32px);
    box-shadow: 0 16px 48px rgba(18, 1, 56, 0.3);
    text-align: center;
    animation: cw-dialog-pop 0.25s ease-out;
}

@keyframes cw-dialog-pop {
    from {
        opacity: 0;
        transform: scale(0.92) translateY(8px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.cw-dialog-icon {
    margin-bottom: 12px;
    line-height: 1;
}

.cw-dialog-title {
    margin: 0 0 8px;
    font-size: 17px;
    font-weight: 700;
    color: #120138;
}

.cw-dialog-msg {
    margin: 0 0 22px;
    font-size: 14px;
    color: #555;
    line-height: 1.5;
}

.cw-dialog-actions {
    display: flex;
    gap: 10px;
}

.cw-dialog-btn {
    flex: 1;
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    font-family: "Roboto", sans-serif;
    cursor: pointer;
    transition: background 0.2s, color 0.2s, border-color 0.2s;
    border: none;
}

.cw-dialog-cancel {
    background: #f0ebfa;
    color: #1e025b;
    border: 1px solid #e0dce8;
}

.cw-dialog-cancel:hover {
    background: #e0dce8;
}

.cw-dialog-confirm {
    background: #4012E4;
    color: #fff;
}

.cw-dialog-confirm:hover {
    background: #1e025b;
}

.cw-dialog-confirm.cw-dialog-danger {
    background: #dc3545;
}

.cw-dialog-confirm.cw-dialog-danger:hover {
    background: #b02a37;
}

/* ── Push back-to-top button left so it doesn't overlap chat ── */

.back-to-top {
    right: 90px !important;
}

/* ── Responsive ────────────────────────────────────────────────── */

@media (max-width: 480px) {
    .chat-widget-panel {
        width: calc(100vw - 16px);
        right: 8px;
        bottom: 84px;
        max-height: calc(100vh - 100px);
    }

    .chat-widget-btn {
        bottom: 16px;
        right: 16px;
    }
}
