* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 14px;
    /* Global scale to achieve "80% zoom" effect */
}

:root {
    /* Jedinstvena medicinska paleta – ista kao u sidebarovima */
    --bg: #f8fafc;
    --surface: #ffffff;
    --text-primary: #111827;
    --text-secondary: #475569;
    --text-light: #6b7280;
    --border: #e5e7eb;
    --border-light: #f3f4f6;
    --accent: #0d9488;
    --accent-hover: #0f766e;
    --accent-light: #ccfbf1;
    --shadow: rgba(0, 0, 0, 0.08);
    --shadow-lg: rgba(0, 0, 0, 0.15);
}

body {
    font-family: 'Inter', 'Segoe UI', Roboto, sans-serif;
    background: #f1f5f9;
    color: var(--text-primary);
    height: 100vh;
    display: flex;
    overflow: hidden;
    /* Avoid page scroll */
}

/* ==================== GLAVNI LAYOUT ==================== */
.app-layout {
    width: 100%;
    max-width: 100%;
    /* Fully responsive */
    height: 100vh;
    display: flex;
    background: var(--surface);
    overflow: hidden;
    position: relative;
}

/* ==================== SIDEBAROVI (levi i desni) ==================== */
/* Stilovi su sada u leftSidebar.css i rightSidebar.css */
/* Ovde samo osnovno pozicioniranje */
.sidebar {
    flex-shrink: 0;
    position: relative;
    z-index: 10;
}

/* ==================== CENTRALNI DEO ==================== */
.main-content {
    flex: 1;
    display: flex;
    overflow: hidden;
    position: relative;
    background: var(--bg);
}

/* Kada je pacijent izabran */
.patient-selected-view {
    display: flex;
    width: 100%;
    height: 100%;
}

/* Kada NEMA pacijenta – welcome ekran */
.no-patient-view {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #f8fafc 0%, #e0f2fe 100%);
    z-index: 20;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s ease;
    padding: 40px;
}

.no-patient-view.active {
    opacity: 1;
    pointer-events: all;
}

.patient-selected-view.hidden {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s ease;
}

/* ==================== CHAT CONTAINER ==================== */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* Header */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}


.logout-btn-header {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.15);
    border: 1.5px solid rgba(255, 255, 255, 0.3);
    padding: 8px 16px;
    border-radius: 10px;
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.logout-btn-header:hover {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.5);
    transform: translateY(-1px);
}

.logout-btn-header svg {
    width: 18px;
    height: 18px;
}

/* Export PDF Button */
.export-pdf-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.15);
    border: 1.5px solid rgba(255, 255, 255, 0.3);
    padding: 8px 16px;
    border-radius: 10px;
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    margin-right: 12px;
}

.export-pdf-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.5);
    transform: translateY(-1px);
}

.export-pdf-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.export-pdf-btn svg {
    width: 18px;
    height: 18px;
}

/* App Version Badge */
.app-version-badge {
    display: inline-flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 4px 10px;
    border-radius: 16px;
    color: rgba(255, 255, 255, 0.75);
    font-size: 0.7rem;
    font-weight: 600;
    font-family: 'SF Mono', 'Courier New', monospace;
    letter-spacing: 0.5px;
    backdrop-filter: blur(4px);
    transition: all 0.2s ease;
    margin-left: 8px;
}

.app-version-badge:hover {
    background: rgba(255, 255, 255, 0.18);
    border-color: rgba(255, 255, 255, 0.35);
    color: rgba(255, 255, 255, 0.95);
}

.controls {
    display: none;
    /* Hide if not used, or re-enable if needed */
}

.model-selector,
.mode-toggle {
    padding: 10px 16px;
    background: rgba(255, 255, 255, 0.2);
    border: 1.5px solid rgba(255, 255, 255, 0.3);
    border-radius: 12px;
    color: white;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    backdrop-filter: blur(4px);
    transition: all 0.2s;
}

.model-selector:hover,
.mode-toggle:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-1px);
}

/* Quick Actions Bar */
.quick-actions {
    padding: 12px 20px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    overflow-x: auto;
    scrollbar-width: none;
}

