/* ═══ VitaraAfya AI Chat Widget ═══ */

.va-chat {
    position: fixed;
    bottom: 148px;
    right: 16px;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ─── Toggle Button ─────────────────────────────────── */
.va-chat__toggle {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0077B6, #00B4D8);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(0, 119, 182, 0.4);
    transition: all 0.3s ease;
    position: absolute;
    bottom: 0;
    right: 0;
}

.va-chat__toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 24px rgba(0, 119, 182, 0.5);
}

.va-chat__toggle svg {
    width: 24px;
    height: 24px;
}

.va-chat__icon-close { display: none; }
.va-chat.is-open .va-chat__icon-open { display: none; }
.va-chat.is-open .va-chat__icon-close { display: block !important; }
.va-chat.is-open .va-chat__toggle { background: linear-gradient(135deg, #6c757d, #495057); }

/* ─── Panel ─────────────────────────────────────────── */
.va-chat__panel {
    display: none;
    position: absolute;
    bottom: 70px;
    right: 0;
    width: 380px;
    height: 520px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.18);
    flex-direction: column;
    overflow: hidden;
    animation: va-chat-slide-up 0.25s ease-out;
}

.va-chat.is-open .va-chat__panel { display: flex; }

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

/* ─── Header ────────────────────────────────────────── */
.va-chat__header {
    background: linear-gradient(135deg, #0077B6, #00B4D8);
    color: #fff;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.va-chat__header-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.va-chat__avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 13px;
}

.va-chat__name {
    font-weight: 600;
    font-size: 15px;
}

.va-chat__status {
    font-size: 11px;
    opacity: 0.85;
}

.va-chat__header-actions {
    display: flex;
    gap: 4px;
}

.va-chat__btn-icon {
    width: 32px;
    height: 32px;
    border: none;
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.va-chat__btn-icon:hover {
    background: rgba(255, 255, 255, 0.3);
}

.va-chat__btn-icon svg {
    width: 16px;
    height: 16px;
}

/* ─── Sessions Sidebar ──────────────────────────────── */
.va-chat__sessions {
    border-bottom: 1px solid #e5e7eb;
    max-height: 200px;
    overflow-y: auto;
}

.va-chat__sessions-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    font-weight: 600;
    font-size: 13px;
    color: #6b7280;
    border-bottom: 1px solid #f3f4f6;
}

.va-chat__sessions-header .va-chat__btn-icon {
    background: transparent;
    color: #6b7280;
}

.va-chat__sessions-list {
    max-height: 160px;
    overflow-y: auto;
}

.va-chat__session-item {
    padding: 10px 14px;
    cursor: pointer;
    border-bottom: 1px solid #f9fafb;
    transition: background 0.15s;
}

.va-chat__session-item:hover {
    background: #f0f8ff;
}

.va-chat__session-item.is-active {
    background: #e0f2fe;
    border-left: 3px solid #0077B6;
}

.va-chat__session-title {
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.va-chat__session-time {
    font-size: 11px;
    color: #9ca3af;
}

.va-chat__session-delete {
    float: right;
    background: none;
    border: none;
    color: #dc2626;
    cursor: pointer;
    font-size: 12px;
    padding: 2px 6px;
    border-radius: 4px;
}

.va-chat__session-delete:hover {
    background: #fef2f2;
}

/* ─── Messages ──────────────────────────────────────── */
.va-chat__messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
}

.va-chat__welcome {
    text-align: center;
    padding: 24px 16px;
    color: #6b7280;
}

.va-chat__welcome-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0077B6, #00B4D8);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 16px;
    margin: 0 auto 12px;
}

.va-chat__welcome h4 {
    margin: 0 0 6px;
    color: #1a1a2e;
    font-size: 16px;
}

.va-chat__welcome p {
    margin: 0 0 16px;
    font-size: 13px;
}

.va-chat__quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
}

.va-chat__quick-btn {
    padding: 6px 14px;
    border: 1px solid #d1d5db;
    background: #fff;
    border-radius: 20px;
    font-size: 12px;
    cursor: pointer;
    color: #374151;
    transition: all 0.2s;
}

.va-chat__quick-btn:hover {
    border-color: #0077B6;
    color: #0077B6;
    background: #f0f8ff;
}

