﻿/* ═══════════════════════════════════════════════════════════════════════════
   UserChatMobile.css — Chat Widget
   Palette: #abba7b pharmacy sage green
═══════════════════════════════════════════════════════════════════════════ */

:root {
    --chat-green: #abba7b;
    --chat-green-dark: #97a66a;
    --chat-green-light: #f0f4e8;
    --chat-green-ghost: #f7f9f3;
    --chat-bg: #f0f2ec;
    --chat-white: #ffffff;
    --chat-text: #1a1a1a;
    --chat-muted: #8a8a8a;
    --chat-border: #dde3d4;
    --chat-bubble-in: #ffffff;
    --chat-bubble-out: #abba7b;
    --chat-radius: 16px;
}

.hidden {
    display: none !important;
}

/* ══ FAB ═══════════════════════════════════════════════════════════════════ */

.chat-fab {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--chat-green);
    color: #fff;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(171,186,123,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999999;
    transition: all 0.2s ease;
}

    .chat-fab:active {
        transform: scale(.92);
    }

.fab-icon {
    font-size: 22px;
    line-height: 1;
}

.fab-badge {
    position: absolute;
    top: -3px;
    right: -3px;
    background: #d94040;
    color: #fff;
    border-radius: 50%;
    min-width: 18px;
    height: 18px;
    font-size: 10px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #fff;
}

/* ══ Modal ═════════════════════════════════════════════════════════════════ */

.chat-modal {
    position: fixed;
    bottom: 80px;
    right: 20px;
    width: 360px;
    height: 520px;
    z-index: 9999999;
    border-radius: var(--chat-radius);
    overflow: hidden;
    box-shadow: 0 6px 30px rgba(0,0,0,.18);
    background: rgba(255,255,255,0.92);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    animation: slideUp .2s ease;
}

.chat-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(12px);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

/* ══ Header ════════════════════════════════════════════════════════════════ */