.quick-actions::-webkit-scrollbar {
    display: none;
}

.qa-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 8px;
    background: transparent;
    color: var(--text-secondary);
    border: 2px solid var(--border);
    border-radius: 20px;
    font-size: 0.92rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.qa-btn img {
    width: 22px;
    height: 22px;
    opacity: 0.7;
    filter: grayscale(20%);
    transition: all 0.3s;
}

.qa-btn:hover {
    background: var(--accent);
    color: white;
    border-color: var(--accent-hover);
    transform: translateY(-4px);
    box-shadow: 0 10px 25px rgba(13, 148, 136, 0.25);
}

.qa-btn:hover img {
    opacity: 1;
    filter: none;
    transform: scale(1.15);
}

/* Chat Box */
#chat-box {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    background: var(--bg);
    display: flex;
    flex-direction: column;
    gap: 18px;
}

/* Poruke */
.message {
    max-width: 78%;
    padding: 14px 18px;
    border-radius: 20px;
    line-height: 1.55;
    font-size: 0.98rem;
    animation: fadeIn 0.35s ease;
    position: relative;
}

.message.user {
    align-self: flex-end;
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-hover) 100%);
    color: white;
    border-bottom-right-radius: 6px;
}

.message.bot {
    align-self: flex-start;
    background: var(--surface);
    color: var(--text-primary);
    border-bottom-left-radius: 6px;
    box-shadow: 0 4px 12px var(--shadow);
}

/* Special formatting for PDF Analysis messages */
.message.bot.pdf-analysis {
    background: #f0f9ff;
    border: 1.5px solid #0ea5e9;
    border-left: 5px solid #0ea5e9;
    box-shadow: 0 6px 16px rgba(14, 165, 233, 0.15);
}

.message.bot.pdf-analysis .formatted-bot strong {
    color: #0369a1;
}

.message.bot.pdf-analysis .message-content::before {
    content: 'PDF ANALYSIS REPORT' attr(data-source);
    display: block;
    font-size: 0.75rem;
    font-weight: 800;
    text-transform: uppercase;
    color: #0369a1;
    margin-bottom: 8px;
    letter-spacing: 1px;
    border-bottom: 1px solid rgba(14, 165, 233, 0.2);
    padding-bottom: 4px;
}

.model-badge {
    position: absolute;
    top: -10px;
    left: 12px;
    background: var(--accent);
    color: white;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.message-content {
    word-wrap: break-word;
}

.cursor {
    display: inline-block;
    width: 10px;
    animation: blink 1s infinite;
}

/* Input */
.input-container {
    padding: 20px 24px;
    background: var(--surface);
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.chat-input-area {
    padding: 20px;
    background: var(--surface);
    border-top: 1px solid var(--border);
    display: flex;
    gap: 12px;
    align-items: flex-end;
    /* Align to bottom for multiline */
}

.chat-input-area textarea {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid var(--border);
    border-radius: 20px;
    font-size: 0.95rem;
    font-family: inherit;
    resize: none;
    /* Auto-resize via JS ideally, or vertical */
    height: 50px;
    /* Base height */
    transition: all 0.3s;
}

.chat-input-area textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(13, 148, 136, 0.15);
}

.send-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-hover) 100%);
    color: white;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s;
    flex-shrink: 0;
}

.send-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(13, 148, 136, 0.3);
}

.send-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.send-btn svg {
    width: 24px;
    height: 24px;
    margin-left: -2px;
    /* Visual center adjustment */
}

/* ==================== WELCOME EKRAN ==================== */
.welcome-doctor {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

.welcome-content {
    text-align: center;
    max-width: 900px;
}

.doctor-avatar {
    width: 160px;
    height: 160px;
    border-radius: 50%;
    border: 8px solid white;
    box-shadow: 0 15px 40px rgba(13, 148, 136, 0.25);
    object-fit: cover;
    margin-bottom: 24px;
}

.welcome-text h1 {
    font-size: 2.4rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

#doctor-name {
    font-size: 4rem;
    font-weight: 900;
    background: linear-gradient(135deg, var(--accent), var(--accent-hover));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin: 0;
}

.welcome-doctor>p {
    font-size: 1.4rem;
    color: var(--text-secondary);
    margin: 24px 0 40px;
    max-width: 700px;
}

.doctor-stats-placeholder {
    display: flex;
    gap: 32px;
    flex-wrap: wrap;
    justify-content: center;
    margin-top: 32px;
}

.stat-card {
    background: white;
    padding: 32px 40px;
    border-radius: 24px;
    min-width: 200px;
    box-shadow: 0 10px 30px var(--shadow);
    transition: all 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-10px);
    box-shadow: 0 20px 40px var(--shadow-lg);
}

