/* Reset e Configura��es Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    height: 100dvh;
    font-family: 'Inter', sans-serif;
}

body {
    background: #f5f5f5;
    display: flex;
    justify-content: center;
    align-items: center;
}

:root {
    --primary-blue: #1e3a5f;
    --primary-blue-dark: #152a45;
    --accent-blue: #2c5282;
    --accent-light: #e6f2ff;
    --orange: #ff6b35;
    --green: #00a86b;
    --bg-light: #f5f5f5;
    --text-dark: #1e293b;
    --text-light: #64748b;
    --border: #e2e8f0;
}

/* ========== TELA DE LOGIN ========== */
.login-screen {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
    height: 100dvh;
    background: linear-gradient(135deg, var(--primary-blue) 0%, var(--accent-blue) 100%);
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1000;
}

.login-container {
    background: white;
    border-radius: 16px;
    padding: 40px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

.login-header {
    text-align: center;
    margin-bottom: 40px;
}

.login-logo {
    width: 100px;
    height: 100px;
    border-radius: 12px;
    object-fit: contain;
    margin-bottom: 16px;
}

.login-header h1 {
    font-size: 32px;
    font-weight: 600;
    color: var(--text-dark);
    margin: 0;
}

.login-header p {
    font-size: 14px;
    color: var(--text-light);
    margin-top: 8px;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-bottom: 24px;
}

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

.form-group label {
    font-weight: 500;
    color: var(--text-dark);
    font-size: 14px;
}

.form-group input {
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    font-family: 'Inter', sans-serif;
    transition: all 0.3s ease;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 3px rgba(30, 58, 95, 0.1);
}

.form-error {
    font-size: 12px;
    color: #dc2626;
    display: none;
}

.form-error.show {
    display: block;
}

.login-button {
    padding: 12px;
    background: linear-gradient(135deg, var(--primary-blue) 0%, var(--accent-blue) 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.login-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(30, 58, 95, 0.3);
}

.login-button:active {
    transform: translateY(0);
}

.login-footer {
    background: #f9fafb;
    border-radius: 8px;
    padding: 16px;
    text-align: center;
    font-size: 12px;
    color: var(--text-light);
    line-height: 1.6;
}

.login-footer p {
    margin: 4px 0;
}

.login-footer strong {
    color: var(--text-dark);
}

/* ── Link "Esqueci minha senha" ── */
.login-forgot {
    text-align: center;
    margin-top: -8px;
}

.forgot-link {
    background: none;
    border: none;
    color: var(--primary-blue);
    font-size: 13px;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 2px;
    transition: color 0.2s;
    font-family: 'Inter', sans-serif;
}

.forgot-link:hover {
    color: var(--accent-blue);
}

/* ── Modal de Recuperação de Senha ── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(4px);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
}

.modal-box {
    background: white;
    border-radius: 20px;
    padding: 40px 36px 36px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
    position: relative;
    transform: translateY(20px);
    transition: transform 0.3s ease;
    animation: slideUp 0.3s ease forwards;
}

@keyframes slideUp {
    from { transform: translateY(24px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: #f1f5f9;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 18px;
    cursor: pointer;
    color: var(--text-light);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.modal-close:hover {
    background: #fee2e2;
    color: #dc2626;
}

.modal-icon {
    font-size: 40px;
    text-align: center;
    margin-bottom: 12px;
}

.modal-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-dark);
    text-align: center;
    margin: 0 0 8px;
}

.modal-desc {
    font-size: 14px;
    color: var(--text-light);
    text-align: center;
    line-height: 1.6;
    margin: 0 0 24px;
}

.modal-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Mensagens de feedback no modal */
.forgot-message {
    margin-top: 16px;
    font-size: 13px;
    line-height: 1.5;
    text-align: center;
    border-radius: 8px;
    padding: 0;
    min-height: 0;
    transition: all 0.3s;
}

.forgot-message.success {
    color: #166534;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    padding: 12px 16px;
}

.forgot-message.error {
    color: #991b1b;
    background: #fef2f2;
    border: 1px solid #fecaca;
    padding: 12px 16px;
}

/* ========== LAYOUT PRINCIPAL ========== */
.app-container {
    display: flex;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    background: white;
}

/* ========== COLLAPSIBLE SIDEBAR ========== */
.sidebar {
    width: 64px;
    background: var(--primary-blue);
    color: white;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    flex-shrink: 0;
    transition: width 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    z-index: 100;
}

.sidebar:hover {
    width: 280px;
}

/* Header styling */
.sidebar-header {
    padding: 16px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    gap: 12px;
    height: 70px;
    overflow: hidden;
    flex-shrink: 0;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    flex-shrink: 0;
}

.sidebar-logo img {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    object-fit: contain;
}

.sidebar-title {
    opacity: 0;
    transform: translateX(-10px);
    transition: opacity 0.2s ease, transform 0.2s ease;
    white-space: nowrap;
}

.sidebar:hover .sidebar-title {
    opacity: 1;
    transform: translateX(0);
    transition-delay: 0.1s;
}

.sidebar-title h2 {
    font-size: 15px;
    font-weight: 700;
    margin: 0;
    letter-spacing: 0.5px;
}

.sidebar-title p {
    font-size: 9px;
    margin: 2px 0 0 0;
    opacity: 0.8;
}

/* Menu items */
.sidebar-menu {
    padding: 15px 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.menu-section-title {
    padding: 0 16px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1px;
    color: var(--orange);
    margin-bottom: 8px;
    white-space: nowrap;
    opacity: 0;
    transform: translateX(-10px);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.sidebar:hover .menu-section-title {
    opacity: 1;
    transform: translateX(0);
    transition-delay: 0.1s;
}

.sidebar-menu-item {
    width: 100%;
    padding: 12px 20px;
    background: transparent;
    border: none;
    color: white;
    text-align: left;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 13.5px;
    overflow: hidden;
}

.sidebar-menu-item i {
    width: 24px;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.sidebar-menu-item span {
    white-space: nowrap;
    opacity: 0;
    transform: translateX(-10px);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.sidebar:hover .sidebar-menu-item span {
    opacity: 1;
    transform: translateX(0);
}

.sidebar-menu-item:hover {
    background: rgba(255, 255, 255, 0.08);
}

/* Sidebar sections: like ubs info, doctor/medical team */
.sidebar-section {
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    overflow: hidden;
    transition: all 0.3s ease;
    opacity: 0;
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    border-top-color: transparent;
    pointer-events: none;
}

.sidebar:hover .sidebar-section {
    opacity: 1;
    max-height: 200px;
    padding: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    pointer-events: auto;
}

.section-title {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1px;
    color: var(--orange);
    margin-bottom: 10px;
    white-space: nowrap;
}

.ubs-info h3 {
    font-size: 14px;
    font-weight: 600;
    margin: 0 0 4px 0;
    white-space: nowrap;
}

.ubs-address {
    font-size: 11.5px;
    opacity: 0.7;
    margin: 0 0 10px 0;
    line-height: 1.4;
}

.ubs-phone {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #60d5ff;
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
}

.ubs-phone:hover {
    text-decoration: underline;
}

/* Footer Sidebar */
.sidebar-footer {
    margin-top: auto;
    padding: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 16px;
    overflow: hidden;
    flex-shrink: 0;
    height: 60px;
}

.status-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    font-weight: 600;
    flex-shrink: 0;
}

.status-badge.online {
    color: #4ade80;
}

.status-badge i {
    font-size: 8px;
    flex-shrink: 0;
}

.status-badge span {
    opacity: 0;
    width: 0;
    overflow: hidden;
    white-space: nowrap;
    transition: opacity 0.2s ease, width 0.2s ease;
}

.sidebar:hover .status-badge span {
    opacity: 1;
    width: auto;
}

.admin-link {
    display: flex;
    align-items: center;
    gap: 6px;
    color: rgba(255, 255, 255, 0.4);
    text-decoration: none;
    font-size: 12.5px;
    font-weight: 500;
    opacity: 0;
    width: 0;
    overflow: hidden;
    transition: opacity 0.2s ease, width 0.2s ease, color 0.2s ease;
    white-space: nowrap;
}

.sidebar:hover .admin-link {
    opacity: 1;
    width: auto;
}

.admin-link:hover {
    color: #63b3ed;
}

.version {
    font-size: 10px;
    opacity: 0;
    white-space: nowrap;
    margin-left: auto;
    transition: opacity 0.2s ease;
}

.sidebar:hover .version {
    opacity: 0.5;
}

/* ========== MAIN CONTENT ========== */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: white;
    overflow: hidden;
}

/* Top Header */
.top-header {
    height: 70px;
    background: white;
    border-bottom: 2px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    flex-shrink: 0;
}

.menu-toggle {
    display: none;
    background: transparent;
    border: none;
    font-size: 24px;
    color: var(--primary-blue);
    cursor: pointer;
    padding: 8px;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-icon {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    object-fit: contain;
}

.header-text h1 {
    font-size: 18px;
    font-weight: 700;
    color: var(--primary-blue);
    margin: 0;
}

.header-text p {
    font-size: 11px;
    color: var(--green);
    margin: 0;
    font-weight: 600;
}

.header-badge {
    background: var(--primary-blue);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
}

.header-badge i {
    color: #4ade80;
    font-size: 8px;
}

.logout-btn {
    background: transparent;
    color: var(--text-light);
    border: 1px solid var(--border);
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
}

.logout-btn:hover {
    background: #fee;
    color: #dc2626;
    border-color: #fca5a5;
}

.logout-btn i {
    font-size: 14px;
}

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

/* ========== CHAT WRAPPER ========== */
.chat-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #f8f9fa;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Mensagens */
.message {
    display: flex;
    gap: 12px;
    max-width: 85%;
    animation: fadeIn 0.3s ease;
}

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

.message-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    flex-shrink: 0;
    overflow: visible;
    background: var(--primary-blue);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: all 0.3s ease;
}

.clara-message .message-avatar {
    background: #ffffff;
    box-shadow: 
        0 0 0 2px #ffffff,
        0 0 0 4px #0d9488;
}

/* Checkmark Badge do avatar da Clara (verificada) */
.clara-message .message-avatar::after {
    content: '\f00c';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    position: absolute;
    bottom: -4px;
    right: -4px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #0d9488;
    color: #ffffff;
    font-size: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #ffffff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
    z-index: 2;
}

.user-message .message-avatar {
    box-shadow: 
        0 0 0 2px #ffffff,
        0 0 0 4px var(--orange);
}

.message-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.message-avatar i {
    color: #ffffff;
    font-size: 15px;
    z-index: 1;
}

.message-content {
    flex: 1;
}

.message-bubble {
    background: white;
    padding: 16px 20px;
    border-radius: 12px;
    border-left: 4px solid var(--orange);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    line-height: 1.6;
}

.message-bubble p {
    margin: 0 0 8px 0;
    color: var(--text-dark);
    font-size: 14px;
}

.message-bubble p:last-child {
    margin-bottom: 0;
}

.message-bubble strong {
    color: var(--primary-blue);
}

.message-time {
    font-size: 11px;
    color: var(--text-light);
    margin-top: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.user-message {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.user-message .message-bubble {
    background: var(--primary-blue);
    color: white;
    border-left: none;
    border-right: 4px solid var(--orange);
}

.user-message .message-bubble p,
.user-message .message-bubble strong {
    color: white;
}

.user-message .message-content {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

/* Indicador de digitação */
.typing-indicator {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 1px;
    padding: 12px 18px;
    background: white;
    border-radius: 12px;
    border-left: 4px solid var(--orange);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.typing-char {
    display: inline-block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-light);
    animation: typing-char 1.6s infinite ease-in-out;
}

@keyframes typing-char {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.8; }
    30% { transform: translateY(-6px); opacity: 1; color: var(--primary-blue); }
}

/* ========== CHAT FOOTER ========== */
.chat-footer {
    background: white;
    border-top: 2px solid var(--border);
    padding: 16px 24px;
    flex-shrink: 0;
}

.expandable-tabs {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 6px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.02);
    margin-bottom: 16px;
    justify-content: center;
}

.tab-item {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0;
    padding: 8px 12px;
    background: transparent;
    border: none;
    border-radius: 12px;
    color: var(--text-light);
    font-size: 13.5px;
    font-weight: 500;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
    overflow: hidden;
}

.tab-item i {
    font-size: 15px;
    flex-shrink: 0;
    transition: color 0.3s;
}

.tab-title {
    max-width: 0;
    opacity: 0;
    white-space: nowrap;
    transition: max-width 0.4s cubic-bezier(0.25, 0.8, 0.25, 1), opacity 0.3s ease, margin-left 0.4s ease;
    display: inline-block;
}

/* Hover para abas não selecionadas */
.tab-item:hover {
    background: #f1f5f9;
    color: var(--text-dark);
}

/* Estado de Aba Selecionada (Expandida) */
.tab-item.selected {
    gap: 8px;
    background: #e2e8f0;
    color: var(--primary-blue);
    padding-left: 14px;
    padding-right: 14px;
}

.tab-item.selected .tab-title {
    max-width: 120px;
    opacity: 1;
    margin-left: 4px;
}

.tab-separator {
    width: 1px;
    height: 18px;
    background: var(--border);
    margin: 0 4px;
}

.ai-input-container {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
}

.input-area {
    position: relative;
    display: flex;
    width: 100%;
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 28px;
    overflow: hidden;
    transition: all 0.25s ease;
}

.input-area:focus-within {
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 3px rgba(30, 58, 95, 0.15);
    background: #ffffff;
}

#messageInput {
    flex: 1;
    min-height: 56px;
    max-height: 200px;
    padding: 18px 60px 18px 24px;
    border: none;
    background: transparent;
    color: var(--text-dark);
    font-size: 14.5px;
    font-family: 'Inter', sans-serif;
    line-height: 1.4;
    resize: none;
    outline: none;
    box-shadow: none !important;
}

#messageInput::placeholder {
    color: var(--text-light);
}

.send-button {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%) !important;
    width: 36px;
    height: 36px;
    border: none;
    background: rgba(0, 0, 0, 0.05);
    color: var(--text-dark);
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.send-button:hover:not(:disabled) {
    background: rgba(0, 0, 0, 0.1);
    transform: translateY(-50%) scale(1.05) !important;
}

.send-button:disabled {
    background: transparent !important;
    cursor: not-allowed;
}

/* Spinner Loader (Bloco quadrado giratório - design do prompt) */
.spinner-loader {
    width: 16px;
    height: 16px;
    background: var(--text-dark);
    border-radius: 3px;
    animation: spinSquare 3s infinite linear;
}

@keyframes spinSquare {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.ai-input-status {
    padding-left: 20px;
    height: 16px;
    font-size: 11px;
    color: var(--text-light);
    margin: 0;
    transition: color 0.2s ease;
    text-align: left;
}

.send-button:active {
    transform: scale(0.95);
}

.send-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.footer-text {
    text-align: center;
    font-size: 11px;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ========== RESPONSIVIDADE ========== */
@media (max-width: 1024px) {
    .sidebar {
        position: fixed;
        left: -280px;
        top: 0;
        height: 100vh;
        z-index: 1000;
        width: 280px;
        transition: left 0.3s ease;
    }

    .sidebar.active {
        left: 0;
    }

    /* Overlay escuro atrás da sidebar aberta */
    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.4);
        z-index: 999;
        backdrop-filter: blur(2px);
    }

    .sidebar-overlay.active {
        display: block;
    }

    /* Forçar a exibição do conteúdo expandido da sidebar no mobile */
    .sidebar.active .sidebar-title,
    .sidebar.active .menu-section-title,
    .sidebar.active .sidebar-menu-item span,
    .sidebar.active .status-badge span,
    .sidebar.active .admin-link,
    .sidebar.active .version {
        opacity: 1;
        transform: translateX(0);
        width: auto;
    }

    .sidebar.active .sidebar-section {
        opacity: 1;
        max-height: 200px;
        padding: 16px;
        border-top: 1px solid rgba(255, 255, 255, 0.1);
        pointer-events: auto;
    }

    .menu-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
        min-width: 44px;
        min-height: 44px;
    }

    .expandable-tabs {
        overflow-x: auto;
        flex-wrap: nowrap;
        justify-content: flex-start;
        padding: 4px;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }

    .expandable-tabs::-webkit-scrollbar {
        display: none;
    }

    .tab-item {
        white-space: nowrap;
        padding: 10px 14px;
        font-size: 13px;
        min-height: 44px;
        /* Mostrar labels no mobile */
        gap: 6px;
    }

    .tab-item .tab-title {
        max-width: 72px;
        opacity: 1;
        margin-left: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
}

/* Telas pequenas: só ícones nas tabs */
@media (max-width: 480px) {
    .tab-item .tab-title {
        display: none;
    }
    .tab-item {
        flex: 1;
        justify-content: center;
        padding: 10px 8px;
    }
    .tab-item i {
        font-size: 17px;
    }
    .expandable-tabs {
        justify-content: space-around;
    }
    .tab-separator { display: none; }
}

@media (max-width: 768px) {
    /* ── Header ── */
    .top-header {
        padding: 0 12px;
        height: 60px;
    }

    .header-brand {
        gap: 8px;
    }

    .header-icon {
        width: 34px;
        height: 34px;
    }

    .header-text h1 {
        font-size: 15px;
    }

    .header-text p {
        font-size: 9px;
    }

    /* Ocultar badge PET-SAÚDE DIGITAL no mobile — ocupa muito espaço */
    .header-badge {
        display: none;
    }

    .logout-btn span {
        display: none;
    }

    .logout-btn {
        padding: 10px;
        min-width: 44px;
        min-height: 44px;
        border-radius: 50%;
        justify-content: center;
    }

    .header-actions {
        gap: 8px;
    }

    /* ── Mensagens ── */
    .chat-messages {
        padding: 12px;
        gap: 16px;
    }

    .message {
        max-width: 98%;
        gap: 8px;
    }

    .message-avatar {
        width: 34px;
        height: 34px;
        flex-shrink: 0;
    }

    .message-bubble {
        padding: 12px 16px;
        font-size: 13.5px;
    }

    .message-bubble p {
        font-size: 13.5px;
    }

    /* ── Footer / Input ── */
    .chat-footer {
        padding: 10px 12px;
        /* Safe area para iOS (barra home) */
        padding-bottom: max(10px, env(safe-area-inset-bottom));
    }

    /* Evita zoom automático no iOS ao focar no input */
    #messageInput {
        font-size: 16px;
        padding: 14px 56px 14px 18px;
        min-height: 50px;
    }

    .send-button {
        width: 38px;
        height: 38px;
        right: 8px;
    }

    .ai-input-status {
        font-size: 10px;
        padding-left: 14px;
    }

    .footer-text {
        font-size: 10px;
        letter-spacing: 0.3px;
        margin-top: 4px;
    }

    /* ── Login ── */
    .login-container {
        max-width: 100%;
        border-radius: 20px 20px 0 0;
        padding: 32px 24px;
        /* Posiciona o card na parte inferior da tela */
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        margin: 0;
        padding-bottom: max(32px, env(safe-area-inset-bottom));
        box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.15);
    }

    .login-screen {
        align-items: flex-end;
    }

    .login-header {
        margin-bottom: 28px;
    }

    .login-logo {
        width: 72px;
        height: 72px;
    }

    .login-header h1 {
        font-size: 26px;
    }

    .login-form {
        gap: 16px;
        margin-bottom: 16px;
    }

    /* Evita zoom no iOS ao focar nos inputs do login */
    .form-group input {
        font-size: 16px;
        padding: 14px;
        min-height: 50px;
        border-radius: 12px;
    }

    .login-button {
        min-height: 50px;
        font-size: 15px;
        border-radius: 12px;
    }

    .login-footer {
        font-size: 11px;
        padding: 12px;
    }
}

/* Telas muito pequenas (< 380px - ex: iPhone SE) */
@media (max-width: 380px) {
    .header-text h1 {
        font-size: 13px;
    }

    .header-text p {
        display: none;
    }

    .message-bubble {
        padding: 10px 14px;
    }

    .tab-item .tab-title {
        display: none;
    }

    .tab-item {
        padding: 10px 12px;
    }
}

/* Safe area para iOS com notch (topo) */
@supports (padding-top: env(safe-area-inset-top)) {
    .top-header {
        padding-top: env(safe-area-inset-top);
    }

    .sidebar {
        padding-top: env(safe-area-inset-top);
    }
}

/* ========== LOADING OVERLAY ========== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    flex-direction: column;
    gap: 20px;
}

.loading-overlay.show {
    display: flex;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(56, 189, 248, 0.2);
    border-top-color: #38bdf8;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-overlay p {
    color: white;
    font-size: 16px;
    font-weight: 500;
}

/* ========== CUSTOM INVENTORY TABLE STYLE ========== */
.inventory-table-container::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

.inventory-table-container::-webkit-scrollbar-track {
    background: transparent;
}

.inventory-table-container::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 9999px;
}