/* ─── Message Bubbles ───────────────────────────────── */
.va-chat__msg {
    display: flex;
    flex-direction: column;
    max-width: 85%;
    animation: va-chat-fade-in 0.2s ease-out;
}

@keyframes va-chat-fade-in {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

.va-chat__msg--user {
    align-self: flex-end;
}

.va-chat__msg--assistant {
    align-self: flex-start;
}

.va-chat__bubble {
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    white-space: pre-wrap;
}

.va-chat__msg--user .va-chat__bubble {
    background: #0077B6;
    color: #fff;
    border-bottom-right-radius: 4px;
}

.va-chat__msg--assistant .va-chat__bubble {
    background: #f3f4f6;
    color: #1a1a2e;
    border-bottom-left-radius: 4px;
}

.va-chat__bubble p { margin: 0 0 6px; }
.va-chat__bubble p:last-child { margin-bottom: 0; }
.va-chat__bubble strong { font-weight: 600; color: #111827; }
.va-chat__bubble code {
    background: #e5e7eb;
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 12px;
    font-family: 'SF Mono', 'Consolas', monospace;
}
.va-chat__bubble ul, .va-chat__bubble ol {
    margin: 4px 0;
    padding-left: 20px;
}
.va-chat__bubble li { margin: 2px 0; }

.va-chat__msg-time {
    font-size: 10px;
    color: #9ca3af;
    margin-top: 4px;
    padding: 0 4px;
}

.va-chat__msg--user .va-chat__msg-time {
    text-align: right;
}

/* ─── Feedback Buttons ────────────────────────────────── */
.va-chat__feedback {
    display: flex;
    gap: 4px;
    margin-top: 4px;
    padding: 0 4px;
}

.va-chat__feedback-btn {
    background: none;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 2px 8px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
    line-height: 1;
}

.va-chat__feedback-btn:hover {
    border-color: #0077B6;
    background: #f0f8ff;
}

.va-chat__feedback-btn.is-rated {
    cursor: default;
}

.va-chat__feedback-btn.is-active {
    border-color: #0077B6;
    background: #e0f2fe;
}

/* ─── Typing Indicator ──────────────────────────────── */
.va-chat__typing {
    padding: 8px 16px;
    display: flex;
    gap: 4px;
    align-items: center;
}

.va-chat__typing span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #9ca3af;
    animation: va-chat-bounce 1.4s infinite ease-in-out;
}

.va-chat__typing span:nth-child(2) { animation-delay: 0.2s; }
.va-chat__typing span:nth-child(3) { animation-delay: 0.4s; }

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

/* ─── Input Area ────────────────────────────────────── */
.va-chat__input-area {
    display: flex;
    padding: 12px;
    gap: 8px;
    border-top: 1px solid #e5e7eb;
    background: #fff;
}

.va-chat__input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid #d1d5db;
    border-radius: 24px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
    background: #f9fafb;
}

.va-chat__input:focus {
    border-color: #0077B6;
    background: #fff;
}

.va-chat__send {
    width: 40px;
    height: 40px;
    border: none;
    background: #0077B6;
    color: #fff;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    flex-shrink: 0;
}

.va-chat__send:hover {
    background: #005f8a;
}

.va-chat__send:disabled {
    background: #9ca3af;
    cursor: not-allowed;
}

.va-chat__send svg {
    width: 18px;
    height: 18px;
}

/* ─── Mobile Responsive ─────────────────────────────── */
@media (max-width: 480px) {
    .va-chat {
        bottom: 140px;
        right: 12px;
    }

    .va-chat__panel {
        position: fixed;
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        height: calc(100vh - 70px);
        border-radius: 0;
        animation: va-chat-slide-up-mobile 0.25s ease-out;
    }

    @keyframes va-chat-slide-up-mobile {
        from { transform: translateY(100%); }
        to { transform: translateY(0); }
    }

    .va-chat__toggle {
        bottom: 0;
        right: 0;
    }
}

/* ─── Scrollbar ─────────────────────────────────────── */
.va-chat__messages::-webkit-scrollbar,
.va-chat__sessions-list::-webkit-scrollbar {
    width: 5px;
}

.va-chat__messages::-webkit-scrollbar-thumb,
.va-chat__sessions-list::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 4px;
}