.stat-number {
    font-size: 3.6rem;
    font-weight: 900;
    color: var(--accent);
}

.stat-label {
    color: var(--text-light);
    font-size: 1.1rem;
    margin-top: 8px;
    font-weight: 600;
}

/* Logout dugme */
.logout-btn-absolute {
    position: absolute;
    top: 30px;
    right: 30px;
    background: rgba(255, 255, 255, 0.25);
    backdrop-filter: blur(10px);
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-radius: 20px;
    padding: 14px;
    cursor: pointer;
    transition: all 0.3s;
    z-index: 100;
}

.logout-btn-absolute:hover {
    background: white;
    transform: translateY(-4px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.logout-btn-absolute img {
    width: 32px;
    height: 32px;
    filter: brightness(0) invert(1);
}

.patient-cases-count {
    font-size: 11px;
    color: #aaa;
    margin-top: 4px;
}

.patient-cases-count small {
    font-weight: normal;
    opacity: 0.8;
}


.review-stars {
    font-size: 20px;
    margin-bottom: 8px;
}

.review-stars .star {
    cursor: pointer;
    color: #444;
    transition: color 0.2s;
}

.review-stars .star.filled {
    color: #f39c12;
}

.review-stars .star:hover {
    color: #e67e22;
}

.review-textarea {
    width: 100%;
    min-height: 60px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid #555;
    border-radius: 6px;
    padding: 8px;
    color: white;
    font-family: inherit;
    resize: vertical;
    margin-bottom: 8px;
}

.btn-save-review {
    background: #3498db;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
}

.btn-save-review:hover {
    background: #2980b9;
}


/* ==================== ANIMACIJE ==================== */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes blink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0;
    }
}

/* ==================== SCROLLBARS ==================== */
::-webkit-scrollbar {
    width: 10px;
}

::-webkit-scrollbar-track {
    background: var(--border-light);
}

::-webkit-scrollbar-thumb {
    background: var(--accent);
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent-hover);
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 1400px) {
    .header {
        padding: 20px;
    }

    #doctor-name {
        font-size: 3.4rem;
    }
}

@media (max-width: 1100px) {
    .app-layout {
        flex-direction: column;
        height: 100vh;
        border-radius: 0;
    }

    .sidebar {
        width: 100%;
        max-height: 40vh;
    }

    .main-content {
        height: 60vh;
    }

    .quick-actions {
        padding: 16px;
        gap: 12px;
    }
}

@media (max-width: 600px) {
    .header {
        flex-direction: column;
        text-align: center;
        gap: 16px;
    }

    .controls {
        justify-content: center;
    }

    .welcome-doctor {
        padding: 20px;
    }

    #doctor-name {
        font-size: 2.8rem;
    }

    .stat-card {
        padding: 20px;
        min-width: 140px;
    }

    .logout-btn-absolute {
        top: 15px;
        right: 15px;
        padding: 10px;
    }
}


/* Lepše formatiranje bot odgovora */
.formatted-bot strong {
    color: #1f67d2;
    font-weight: 600;
}

.formatted-bot .bullet-list,
.formatted-bot .numbered-list {
    margin: 12px 0;
    padding-left: 24px;
}

.formatted-bot .bullet-item,
.formatted-bot .numbered-item {
    margin: 6px 0;
    line-height: 1.5;
}

.note-block,
.important-block,
.diagnosis-block,
.recommendation-block {
    background: #f0f9ff;
    border-left: 4px solid #0ea5e9;
    padding: 10px 14px;
    border-radius: 6px;
    margin: 12px 0;
    font-size: 0.95em;
}

