/* ==========================================================================
   CLYVO VET — DESIGN SYSTEM MODERNO COM DARK/LIGHT THEME & AURORA BOREAL
   Todas as telas usam as classes abaixo (sem estilos inline nos templates).
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=Inter:wght@400;500;600;700&display=swap');

/* --- VARIÁVEIS DO TEMA: LIGHT (PADRÃO) --- */
:root {
    --bg-page: #f4f6fb;
    --bg-page-gradient: radial-gradient(circle at 15% 15%, rgba(0, 242, 254, 0.05) 0%, transparent 40%),
                        radial-gradient(circle at 85% 85%, rgba(127, 0, 255, 0.04) 0%, transparent 40%);
    --bg-surface: #ffffff;
    --bg-surface-elevated: #ffffff;
    --bg-surface-alt: #f8fafc;
    --bg-input: #ffffff;

    --border-subtle: #e2e8f0;
    --border-focus: #00d9f5;

    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #64748b;

    --accent: #00b3cc;
    --link: #0284c7;
    --link-hover: #0369a1;

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 12px -2px rgba(15, 23, 42, 0.08);
    --shadow-lg: 0 12px 28px -4px rgba(15, 23, 42, 0.12);

    /* Cores de Status */
    --status-agendado-bg: rgba(59, 130, 246, 0.1);
    --status-agendado-text: #2563eb;
    --status-concluida-bg: rgba(16, 185, 129, 0.1);
    --status-concluida-text: #047857;
    --status-cancelada-bg: rgba(239, 68, 68, 0.1);
    --status-cancelada-text: #dc2626;

    --danger: #dc2626;
    --danger-bg: rgba(239, 68, 68, 0.08);

    /* Gradiente da Aurora Boreal */
    --aurora-gradient: linear-gradient(135deg, #00f5a0 0%, #00d9f5 25%, #4facfe 50%, #7f00ff 75%, #00f5a0 100%);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 18px;
    --radius-pill: 9999px;

    --transition-fast: 0.18s ease;
    --transition-normal: 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- VARIÁVEIS DO TEMA: DARK THEME --- */
[data-theme="dark"] {
    --bg-page: #0b0f19;
    --bg-page-gradient: radial-gradient(circle at 10% 20%, rgba(0, 245, 160, 0.08) 0%, transparent 40%),
                        radial-gradient(circle at 90% 80%, rgba(127, 0, 255, 0.09) 0%, transparent 45%);
    --bg-surface: #131b2e;
    --bg-surface-elevated: #1a243d;
    --bg-surface-alt: #101626;
    --bg-input: #172036;

    --border-subtle: #243049;
    --border-focus: #00f5a0;

    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #8391a7;

    --accent: #00f5a0;
    --link: #38bdf8;
    --link-hover: #7dd3fc;

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 6px 18px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 14px 35px rgba(0, 0, 0, 0.55);

    --status-agendado-bg: rgba(59, 130, 246, 0.18);
    --status-agendado-text: #60a5fa;
    --status-concluida-bg: rgba(16, 185, 129, 0.18);
    --status-concluida-text: #34d399;
    --status-cancelada-bg: rgba(239, 68, 68, 0.18);
    --status-cancelada-text: #f87171;

    --danger: #f87171;
    --danger-bg: rgba(239, 68, 68, 0.12);
}

/* --- RESET & BASE --- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Plus Jakarta Sans', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg-page);
    background-image: var(--bg-page-gradient);
    background-attachment: fixed;
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
    transition: background-color var(--transition-normal), color var(--transition-fast);
}

h1, h2, h3, h4 {
    color: var(--text-primary);
    font-weight: 700;
    letter-spacing: -0.4px;
}

p { color: var(--text-secondary); font-size: 14px; line-height: 1.5; }

a {
    color: var(--link);
    text-decoration: none;
    font-weight: 600;
}

a:hover { color: var(--link-hover); text-decoration: underline; }

:focus-visible {
    outline: 3px solid var(--border-focus);
    outline-offset: 2px;
}

@keyframes aurora-flow {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

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

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ==========================================================================
   LAYOUT: CABEÇALHO, PÁGINA E RODAPÉ
   ========================================================================== */
.main-header {
    width: 100%;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-subtle);
    padding: 14px 16px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-sm);
}