.chat-header {
    background: linear-gradient(135deg, #abba7b 0%, #97a66a 100%);
    color: #fff;
    padding: 12px 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    text-shadow: 0 1px 2px rgba(0,0,0,0.15);
}

.header-info {
    display: flex;
    gap: 10px;
    align-items: center;
}

.header-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: rgba(255,255,255,.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    padding:6px;
}

.header-text h2 {
    margin: 0;
    font-size: 13px;
    font-weight: 600;
}

.header-text p {
    margin: 1px 0 0;
    font-size: 10px;
    opacity: .75;
}

.header-actions {
    display: flex;
    gap: 4px;
}

.header-btn {
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 50%;
    background: rgba(255,255,255,.15);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: all 0.2s ease;
}

    .header-btn:active {
        background: rgba(255,255,255,.3);
    }

/* ══ Screens ═══════════════════════════════════════════════════════════════ */

.screen {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

/* ── FAQ screen ─────────────────────────── */

.faq-container {
    padding: 14px 12px;
    overflow-y: auto;
    flex: 1;
}

.faq-greeting {
    text-align: center;
    padding: 14px 8px 12px;
    font-size: 13px;
    color: #555;
    line-height: 1.9;
    justify-content:center;
}

.faq-greeting-icon {
    font-size: 28px;
    margin-bottom: 15px;
    width: 100px;
    justify-self: anchor-center;
}

.faq-item {
    display: flex;
    align-items: center;
    padding: 11px 12px;
    margin-bottom: 6px;
    border: 1.5px solid var(--chat-border);
    border-radius: 10px;
    cursor: pointer;
    background: var(--chat-white);
    font-size: 12px;
    color: #444;
    transition: all 0.15s;
}

.faq-item:active {
    background: var(--chat-green-light);
    border-color: var(--chat-green);
}

.faq-item .faq-icon {
    margin-left: 8px;
    font-size: 16px;
    flex-shrink: 0;
}

.faq-chevron {
    margin-right: auto;
    font-size: 9px;
    color: var(--chat-muted);
    transition: transform 0.2s;
}

.faq-item.expanded .faq-chevron {
    transform: rotate(180deg);
}

.faq-item.expanded {
    border-radius: 10px 10px 0 0;
    margin-bottom: 0;
    border-color: var(--chat-green);
    background: var(--chat-green-light);
}

.faq-answer {
    display: none;
    padding: 10px 12px;
    margin: 0 0 6px;
    background: var(--chat-green-ghost);
    border: 1.5px solid var(--chat-border);
    border-top: none;
    border-radius: 0 0 10px 10px;
    font-size: 11px;
    color: #555;
    line-height: 1.9;
}

.faq-answer.open {
    display: block;
}

.connect-support-btn {
    display: block;
    width: 100%;
    padding: 11px;
    margin-top: 12px;
    text-align: center;
    color: #fff;
    background: linear-gradient(135deg, var(--chat-green) 0%, var(--chat-green-dark) 100%);
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    box-shadow: 0 3px 12px rgba(171, 186, 123, 0.3);
    transition: all 0.2s;
}

.connect-support-btn:active {
    transform: translateY(-1px);
    box-shadow: 0 5px 16px rgba(171, 186, 123, 0.4);
}

/* ── Guest form ──────────────────────────── */

.guest-form {
    padding: 24px 18px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    text-align: center;
}

.form-icon {
    font-size: 36px;
}

.guest-form h3 {
    margin: 0;
    font-size: 14px;
    color: var(--chat-text);
}

.guest-form > p {
    margin: 0;
    font-size: 11px;
    color: var(--chat-muted);
}

.form-field {
    text-align: right;
}

    .form-field label {
        display: block;
        font-size: 11px;
        color: var(--chat-muted);
        margin-bottom: 4px;
        font-weight: 600;
    }

    .form-field input {
        width: 100%;
        padding: 10px 12px;
        border: 1.5px solid var(--chat-border);
        border-radius: 10px;
        font-size: 13px;
        outline: none;
        background: var(--chat-ghost);
        font-family: inherit;
        transition: border-color .15s;
    }

        .form-field input:focus {
            border-color: var(--chat-green);
        }

.form-btn {
    background: var(--chat-green);
    color: #fff;
    border: none;
    padding: 11px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 2px;
    font-family: inherit;
    transition: all 0.2s ease;
}

    .form-btn:active {
        background: var(--chat-green-dark);
    }

/* ── Department ──────────────────────────── */

.dept-header {
    text-align: center;
    padding: 20px 16px 10px;
}

.dept-icon {
    font-size: 30px;
    margin-bottom: 4px;
}

.dept-header h3 {
    margin: 0;
    font-size: 13px;
    color: var(--chat-text);
}

.dept-list {
    padding: 6px 12px 12px;
    flex: 1;
}

.dept-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 12px;
    border: 1.5px solid var(--chat-border);
    border-radius: 10px;
    cursor: pointer;
    margin-bottom: 6px;
    transition: background .12s, border-color .12s;
}

    .dept-item:active {
        background: var(--chat-green-light);
        border-color: var(--chat-green);
    }

.dept-item-icon {
    font-size: 18px;
}

.dept-item-info strong {
    font-size: 12px;
    color: var(--chat-text);
}

.dept-arrow {
    margin-right: auto;
    color: var(--chat-muted);
    font-size: 12px;
}

.dept-loading, .dept-empty {
    text-align: center;
    padding: 28px;
    color: var(--chat-muted);
    font-size: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.mini-spinner {
    width: 12px;
    height: 12px;
    border: 2px solid var(--chat-border);
    border-top: 2px solid var(--chat-green);
    border-radius: 50%;
    animation: spin .6s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ══ Chat area ═════════════════════════════════════════════════════════════ */

.messages-area {
    flex: 1;
    overflow-y: auto;
    padding: 12px 10px;
    background: var(--chat-bg);
    display: flex;
    flex-direction: column;
    gap: 3px;
}

    .messages-area::-webkit-scrollbar {
        width: 0;
    }

/* ── Messages ─────────────────────────────── */

.message {
    display: flex;
    gap: 6px;
    max-width: 82%;
    animation: msgIn .15s ease;
}

@keyframes msgIn {
    from {
        opacity: 0;
        transform: translateY(4px);
    }

    to {
        opacity: 1;
    }
}

.msg-incoming {
    align-self: flex-start;
}

.msg-outgoing {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.msg-avatar {
    width: 26px;
    height: 26px;
    min-width: 26px;
    border-radius: 50%;
    background: var(--chat-green);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    flex-shrink: 0;
    align-self: flex-end;
}

.msg-bubble {
    padding: 8px 11px;
    border-radius: 12px;
    font-size: 13px;
    line-height: 1.65;
    word-wrap: break-word;
}

.msg-incoming .msg-bubble {
    background: var(--chat-bubble-in);
    color: var(--chat-text);
    border-bottom-right-radius: 3px;
    box-shadow: 0 1px 1px rgba(0,0,0,.04);
}

.msg-outgoing .msg-bubble {
    background: var(--chat-bubble-out);
    color: #fff;
    border-bottom-left-radius: 3px;
}

.msg-bubble.sending {
    opacity: .6;
}

.msg-time {
    font-size: 9px;
    opacity: .55;
    margin-top: 3px;
    display: flex;
    align-items: center;
    gap: 3px;
    justify-content: flex-end;
}

.msg-outgoing .msg-time {
    color: rgba(255,255,255,.7);
}

.msg-tick {
    font-size: 10px;
}

    .msg-tick.sending {
        animation: pulse .8s infinite;
    }

@keyframes pulse {
    0%,100% {
        opacity: 1
    }

    50% {
        opacity: .3
    }
}

.msg-image {
    max-width: 180px;
    border-radius: 8px;
    display: block;
    margin-top: 3px;
}

.msg-file-link {
    display: block;
    margin-top: 3px;
    color: inherit;
    text-decoration: underline;
    font-size: 11px;
}

/* System message */
.system-msg {
    align-self: center;
    background: rgba(171,186,123,.1);
    color: var(--chat-green-dark);
    padding: 4px 12px;
    border-radius: 99px;
    font-size: 10px;
    margin: 6px 0;
}

/* ── Typing ───────────────────────────────── */

.typing-bar {
    padding: 5px 12px;
    font-size: 10px;
    color: var(--chat-muted);
    display: flex;
    align-items: center;
    gap: 5px;
    background: var(--chat-bg);
}

.typing-dots {
    display: flex;
    gap: 2px;
}

    .typing-dots span {
        width: 4px;
        height: 4px;
        border-radius: 50%;
        background: var(--chat-muted);
        animation: dot 1.2s infinite;
    }

        .typing-dots span:nth-child(2) {
            animation-delay: .15s;
        }

        .typing-dots span:nth-child(3) {
            animation-delay: .3s;
        }

@keyframes dot {
    0%,60%,100% {
        transform: translateY(0);
        opacity: .35
    }

    30% {
        transform: translateY(-3px);
        opacity: 1
    }
}

/* ── Quick replies ────────────────────────── */

.quick-replies {
    padding: 5px 10px;
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    background: var(--chat-bg);
    border-top: 1px solid rgba(0,0,0,.04);
}

.qr-btn {
    background: var(--chat-white);
    border: 1px solid var(--chat-border);
    color: var(--chat-green-dark);
    padding: 5px 9px;
    border-radius: 99px;
    font-size: 10px;
    cursor: pointer;
    white-space: nowrap;
    font-family: inherit;
    transition: all 0.2s ease;
}

    .qr-btn:active {
        background: var(--chat-green-light);
        border-color: var(--chat-green);
    }

/* ══ Input area ════════════════════════════════════════════════════════════ */

.input-area {
    padding: 8px 10px;
    padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
    background: var(--chat-white);
    border-top: 1px solid var(--chat-border);
    flex-shrink: 0;
}

.input-row {
    display: flex;
    align-items: flex-end;
    gap: 6px;
}

.attach-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--chat-green-light);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 15px;
    flex-shrink: 0;
    transition: all 0.2s ease;
}

    .attach-btn:active {
        background: var(--chat-green);
        color: #fff;
    }

#messageInput {
    flex: 1;
    border: 1.5px solid var(--chat-border);
    border-radius: 18px;
    padding: 10px 12px;
    font-size: 13px;
    line-height: 1.4;
    resize: none;
    outline: none;
    min-height: 44px;
    max-height: 80px;
    font-family: inherit;
    background: var(--chat-ghost);
    transition: border-color .15s;
}

    #messageInput:focus {
        border-color: var(--chat-green);
        background: #fff;
    }

    #messageInput::placeholder {
        color: #b0b0b0;
    }

.send-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, #abba7b 0%, #97a66a 100%);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s ease;
}

    .send-btn:active {
        background: var(--chat-green-dark);
    }

    .send-btn svg {
        transform: scaleX(-1);
        width: 16px;
        height: 16px;
    }

.msg-tick.read {
    color: #4fc3f7;
}

.msg-tick.failed {
    color: #e74c3c;
}

/* ══ Mobile fullscreen ═════════════════════════════════════════════════════ */

@media (max-width: 480px) {
    .chat-modal {
        bottom: 0;
        right: 0;
        left: 0;
        top: 0;
        width: 100%;
        height: 100%;
        border-radius: 0;
    }

    .chat-fab {
        bottom: 14px;
        right: 14px;
        width: 48px;
        height: 48px;
    }

    .fab-icon {
        font-size: 20px;
    }
}