.important-block {
    background: #fff7ed;
    border-color: #f97316;
}

.diagnosis-block {
    background: #fefce8;
    border-color: #ca8a04;
}

.recommendation-block {
    background: #f0fdf4;
    border-color: #22c55e;
}

.message-actions {
    margin-top: 10px;
    display: flex;
    align-items: center;
    gap: 12px;
    opacity: 0;
    transition: opacity 0.2s;
}

.message.bot:hover .message-actions {
    opacity: 1;
}


.action-btn {
    background: transparent;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    padding: 6px 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.action-btn svg {
    width: 18px;
    height: 18px;
    color: #64748b;
    transition: all 0.2s ease;
}

.action-btn:hover {
    background: #f1f5f9;
    border-color: #94a3b8;
    transform: translateY(-1px);
}

.action-btn:hover svg {
    color: #475569;
}

.action-btn.active.like-btn {
    background: #dcfce7;
    border-color: #10b981;
}

.action-btn.active.like-btn svg {
    color: #10b981;
    fill: #10b981;
}

.action-btn.active.dislike-btn {
    background: #fee2e2;
    border-color: #ef4444;
}

.action-btn.active.dislike-btn svg {
    color: #ef4444;
    fill: #ef4444;
}

/* View PDF Button in Chat */
.view-pdf-msg-btn {
    border-color: #fecaca !important;
    background-color: #fff1f2 !important;
    color: #be123c !important;
}

.view-pdf-msg-btn svg {
    color: #be123c !important;
}

.view-pdf-msg-btn:hover {
    background-color: #ffe4e6 !important;
    border-color: #fda4af !important;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(190, 18, 60, 0.15);
}

/* TTS Button Styles */
.tts-btn:hover {
    background: #e0f2fe;
    /* Light blue */
    border-color: #38bdf8;
}

.tts-btn:hover svg {
    color: #0284c7;
}

.tts-btn.playing {
    background: #e0f2fe;
    border-color: #38bdf8;
    color: #0284c7;
    animation: pulse 1.5s infinite;
}

.tts-btn.loading {
    cursor: wait;
    opacity: 0.7;
}

.tts-btn.paused {
    background: #fff7ed;
    /* Light orange for pause */
    border-color: #fdba74;
    color: #c2410c;
    animation: none;
}

.tts-speed-btn {
    font-size: 0.8rem;
    font-weight: 600;
    color: #0d9488;
    background: rgba(13, 148, 136, 0.1);
    border: 1px solid rgba(13, 148, 136, 0.2);
    min-width: 44px;
    padding: 6px 8px;
    /* Override standard padding */
    height: 32px;
    /* Match icon btn height roughly */
}

.tts-speed-btn:hover {
    background: rgba(13, 148, 136, 0.2);
    border-color: rgba(13, 148, 136, 0.4);
}

/* Mic Button */
.mic-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: transparent;
    border: 2px solid var(--border);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s;
    flex-shrink: 0;
}

.mic-btn:hover {
    background-color: #f1f5f9;
    color: #334155;
}

.mic-btn.recording {
    color: #ef4444;
    background-color: #fee2e2;
    animation: pulse-red 1.5s infinite;
}

.mic-btn.processing {
    opacity: 0.7;
    cursor: wait;
    animation: pulse 1s infinite;
}

@keyframes pulse-red {
    0% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(239, 68, 68, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
    }
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(56, 189, 248, 0.4);
    }

    70% {
        box-shadow: 0 0 0 6px rgba(56, 189, 248, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(56, 189, 248, 0);
    }
}

.feedback-status {
    font-size: 0.85em;
    color: #10b981;
    font-weight: 500;
    margin-left: 4px;
}

/* Feedback Modal */
.feedback-modal {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 16px;
    margin-top: 12px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.feedback-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.feedback-header strong {
    color: #0f172a;
    font-size: 0.95em;
}

.close-feedback {
    background: transparent;
    border: none;
    font-size: 24px;
    color: #64748b;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.close-feedback:hover {
    background: #f1f5f9;
    color: #1e293b;
}

.feedback-modal textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 0.9em;
    font-family: inherit;
    resize: vertical;
    transition: border-color 0.2s ease;
}

