/* ============================
   ZELADOR DIGITAL - Estilos Globais
   ============================ */

:root {
    --color-primary: #1a73e8;
    --color-primary-dark: #0d47a1;
    --color-primary-light: #e8f0fe;
    --color-bg: #f0f2f5;
    --color-surface: #ffffff;
    --color-text: #1f2937;
    --color-text-secondary: #6b7280;
    --color-border: #e5e7eb;

    --triage-red: #dc2626;
    --triage-red-bg: #fef2f2;
    --triage-red-border: #fca5a5;
    --triage-yellow: #d97706;
    --triage-yellow-bg: #fffbeb;
    --triage-yellow-border: #fcd34d;
    --triage-green: #059669;
    --triage-green-bg: #ecfdf5;
    --triage-green-border: #6ee7b7;
    --triage-blue: #2563eb;
    --triage-blue-bg: #eff6ff;
    --triage-blue-border: #93c5fd;

    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.07);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.1);
    --radius: 8px;
    --radius-lg: 12px;

    /* Sidebar & Dark Theme */
    --sidebar-width: 220px;
    --sidebar-bg: #111827;
    --sidebar-text: #d1d5db;
    --sidebar-active-bg: #1f2937;
    --sidebar-active-text: #ffffff;
    --sidebar-hover-bg: #1f2937;
    --color-dark-card: #1f2937;
    --color-dark-card-border: #374151;
    --color-dark-text: #f9fafb;
    --color-dark-text-secondary: #9ca3af;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 16px;
    line-height: 1.6;
    color: var(--color-text);
    background: var(--color-bg);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ============================
   NAVBAR
   ============================ */

.navbar {
    background: var(--color-primary);
    color: white;
    padding: 0 24px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow-md);
    position: sticky;
    top: 0;
    z-index: 100;
}

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

.nav-logo {
    width: 36px;
    height: 36px;
}

.nav-title {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.3px;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 8px;
}

.nav-link {
    color: rgba(255,255,255,0.85);
    text-decoration: none;
    padding: 8px 16px;
    border-radius: var(--radius);
    font-size: 15px;
    font-weight: 500;
    transition: all 0.2s;
}

.nav-link:hover, .nav-link.active {
    background: rgba(255,255,255,0.15);
    color: white;
}

.nav-link-emergency {
    color: #fca5a5;
}

.nav-link-emergency:hover, .nav-link-emergency.active {
    color: white;
    background: rgba(220, 38, 38, 0.3);
}

.nav-link-logout {
    margin-left: 8px;
    opacity: 0.7;
}

.nav-link-logout:hover {
    opacity: 1;
}

/* ============================
   SIDEBAR
   ============================ */

body.has-sidebar {
    flex-direction: row;
}

.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 200;
    overflow-y: auto;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 16px;
    border-bottom: 1px solid var(--color-dark-card-border);
}

.sidebar-logo {
    width: 36px;
    height: 36px;
}

.sidebar-title {
    font-size: 17px;
    font-weight: 700;
    color: var(--sidebar-active-text);
    letter-spacing: -0.3px;
}

.sidebar-nav {
    flex: 1;
    padding: 12px 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 15px;
    font-weight: 500;
    transition: background 0.2s, color 0.2s;
    border-left: 3px solid transparent;
}

.sidebar-link:hover {
    background: var(--sidebar-hover-bg);
    color: var(--sidebar-active-text);
}

.sidebar-link.active {
    background: var(--sidebar-active-bg);
    color: var(--sidebar-active-text);
    border-left-color: var(--color-primary);
}

.sidebar-icon {
    width: 20px;
    text-align: center;
    font-size: 16px;
    flex-shrink: 0;
}

.sidebar-section-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--color-dark-text-secondary);
    padding: 8px 20px 4px;
}

.sidebar-divider {
    height: 1px;
    background: var(--color-dark-card-border);
    margin: 8px 16px;
}

.sidebar-link-emergency {
    color: #fca5a5;
}

.sidebar-link-emergency:hover {
    color: white;
    background: rgba(220, 38, 38, 0.25);
}

.sidebar-link-emergency.active {
    color: white;
    background: rgba(220, 38, 38, 0.3);
    border-left-color: var(--triage-red);
}

.sidebar-footer {
    padding: 12px 0;
    border-top: 1px solid var(--color-dark-card-border);
}

.sidebar-link-logout {
    opacity: 0.7;
}

.sidebar-link-logout:hover {
    opacity: 1;
}

/* Main wrapper when sidebar is active */
.main-wrapper {
    margin-left: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

body.has-sidebar .container {
    max-width: 1400px;
}

/* Mobile sidebar */
.mobile-header {
    display: none;
}

.sidebar-overlay {
    display: none;
}

@media (max-width: 1024px) {
    body.has-sidebar {
        flex-direction: column;
    }

    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        z-index: 300;
        visibility: hidden;
    }

    .sidebar.open {
        transform: translateX(0);
        visibility: visible;
    }

    .main-wrapper {
        margin-left: 0;
    }

    .mobile-header {
        display: flex;
        align-items: center;
        padding: 8px 12px;
        background: var(--sidebar-bg);
        color: white;
        gap: 8px;
        position: sticky;
        top: 0;
        z-index: 100;
        width: 100%;
        height: 44px;
    }

    .mobile-header .sidebar-title {
        font-size: 14px;
        font-weight: 600;
    }

    .mobile-toggle {
        background: none;
        border: none;
        color: white;
        font-size: 20px;
        cursor: pointer;
        padding: 4px;
    }

    .sidebar-overlay.visible {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.5);
        z-index: 250;
    }
}