.header-inner {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
}

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

.brand:hover { text-decoration: none; }

.brand-icon {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: var(--aurora-gradient);
    background-size: 250% 250%;
    animation: aurora-flow 6s ease infinite;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    box-shadow: 0 4px 14px rgba(0, 245, 160, 0.35);
}

.brand-title {
    font-size: 20px;
    font-weight: 800;
    line-height: 1.2;
    background: var(--aurora-gradient);
    background-size: 200% auto;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.brand-tagline {
    display: block;
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

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

.lang-switch {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
}

.lang-switch a {
    color: var(--text-secondary);
    padding: 4px 8px;
    border-radius: 6px;
    border: 1px solid var(--border-subtle);
}

.lang-switch a.active {
    color: var(--text-primary);
    border-color: var(--border-focus);
}

.lang-switch a:hover { text-decoration: none; border-color: var(--border-focus); }

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    color: var(--text-secondary);
}

.page {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 16px 20px;
    flex: 1;
}

.page--narrow { max-width: 960px; }

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

.page-title {
    font-size: 26px;
    font-weight: 800;
    margin-bottom: 4px;
}

.page-subtitle { font-size: 15px; }

.info-chip {
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 10px 18px;
    font-size: 13px;
    color: var(--text-secondary);
}

.main-footer {
    text-align: center;
    padding: 28px 16px;
    margin-top: 48px;
    border-top: 1px solid var(--border-subtle);
    color: var(--text-muted);
    font-size: 13px;
}

.main-footer p { color: inherit; font-size: inherit; }
.main-footer .footer-stack { font-size: 12px; margin-top: 6px; }

/* ==========================================================================
   GRIDS E SEÇÕES
   ========================================================================== */
.grid-forms {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr));
    gap: 24px;
    margin-bottom: 32px;
}

.grid-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr));
    gap: 16px;
}

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

.card {
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    position: relative;
}

.card--alt {
    background: var(--bg-surface-alt);
    padding: 16px;
}

.section { margin-bottom: 32px; }

.section-title {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.section-title + .section-desc { margin-top: -8px; }

.section-desc {
    font-size: 13px;
    margin-bottom: 16px;
}

.empty-state {
    color: var(--text-muted);
    font-size: 14px;
    text-align: center;
    padding: 24px;
}

.detail {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.detail strong { color: var(--text-primary); }

.item-title {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 6px;
}

.item-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 8px;
}

/* ==========================================================================
   FORMULÁRIOS
   ========================================================================== */
.form-group { margin-bottom: 16px; }

.form-label {
    display: block;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
    letter-spacing: 0.2px;
}

.form-input {
    width: 100%;
    padding: 12px 15px;
    background: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 14px;
    outline: none;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-input:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3.5px rgba(0, 217, 245, 0.22);
}

select.form-input { cursor: pointer; }
textarea.form-input { resize: vertical; min-height: 70px; }

.form-input--sm { padding: 9px 12px; font-size: 13px; }

/* ==========================================================================
   BOTÕES
   ========================================================================== */
.btn-aurora {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    border: none;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 14.5px;
    font-weight: 700;
    color: #ffffff;
    cursor: pointer;
    background: var(--aurora-gradient);
    background-size: 250% 250%;
    animation: aurora-flow 6s ease infinite;
    box-shadow: 0 4px 14px rgba(0, 245, 160, 0.25);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
    transition: transform 0.2s ease, box-shadow 0.25s ease;
}

.btn-aurora:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 245, 160, 0.4);
}

.btn-aurora:active { transform: translateY(0.5px) scale(0.985); }