.inventory-table-container::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

.inventory-table tr {
    transition: background-color 0.15s ease;
}

.inventory-table tr:hover {
    background-color: #f8fafc;
}

.legend-card:hover {
    background-color: #f8fafc !important;
    border-color: #cbd5e1 !important;
    transform: translateY(-1px);
}

/* ─────────────────────────────────────────────────────────────
   CARD CLÍNICO PCDT & MEDICAMENTOS (PADRÃO EQUIPE MÉDICA)
   ───────────────────────────────────────────────────────────── */
.clinical-card {
    background: #0f172a;
    color: #e2e8f0;
    border-radius: 12px;
    padding: 20px 22px;
    font-family: inherit;
    font-size: 13.5px;
    line-height: 1.6;
    border: 1px solid #1e293b;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    margin: 4px 0;
    max-width: 680px;
}

.clinical-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid #1e293b;
}

.clinical-title-box {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.clinical-title {
    margin: 0;
    font-size: 20px;
    font-weight: 700;
    color: #ffffff;
    letter-spacing: -0.3px;
}

.clinical-subtitle {
    font-size: 12px;
    color: #94a3b8;
    font-weight: 500;
}

.clinical-section {
    margin-bottom: 14px;
}

.clinical-section h4 {
    margin: 0 0 8px 0;
    font-size: 14px;
    font-weight: 600;
    color: #f8fafc;
    letter-spacing: -0.2px;
}

.clinical-section p {
    margin: 0;
    font-size: 13.5px;
    color: #cbd5e1;
    line-height: 1.6;
}

.clinical-section ul {
    margin: 0;
    padding-left: 18px;
    color: #cbd5e1;
    list-style-type: disc;
}

.clinical-section ul li {
    margin-bottom: 4px;
}

.clinical-section ul li strong {
    color: #f1f5f9;
    font-weight: 600;
}

.clinical-divider {
    height: 1px;
    background: #1e293b;
    margin: 14px 0;
}

.clinical-alert-box {
    background: #1c1113;
    border: 1px solid #7f1d1d;
    border-left: 4px solid #ef4444;
    border-radius: 8px;
    padding: 12px 16px;
    margin: 16px 0 12px 0;
}

.clinical-alert-title {
    font-size: 13.5px;
    font-weight: 700;
    color: #f87171;
    margin-bottom: 6px;
}

.clinical-alert-box ul {
    margin: 0;
    padding-left: 16px;
    color: #fca5a5;
    font-size: 13px;
    list-style-type: disc;
}

.clinical-alert-box ul li {
    margin-bottom: 4px;
}

.clinical-footer {
    font-size: 11px;
    color: #64748b;
    margin-top: 14px;
    padding-top: 10px;
    border-top: 1px solid #1e293b;
    line-height: 1.5;
}