.feedback-modal textarea:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.feedback-buttons {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 12px;
}

.btn-cancel,
.btn-submit-feedback {
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 0.9em;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
}

.btn-cancel {
    background: #f1f5f9;
    color: #475569;
}

.btn-cancel:hover {
    background: #e2e8f0;
}

.btn-submit-feedback {
    background: #3b82f6;
    color: white;
}

.btn-submit-feedback:hover {
    background: #2563eb;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}

/* Responsive Design */
@media (max-width: 1400px) {
    .left-sidebar {
        width: 380px;
    }

    .right-sidebar {
        width: 450px;
    }
}

@media (max-width: 1200px) {
    .left-sidebar {
        width: 320px;
    }

    .right-sidebar {
        width: 380px;
    }
}

@media (max-width: 1024px) {
    .app-layout {
        flex-direction: column;
        height: 100vh;
        overflow: hidden;
    }

    .sidebar {
        position: fixed;
        inset: 0;
        z-index: 1000;
        width: 100% !important;
        max-width: 100% !important;
        height: calc(100vh - 70px) !important;
        max-height: none !important;
        display: none !important;
        /* Hidden by default on mobile */
    }

    /* Logic to show correct section based on active tab */
    .app-layout.view-patients .left-sidebar {
        display: flex !important;
    }

    .app-layout.view-chat .chat-container {
        display: flex !important;
    }

    .app-layout.view-history .right-sidebar {
        display: flex !important;
    }

    .main-content {
        flex: 1;
        height: calc(100vh - 70px) !important;
        /* Fixed height on mobile to clear nav */
        width: 100%;
        position: relative;
    }

    .patient-selected-view {
        width: 100%;
        height: 100%;
        flex-direction: column;
    }

    .chat-container {
        display: none;
        /* Hidden on mobile unless active */
        height: 100%;
    }

    /* MOBILE NAV BAR STYLES */
    .mobile-nav {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
        height: 70px;
        background: white;
        border-top: 1px solid var(--border);
        box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.05);
        z-index: 2000;
        justify-content: space-around;
        align-items: center;
        padding: 0 10px;
        transition: transform 0.3s ease;
    }

    /* Hide nav when keyboard is likely up or in modal */
    body.modal-open .mobile-nav,
    body.keyboard-visible .mobile-nav {
        transform: translateY(100%);
        pointer-events: none;
    }

    .mobile-nav-btn {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 4px;
        background: transparent;
        border: none;
        color: var(--text-light);
        cursor: pointer;
        padding: 8px 0;
        transition: all 0.2s;
    }

    .mobile-nav-btn svg {
        transition: transform 0.2s;
    }

    .mobile-nav-btn span {
        font-size: 0.75rem;
        font-weight: 600;
    }

    .mobile-nav-btn.active {
        color: var(--accent);
    }

    .mobile-nav-btn.active svg {
        transform: translateY(-2px);
    }
}

/* Hide mobile nav on desktop */
@media (min-width: 1025px) {
    .mobile-nav {
        display: none !important;
    }

    /* Default views on desktop */
    .chat-container {
        display: flex !important;
    }

    .left-sidebar,
    .right-sidebar {
        display: flex !important;
    }
}

@media (max-width: 768px) {
    .chat-header {
        padding: 5px 10px;
        min-height: 70px;
        gap: 8px;
    }

    .header-info-main {
        gap: 8px;
        overflow: hidden;
        min-width: 0;
    }

    .header-doctor-icon {
        width: 38px;
        height: 38px;
        flex-shrink: 0;
    }

    .chat-header h1 {
        font-size: 0.95rem;
        flex-shrink: 1;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .header-consultation-badge {
        font-size: 10px;
        padding: 2px 6px;
        background: rgba(255, 255, 255, 0.2);
        border: 1px solid rgba(255, 255, 255, 0.3);
        max-width: 75px;
        flex-shrink: 0;
    }

    .header-actions {
        gap: 8px;
    }

    .header-star-widget {
        padding: 2px 6px;
    }

    .header-star {
        font-size: 0.9rem;
    }

    .logout-btn-header span {
        display: none;
    }

    .logout-btn-header {
        padding: 6px;
    }

    .app-version-badge {
        display: none;
    }

    .message {
        max-width: 95%;
    }

    .chat-container {
        height: 100%;
        padding-bottom: 25px;
        /* Increased spacing */
    }

    .chat-input-area {
        padding: 12px;
        padding-bottom: 85px;
        /* Significantly increased to avoid bottom nav bar overlap */
        background: white;
    }
}

/* === RECORDING STATE UI === */
.chat-input-area.recording-active {
    background: #f8fafc;
}

.chat-input-area.recording-active #chat-input,
.chat-input-area.recording-active #send-btn {
    display: none;
}