/* Ação destrutiva: visualmente distinta da ação principal */
.btn-cancel {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 12px;
    border: 1px solid var(--danger);
    border-radius: var(--radius-sm);
    background: var(--danger-bg);
    color: var(--danger);
    font-family: inherit;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: background-color var(--transition-fast), color var(--transition-fast);
}

.btn-cancel:hover {
    background: var(--danger);
    color: #ffffff;
    text-decoration: none;
}

.btn-block { width: 100%; margin-top: 8px; }
.btn-compact { padding: 8px 18px; font-size: 13px; }

.actions-end {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.inline-form { display: inline; }

/* Alternador de Tema (Sun / Moon) */
.theme-toggle {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-pill);
    background: var(--bg-surface-alt);
    border: 1px solid var(--border-subtle);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 18px;
    transition: transform var(--transition-fast), border-color var(--transition-fast);
}

.theme-toggle:hover {
    transform: rotate(20deg) scale(1.08);
    border-color: var(--border-focus);
}

/* ==========================================================================
   ALERTAS
   ========================================================================== */
.alert {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 18px;
    border-radius: var(--radius-md);
    margin-bottom: 20px;
    font-size: 14px;
    font-weight: 500;
    animation: fadeIn 0.3s ease;
}

.alert--success {
    background: rgba(16, 185, 129, 0.12);
    color: var(--status-concluida-text);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.alert--error {
    background: rgba(239, 68, 68, 0.12);
    color: var(--status-cancelada-text);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

/* ==========================================================================
   NOTIFICAÇÕES
   ========================================================================== */
.notif-link {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-pill);
    background: var(--bg-surface);
    font-size: 16px;
    transition: border-color var(--transition-fast);
}

.notif-link:hover { text-decoration: none; border-color: var(--border-focus); }

.notif-count {
    position: absolute;
    top: -6px;
    right: -6px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: var(--radius-pill);
    background: var(--danger);
    color: #ffffff;
    font-size: 11px;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
}

.notif-list { list-style: none; padding: 0; margin: 0; }
.notif-item { padding: 14px 18px; }
.notif-item:not(.notif-item--unread) { border-left-color: var(--border-subtle); }
.notif-item--unread .notif-message { font-weight: 600; }
.notif-message { margin-top: 6px; color: var(--text-primary); }

/* ==========================================================================
   STATUS
   ========================================================================== */
.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: var(--radius-pill);
    font-size: 11.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
    background: var(--status-agendado-bg);
    color: var(--status-agendado-text);
}

.status-concluida, .status-ativa, .status-ativo {
    background: var(--status-concluida-bg);
    color: var(--status-concluida-text);
}

.status-cancelada, .status-revogada, .status-expirada, .status-inativo {
    background: var(--status-cancelada-bg);
    color: var(--status-cancelada-text);
}

/* ==========================================================================
   TABELAS
   ========================================================================== */
.table-wrap { overflow-x: auto; }

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    text-align: left;
}

.data-table th {
    padding: 12px 8px;
    border-bottom: 2px solid var(--border-subtle);
    color: var(--text-secondary);
    white-space: nowrap;
}

.data-table td {
    padding: 12px 8px;
    border-bottom: 1px solid var(--border-subtle);
}

.data-table td.cell-strong { font-weight: 600; }
.data-table .text-right { text-align: right; }

/* ==========================================================================
   PRONTUÁRIOS E CONSULTAS
   ========================================================================== */
.record {
    background: var(--bg-surface-alt);
    border: 1px solid var(--border-subtle);
    border-left: 4px solid var(--accent);
    border-radius: var(--radius-md);
    padding: 20px;
}

.record--pending { border-left-color: var(--border-focus); }

.record-meta {
    font-size: 13px;
    color: var(--text-secondary);
    margin-left: 8px;
}

.record-body {
    background: var(--bg-surface);
    padding: 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-subtle);
    font-size: 14px;
    line-height: 1.5;
    white-space: pre-line;
}

