/* ═══════════════════════════════════════════════════════════════
   global.css — Hospital Clean Design System
   Palette: Indigo-600 brand · Slate text hierarchy
   ═══════════════════════════════════════════════════════════════ */

/* ─── Imports ─────────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&display=swap');

/* ─── Root Variables ──────────────────────────────────────────── */
:root {
    --brand: #4f46e5;           /* Indigo-600 */
    --brand-light: #818cf8;     /* Indigo-400 */
    --brand-dark: #3730a3;      /* Indigo-800 */
    --surface: #ffffff;
    --surface-alt: #f8fafc;     /* Slate-50 */
    --border: #e2e8f0;          /* Slate-200 */
    --border-light: #f1f5f9;    /* Slate-100 */
    --text-primary: #0f172a;    /* Slate-900 */
    --text-secondary: #475569;  /* Slate-600 */
    --text-muted: #94a3b8;      /* Slate-400 */
    --success: #059669;         /* Emerald-600 */
    --warning: #d97706;         /* Amber-600 */
    --danger: #dc2626;          /* Red-600 */
    --info: #0284c7;            /* Sky-600 */
    --glass-bg: rgba(255,255,255,0.72);
    --glass-border: rgba(255,255,255,0.3);
    --sidebar-width: 240px;
    --sidebar-collapsed: 64px;
    --header-height: 56px;
}

/* ─── Modal Scroll Lock ──────────────────────────────────────── */
body.modal-open { overflow: hidden; }

/* ─── Base ────────────────────────────────────────────────────── */
* { box-sizing: border-box; }

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    color: var(--text-primary);
    background: var(--surface-alt);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    /* Optimize for low-res hospital screens */
    text-rendering: optimizeLegibility;
    font-size: 14px;
    line-height: 1.5;
}

/* ─── View System ─────────────────────────────────────────────── */
.view { display: none; }
.view.active { display: block; }

/* ─── Typography for Low-Res Screens ──────────────────────────── */
h1, h2, h3, h4 {
    letter-spacing: -0.01em;
    font-weight: 700;
}

/* Minimum text size to ensure readability on low-DPI monitors */
@media (max-resolution: 96dpi) {
    body { font-size: 15px; }
    .text-xs { font-size: 0.8rem !important; }
    .text-\\[10px\\] { font-size: 0.75rem !important; }
    .text-\\[11px\\] { font-size: 0.8rem !important; }
}

th, td { padding: 10px 14px; text-align: left; }

/* ─── Patient Called Pulse (softer) ───────────────────────────── */
@keyframes pulse-soft {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(79, 70, 229, 0.5);
    }
    50% {
        transform: scale(1.02);
        box-shadow: 0 0 12px 4px rgba(79, 70, 229, 0);
    }
}
.patient-called { animation: pulse-soft 2.5s infinite ease-in-out; }

/* ─── Anti-Burn-In (1px / 10 minutes) ─────────────────────────── */
@keyframes pixel-drift {
    0%   { transform: translate(0, 0); }
    25%  { transform: translate(1px, 0); }
    50%  { transform: translate(1px, 1px); }
    75%  { transform: translate(0, 1px); }
    100% { transform: translate(0, 0); }
}

.anti-burn-in {
    animation: pixel-drift 600s infinite linear; /* 10min cycle */
    will-change: transform;
    background-color: var(--surface-alt);
}

/* ─── Glassmorphism ───────────────────────────────────────────── */
.glass-modal {
    background: var(--glass-bg);
    backdrop-filter: blur(16px) saturate(180%);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
    border: 1px solid var(--glass-border);
    box-shadow:
        0 8px 32px rgba(15, 23, 42, 0.08),
        0 2px 8px rgba(15, 23, 42, 0.04);
}

.glass-card {
    background: rgba(255, 255, 255, 0.65);
    backdrop-filter: blur(12px) saturate(160%);
    -webkit-backdrop-filter: blur(12px) saturate(160%);
    border: 1px solid rgba(226, 232, 240, 0.6);
    box-shadow: 0 4px 16px rgba(15, 23, 42, 0.05);
}

.glass-sidebar {
    background: rgba(15, 23, 42, 0.92);
    backdrop-filter: blur(20px) saturate(200%);
    -webkit-backdrop-filter: blur(20px) saturate(200%);
}