.recording-overlay {
    display: none;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 60px;
    gap: 30px;
    position: relative;
}

.chat-input-area.recording-active .recording-overlay {
    display: flex;
}

.recording-waves {
    position: relative;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.wave {
    position: absolute;
    width: 40px;
    height: 40px;
    background: rgba(13, 148, 136, 0.2);
    border-radius: 50%;
    animation: wave-expand 2s infinite ease-out;
}

.wave:nth-child(2) {
    animation-delay: 0.5s;
}

.wave:nth-child(3) {
    animation-delay: 1s;
}

.recording-mic-icon {
    position: relative;
    z-index: 2;
    background: var(--accent);
    color: white;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(13, 148, 136, 0.3);
    border: none;
}

.recording-status {
    font-weight: 600;
    color: var(--accent);
    animation: blink 1.5s infinite;
}

@keyframes wave-expand {
    0% {
        transform: scale(1);
        opacity: 0.8;
    }

    100% {
        transform: scale(2.5);
        opacity: 0;
    }
}

@keyframes blink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

/* === CHAT ATTACHMENT & POPOVER === */


/* === CHAT HEADER - REFINED === */
.chat-header {
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-hover) 100%);
    padding: 8px 16px;
    border-bottom: 2px solid var(--border-light);
    flex-shrink: 0;
    min-height: 80px;
    display: flex;
    align-items: center;
    position: relative;
    z-index: 10;
}

.chat-header .header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    margin: 0 auto;
    color: white;
    gap: 12px;
}

.header-info-main {
    display: flex;
    align-items: center;
    gap: 16px;
    flex: 1;
    min-width: 0;
}

.header-info-main .logout-btn-header {
    padding: 6px 12px;
    font-size: 0.85rem;
}

.header-info-main .logout-btn-header svg {
    width: 16px;
    height: 16px;
}