.meta-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr));
    gap: 12px;
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.clinical-form {
    background: var(--bg-surface);
    padding: 16px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
    margin-top: 12px;
}

.clinical-form h3 {
    font-size: 14px;
    margin-bottom: 12px;
}

.clinical-form .form-group { margin-bottom: 10px; }
.clinical-form .btn-cancel { margin-top: 10px; }

/* Assistente de IA da consulta */
.ai-panel {
    background: var(--bg-surface-alt);
    border: 1px dashed var(--border-focus);
    border-radius: var(--radius-md);
    padding: 14px;
    margin-bottom: 16px;
}
.ai-panel-header { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 14px; }
.ai-live { color: var(--danger); font-size: 12px; font-weight: 600; animation: ai-pulse 1.2s ease-in-out infinite; }
@keyframes ai-pulse { 50% { opacity: 0.35; } }
@media (prefers-reduced-motion: reduce) { .ai-live { animation: none; } }
.ai-hint { font-size: 12px; color: var(--text-muted); margin: 6px 0 10px; }
.ai-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.btn-ai {
    padding: 8px 14px;
    font-size: 13px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
    background: var(--bg-surface);
    color: var(--text-primary);
    cursor: pointer;
}
.btn-ai:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-ai--primary { background: var(--aurora-gradient); border-color: transparent; color: #0f172a; font-weight: 600; }
.ai-transcript { resize: vertical; }
.ai-interim { font-size: 13px; color: var(--text-muted); font-style: italic; min-height: 1em; margin: 4px 0 0; }
.ai-status { font-size: 12px; color: var(--text-secondary); margin: 4px 0 0; }
.ai-result { font-size: 13px; color: var(--text-secondary); margin-top: 10px; display: grid; gap: 6px; }
.ai-result ul { margin: 4px 0 0 18px; }
/* O display das classes acima não pode reexibir o que o JS escondeu com o atributo hidden */
.ai-panel [hidden] { display: none; }
.ai-source { color: var(--text-muted); }
.ai-filled { border-color: var(--border-focus); box-shadow: 0 0 0 2px rgba(0, 217, 245, 0.15); }

/* ==========================================================================
   LOGIN E CADASTRO
   ========================================================================== */
.auth-title { font-size: 24px; margin-bottom: 6px; }
.auth-subtitle { margin-bottom: 24px; }

.divider {
    display: flex;
    align-items: center;
    margin: 20px 0 16px;
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
}

.divider::before, .divider::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid var(--border-subtle);
}

.divider span { padding: 0 12px; }

.oauth-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.oauth-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 10px 16px;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    background: var(--bg-surface-elevated);
    color: var(--text-primary);
    font-size: 14px;
}

.oauth-btn:hover { text-decoration: none; border-color: var(--border-focus); }

.oauth-btn--github {
    background: #24292e;
    color: #ffffff;
}

.demo-box {
    margin-top: 14px;
    padding: 10px;
    background: var(--bg-surface-alt);
    border-radius: var(--radius-sm);
    border: 1px dashed var(--border-subtle);
    text-align: center;
    font-size: 12px;
    color: var(--text-muted);
}

.demo-box strong {
    display: block;
    margin-bottom: 6px;
    color: var(--text-secondary);
}

.demo-links {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
}

.demo-links a:hover { text-decoration: none; }

.api-note {
    margin-top: 20px;
    padding-top: 14px;
    border-top: 1px dashed var(--border-subtle);
    font-size: 13px;
    color: var(--text-muted);
    text-align: center;
}

/* ==========================================================================
   RESPONSIVIDADE
   ========================================================================== */
@media (max-width: 640px) {
    .page-title { font-size: 22px; }
    .card { padding: 18px; }
    .header-inner { justify-content: center; }
    .user-info { flex-wrap: wrap; justify-content: center; }
}

/* Barra de rolagem personalizada */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg-surface-alt); }
::-webkit-scrollbar-thumb { background: var(--border-subtle); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-focus); }