/* ─── Teleprompter ────────────────────────────────────────────── */
.teleprompter-container {
    overflow: hidden;
    width: 100%;
    background: linear-gradient(135deg, #0f172a, #1e293b);
    color: white;
    padding: 1rem;
    border-radius: 0.75rem;
}
.teleprompter-text {
    white-space: nowrap;
    display: inline-block;
    animation: scroll-left 15s linear infinite;
}
@keyframes scroll-left {
    0%   { transform: translateX(100%); }
    100% { transform: translateX(-100%); }
}

/* ─── Search Results ──────────────────────────────────────────── */
.search-results-list li { cursor: pointer; transition: background-color 0.15s; }
.search-results-list li:hover { background-color: #f1f5f9; }

/* ─── Custom Scrollbar ────────────────────────────────────────── */
.custom-scrollbar::-webkit-scrollbar { width: 5px; }
.custom-scrollbar::-webkit-scrollbar-track { background: transparent; }
.custom-scrollbar::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 10px;
}
.custom-scrollbar::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* Firefox */
.custom-scrollbar {
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 transparent;
}

/* ─── Quill Editor (Atestados) ───────────────────────────────── */
#cert-quill-editor {
    display: flex;
    flex-direction: column;
}
#cert-quill-editor .ql-toolbar {
    border-radius: 8px 8px 0 0;
    border-color: #e2e8f0;
    background: #f8fafc;
    flex-shrink: 0;
}
#cert-quill-editor .ql-container {
    border-radius: 0 0 8px 8px;
    border-color: #e2e8f0;
    font-size: 0.875rem;
    line-height: 1.7;
    flex: 1;
    overflow-y: auto;
}
#cert-quill-editor .ql-editor {
    min-height: 260px;
    color: #1e293b;
}
#cert-quill-editor .ql-editor.ql-blank::before {
    color: #94a3b8;
    font-style: italic;
}

/* ─── Sidebar Navigation ─────────────────────────────────────── */
.app-sidebar {
    width: var(--sidebar-width);
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.app-sidebar.collapsed {
    width: var(--sidebar-collapsed);
}
.app-sidebar .nav-label {
    opacity: 1;
    transition: opacity 0.2s ease;
    white-space: nowrap;
    overflow: hidden;
}
.app-sidebar.collapsed .nav-label {
    opacity: 0;
    width: 0;
    pointer-events: none;
}

.sidebar-nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    border-radius: 10px;
    color: rgba(255, 255, 255, 0.6);
    font-weight: 600;
    font-size: 13px;
    transition: all 0.2s ease;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}
.sidebar-nav-item:hover {
    color: rgba(255, 255, 255, 0.9);
    background: rgba(255, 255, 255, 0.08);
}
.sidebar-nav-item.active {
    color: #fff;
    background: rgba(79, 70, 229, 0.5);
    box-shadow: 0 0 12px rgba(79, 70, 229, 0.3);
}
.sidebar-nav-item .nav-icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    flex-shrink: 0;
    font-size: 16px;
}