.chat-header h1 {
    font-size: 1.3rem;
    font-weight: 700;
    color: white !important;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.header-doctor-icon {
    width: 48px;
    height: 48px;
    opacity: 1;
    filter: brightness(0) invert(1);
    flex-shrink: 0;
    object-fit: contain;
}

.header-consultation-badge {
    background: rgba(255, 255, 255, 0.15);
    color: rgba(255, 255, 255, 0.9);
    padding: 4px 12px;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 600;
    font-family: 'SF Mono', 'Courier New', monospace;
    border: 1.5px solid rgba(255, 255, 255, 0.2);
    white-space: nowrap;
    backdrop-filter: blur(4px);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.header-star-widget {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 24px;
    backdrop-filter: blur(8px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.header-star-widget:hover {
    background: rgba(255, 255, 255, 0.18);
    border-color: rgba(255, 255, 255, 0.4);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
}

.review-status-label {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 2px 8px;
    border-radius: 10px;
}

.review-status-label.status-pending {
    background: rgba(251, 191, 36, 0.2);
    color: #fbbf24;
}

.review-status-label.status-reviewed {
    background: rgba(16, 185, 129, 0.2);
    color: #10b981;
}

.stars-wrapper {
    display: flex;
    gap: 2px;
}

.header-star {
    font-size: 1.1rem;
    color: rgba(255, 255, 255, 0.25);
    transition: all 0.3s ease;
    filter: drop-shadow(0 0 2px rgba(0, 0, 0, 0.1));
}

.header-star.active {
    color: #fbbf24;
    filter: drop-shadow(0 0 5px rgba(251, 191, 36, 0.5));
}

.header-star-widget:hover .header-star {
    transform: scale(1.1);
}

.btn-edit-header-review {
    background: rgba(255, 255, 255, 0.2) !important;
    border: none;
    color: white !important;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    margin-left: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.btn-edit-header-review:hover {
    background: white !important;
    color: var(--accent) !important;
    transform: rotate(15deg) scale(1.1);
    box-shadow: 0 4px 12px rgba(255, 255, 255, 0.3);
}

/* Modal Stars */
.modal-stars {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin: 20px 0;
}

.modal-star {
    font-size: 2.5rem;
    color: #e2e8f0;
    cursor: pointer;
    transition: all 0.2s;
}

.modal-star.active {
    color: #fbbf24;
}

.review-modal-content {
    width: 450px !important;
}

.review-rating-selector p {
    text-align: center;
    font-weight: 600;
    color: var(--text-secondary);
}

.pdf-chat-popover {
    position: fixed;
    z-index: 2000;
    background: white;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-xl);
    padding: 12px;
    width: 220px;
    border: 1px solid var(--border-light);
    animation: fadeIn 0.2s ease-out;
}

.popover-header {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-secondary);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.popover-select {
    width: 100%;
    padding: 8px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    margin-bottom: 12px;
}

.popover-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.popover-cancel,
.popover-submit {
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
}

.popover-cancel {
    background: none;
    border: 1px solid var(--border-light);
    color: var(--text-secondary);
}

.popover-submit {
    background: var(--primary);
    border: none;
    color: white;
}

.attach-btn.processing {
    animation: pulse 1.5s infinite;
    color: var(--primary);
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* === GLOBAL MODALS FIX === */
.modal-backdrop {
    display: none !important;
    /* Force hide by default to override dynamic styles */
}

.modal-backdrop.open {
    display: flex !important;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(8px);
    justify-content: center;
    align-items: center;
    z-index: 3000;
    opacity: 1;
    /* Match .open state */
}

.modal-content {
    background: white;
    width: 500px;
    max-width: 95%;
    max-height: 90vh;
    border-radius: 16px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    display: flex;
    flex-direction: column;
    transform: scale(0.9);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-backdrop.open .modal-content {
    transform: scale(1);
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid #f1f5f9;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid #f1f5f9;
    background: #f8fafc;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    border-bottom-left-radius: 16px;
    border-bottom-right-radius: 16px;
}

/* ==================== FULL SCREEN LOADER ==================== */
.full-screen-loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: fadeInLoader 0.3s ease;
}

.full-screen-loader.active {
    display: flex;
}

.loader-content {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.loader-spinner {
    width: 80px;
    height: 80px;
    border: 5px solid var(--border-light);
    border-top: 5px solid var(--accent);
    border-radius: 50%;
    animation: spin 1s cubic-bezier(0.5, 0.1, 0.4, 0.9) infinite;
    box-shadow: 0 0 30px rgba(13, 148, 136, 0.15);
}

.loader-text {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
    letter-spacing: -0.02em;
}

.loader-subtext {
    font-size: 1rem;
    color: var(--text-secondary);
    max-width: 320px;
    line-height: 1.5;
    margin: 0;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

@keyframes fadeInLoader {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.loader-text {
    animation: pulseText 2s ease-in-out infinite;
}

@keyframes pulseText {

    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.8;
        transform: scale(0.98);
    }
}

/* === STT LANGUAGE TOGGLE === */
.stt-lang-toggle {
    display: flex;
    background: #f1f5f9;
    padding: 3px;
    border-radius: 10px;
    gap: 2px;
    margin-right: 8px;
    border: 1px solid #e2e8f0;
    align-self: center;
}

.lang-btn {
    background: transparent;
    border: none;
    padding: 4px 10px;
    font-size: 0.75rem;
    font-weight: 700;
    color: #64748b;
    border-radius: 7px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.lang-btn.active {
    background: white;
    color: var(--accent);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.lang-btn:hover:not(.active) {
    background: rgba(255, 255, 255, 0.5);
    color: #475569;
}