/* ============================
   CONTAINER & LAYOUT
   ============================ */

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px;
    flex: 1;
    width: 100%;
}

/* ============================
   FOOTER
   ============================ */

.footer {
    text-align: center;
    padding: 16px;
    color: var(--color-text-secondary);
    font-size: 13px;
    border-top: 1px solid var(--color-border);
    background: var(--color-surface);
}

/* ============================
   BUTTONS
   ============================ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    gap: 8px;
}

.btn-primary {
    background: var(--color-primary);
    color: white;
}

.btn-primary:hover {
    background: var(--color-primary-dark);
}

.btn-success {
    background: var(--triage-green);
    color: white;
}

.btn-success:hover {
    background: #047857;
}

.btn-secondary {
    background: var(--color-bg);
    color: var(--color-text);
    border: 1px solid var(--color-border);
}

.btn-secondary:hover {
    background: var(--color-border);
}

.btn-full {
    width: 100%;
}

.btn-sm {
    padding: 6px 14px;
    font-size: 13px;
}

/* ============================
   FORMS
   ============================ */

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    font-size: 14px;
    color: var(--color-text);
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 15px;
    font-family: inherit;
    transition: border-color 0.2s;
    background: var(--color-surface);
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-light);
}

/* ============================
   CARDS
   ============================ */

.card {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--color-border);
    overflow: hidden;
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--color-border);
    font-weight: 700;
    font-size: 16px;
}

.card-body {
    padding: 20px;
}

/* ============================
   BADGES
   ============================ */

.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-red {
    background: var(--triage-red-bg);
    color: var(--triage-red);
    border: 1px solid var(--triage-red-border);
}

.badge-yellow {
    background: var(--triage-yellow-bg);
    color: var(--triage-yellow);
    border: 1px solid var(--triage-yellow-border);
}

.badge-green {
    background: var(--triage-green-bg);
    color: var(--triage-green);
    border: 1px solid var(--triage-green-border);
}

.badge-blue {
    background: var(--triage-blue-bg);
    color: var(--triage-blue);
    border: 1px solid var(--triage-blue-border);
}

/* ============================
   ALERTS
   ============================ */

.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-size: 14px;
    font-weight: 500;
}

.alert-error {
    background: var(--triage-red-bg);
    color: var(--triage-red);
    border: 1px solid var(--triage-red-border);
}

.alert-success {
    background: var(--triage-green-bg);
    color: var(--triage-green);
    border: 1px solid var(--triage-green-border);
}

.alert-info {
    background: var(--triage-blue-bg);
    color: var(--triage-blue);
    border: 1px solid var(--triage-blue-border);
}

.alert-link {
    display: block;
    margin-top: 8px;
    font-weight: 600;
    text-decoration: underline;
}

/* ============================
   LOGIN
   ============================ */

.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 80px);
    padding: 24px;
}

.login-card {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 40px;
    width: 100%;
    max-width: 420px;
}

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

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

.login-header h1 {
    font-size: 28px;
    font-weight: 800;
    color: var(--color-primary);
    margin-bottom: 4px;
}

.login-subtitle {
    font-size: 14px;
    color: var(--color-text-secondary);
}

.login-form {
    margin-top: 24px;
}

.login-hint {
    text-align: center;
    margin-top: 20px;
    font-size: 12px;
    color: var(--color-text-secondary);
    opacity: 0.6;
}

/* ============================
   STATS BAR (used by legacy pages)
   ============================ */

/* ============================
   TABS (used by legacy pages)
   ============================ */

/* ============================
   PAGE HEADER
   ============================ */

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

.page-header h1 {
    font-size: 24px;
    font-weight: 800;
    color: var(--color-text);
}

/* ============================
   RESPONSIVE
   ============================ */

@media (max-width: 768px) {
    .container {
        padding: 16px;
    }

    .navbar {
        padding: 8px 16px;
        height: auto;
        flex-wrap: wrap;
        gap: 8px;
    }

    .nav-links {
        flex-wrap: wrap;
        gap: 4px;
    }

    .nav-link {
        padding: 6px 10px;
        font-size: 13px;
    }
}

/* ============================
   EMERGENCY BANNER
   ============================ */

.emergency-banner {
    display: flex;
    align-items: center;
    gap: 16px;
    background: var(--triage-red);
    color: white;
    padding: 14px 20px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-weight: 700;
    font-size: 15px;
    animation: emergency-pulse 1.5s ease-in-out 3;
}

.emergency-banner-link {
    color: white;
    text-decoration: underline;
    font-weight: 700;
    white-space: nowrap;
}

.emergency-banner-close {
    background: none;
    border: none;
    color: white;
    font-size: 18px;
    font-weight: 700;
    cursor: pointer;
    padding: 0 4px;
    margin-left: auto;
}

@keyframes emergency-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}