/* ─── Mobile Bottom Navigation ────────────────────────────────── */
@media (max-width: 1023px) {
    .app-sidebar { display: none !important; }
    .mobile-bottom-nav {
        display: flex !important;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 50;
        background: linear-gradient(to top, #0f172a, rgba(15, 23, 42, 0.97));
        backdrop-filter: blur(12px);
        border-top: 1px solid rgba(255,255,255,0.1);
        padding: 4px 8px;
        padding-bottom: env(safe-area-inset-bottom, 4px);
        gap: 2px;
    }
    .mobile-bottom-nav .mobile-nav-item {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 2px;
        padding: 6px 4px;
        border-radius: 8px;
        color: rgba(255,255,255,0.5);
        font-size: 10px;
        font-weight: 600;
        cursor: pointer;
        transition: all 0.2s;
    }
    .mobile-bottom-nav .mobile-nav-item:hover,
    .mobile-bottom-nav .mobile-nav-item.active {
        color: #fff;
        background: rgba(79, 70, 229, 0.4);
    }
    .mobile-bottom-nav .mobile-nav-item .text-lg {
        font-size: 18px;
    }
    #main-app-container { padding-bottom: 72px; }
}
@media (min-width: 1024px) {
    .mobile-bottom-nav { display: none !important; }
}

/* ─── Timeline System ─────────────────────────────────────────── */
.timeline-entry {
    position: relative;
    padding-left: 28px;
    padding-bottom: 16px;
    border-left: 2px solid var(--border);
    margin-left: 8px;
}
.timeline-entry:last-child { border-left-color: transparent; }
.timeline-entry::before {
    content: '';
    position: absolute;
    left: -5px;
    top: 4px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    border: 2px solid var(--border);
    background: var(--surface);
}

/* Role colors */
.timeline-entry.role-medico { border-left-color: #a78bfa; }
.timeline-entry.role-medico::before { border-color: #7c3aed; background: #ede9fe; }
.timeline-entry.role-enfermeiro { border-left-color: #6ee7b7; }
.timeline-entry.role-enfermeiro::before { border-color: #059669; background: #d1fae5; }
.timeline-entry.role-tecnico { border-left-color: #93c5fd; }
.timeline-entry.role-tecnico::before { border-color: #2563eb; background: #dbeafe; }
.timeline-entry.role-sistema { border-left-color: #e2e8f0; }
.timeline-entry.role-sistema::before { border-color: #94a3b8; background: #f1f5f9; }

/* Type icons */
.timeline-type-icon {
    width: 22px;
    height: 22px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    flex-shrink: 0;
}

/* ─── Allergy Border Pulse ────────────────────────────────────── */
@keyframes border-pulse-red {
    0%, 100% { border-color: #fca5a5; box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.3); }
    50%      { border-color: #ef4444; box-shadow: 0 0 8px 2px rgba(220, 38, 38, 0.15); }
}
.allergy-alert {
    animation: border-pulse-red 2s infinite ease-in-out;
    border-width: 2px;
    border-style: solid;
}

/* ─── Auto-expand Textarea ────────────────────────────────────── */
.auto-expand {
    overflow: hidden;
    resize: none;
    min-height: 120px;
    transition: height 0.15s ease;
}

/* ─── Glasgow Segmented Buttons ───────────────────────────────── */
.gcs-segment {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}
.gcs-segment-btn {
    flex: 1;
    min-width: 0;
    padding: 8px 4px;
    border: 2px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    cursor: pointer;
    text-align: center;
    font-weight: 600;
    font-size: 11px;
    line-height: 1.3;
    color: var(--text-secondary);
    transition: all 0.2s;
}
.gcs-segment-btn:hover {
    border-color: var(--brand-light);
    background: #eef2ff;
}
.gcs-segment-btn.selected {
    border-color: var(--brand);
    background: #4f46e5;
    color: white;
    box-shadow: 0 2px 8px rgba(79, 70, 229, 0.3);
}

/* ─── Manchester Risk Tint ────────────────────────────────────── */
.risk-tint-1 { background-color: rgba(220, 38, 38, 0.06) !important; }   /* Red */
.risk-tint-2 { background-color: rgba(249, 115, 22, 0.06) !important; }  /* Orange */
.risk-tint-3 { background-color: rgba(234, 179, 8, 0.06) !important; }   /* Yellow */
.risk-tint-4 { background-color: rgba(22, 163, 74, 0.06) !important; }   /* Green */
.risk-tint-5 { background-color: rgba(37, 99, 235, 0.06) !important; }   /* Blue */
.risk-tint-6 { background-color: rgba(148, 163, 184, 0.04) !important; } /* Gray */

/* ─── Utility Animations ──────────────────────────────────────── */
@keyframes fade-in {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}
.animate-fade-in { animation: fade-in 0.3s ease-out; }

@keyframes slide-in-right {
    from { opacity: 0; transform: translateX(16px); }
    to   { opacity: 1; transform: translateX(0); }
}
.animate-slide-in-right { animation: slide-in-right 0.3s ease-out; }

@keyframes slide-up {
    from { opacity: 0; transform: translateY(100%); }
    to   { opacity: 1; transform: translateY(0); }
}
.animate-slide-up { animation: slide-up 0.3s cubic-bezier(0.4, 0, 0.2, 1); }

/* ─── Focus States ────────────────────────────────────────────── */
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--brand-light);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

/* ─── Print Overrides ─────────────────────────────────────────── */
@media print {
    .app-sidebar, .mobile-bottom-nav,
    #toast-container, #footer-toggle,
    .no-print { display: none !important; }
    body { background: white; }
}