/* ==========================================================================
   1. DESIGN SYSTEM ULTRA-PREMIUM (Estilo Linear / Fintech)
   ========================================================================== */
:root {
    /* Paleta Cromática Principal (Base Zinc & Indigo) */
    --hue: 230;
    --primary-bg: #09090b;          /* Fundo da Sidebar (Quase Preto) */
    --primary-hover: #27272a;       /* Hover da Sidebar */
    --accent: #4f46e5;              /* Indigo 600 - Ação Primária */
    --accent-glow: rgba(79, 70, 229, 0.4);
    --accent-light: #e0e7ff;        /* Indigo 100 */
    
    /* Estados Semânticos (Alta Saturação) */
    --success: #10b981;             
    --success-bg: #d1fae5;
    --danger: #f43f5e;              
    --danger-bg: #ffe4e6;
    --warning: #f59e0b;             
    --warning-bg: #fef3c7;
    --info: #3b82f6;                
    --info-bg: rgba(59, 130, 246, 0.1);
    
    /* Superfícies e Fundos (Tema Claro de Alta Definição) */
    --bg-app: #f4f4f5;              /* Zinc 100 - Fundo Geral */
    --bg-card: #ffffff;             /* Superfície dos Paineis */
    --border-soft: #e4e4e7;         /* Zinc 200 - Bordas sutis */
    --border-hard: #d4d4d8;         /* Zinc 300 - Bordas de inputs */
    
    /* Tipografia de Contraste Profundo */
    --text-title: #18181b;          /* Zinc 900 */
    --text-body: #3f3f46;           /* Zinc 700 */
    --text-muted: #71717a;          /* Zinc 500 */
    
    /* Geometria e Arredondamentos */
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 24px;              
    --radius-pill: 9999px;
    
    /* Sombras e Efeitos 3D (Estilo Apple / Stripe) */
    --shadow-micro: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-card: 0 4px 12px rgba(0, 0, 0, 0.03), 0 1px 2px rgba(0, 0, 0, 0.02);
    --shadow-hover: 0 20px 25px -5px rgba(0, 0, 0, 0.05), 0 8px 10px -6px rgba(0, 0, 0, 0.02);
    --shadow-input: inset 0 2px 4px rgba(0, 0, 0, 0.02);
    --shadow-float: 0 20px 25px -5px rgba(15, 23, 42, 0.12), 0 10px 10px -5px rgba(15, 23, 42, 0.04);
    
    /* Tempos de Transição */
    --spring: cubic-bezier(0.175, 0.885, 0.32, 1.1); /* Efeito elástico */
    --smooth: cubic-bezier(0.4, 0, 0.2, 1);
}

/* ==========================================================================
   2. RESET MODERNO E TIPOGRAFIA
   ========================================================================== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-app);
    color: var(--text-body);
    font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6 {
    color: var(--text-title);
    font-weight: 800;
    letter-spacing: -0.03em;
}

/* Scrollbar Minimalista */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d4d4d8; border-radius: var(--radius-pill); }
::-webkit-scrollbar-thumb:hover { background: #a1a1aa; }

::selection { background-color: var(--accent-light); color: var(--accent); }

/* ==========================================================================
   3. ANIMAÇÕES CINEMATOGRÁFICAS E EFEITOS
   ========================================================================== */
@keyframes blurIn {
    0% { opacity: 0; filter: blur(10px); transform: scale(0.95) translateY(10px); }
    100% { opacity: 1; filter: blur(0); transform: scale(1) translateY(0); }
}

@keyframes slideDown {
    0% { opacity: 0; transform: translateY(-20px); }
    100% { opacity: 1; transform: translateY(0); }
}

.animar-entrada, .card, .chamado-item, .table-responsive {
    animation: blurIn 0.6s var(--spring) both;
}

/* Efeito Cascata nos Cards de Estatísticas */
.stats-grid .card:nth-child(1) { animation-delay: 0.05s; }
.stats-grid .card:nth-child(2) { animation-delay: 0.15s; }
.stats-grid .card:nth-child(3) { animation-delay: 0.25s; }

/* ==========================================================================
   4. TELA DE LOGIN (Efeito Aurora)
   ========================================================================== */
.fullscreen-center {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: radial-gradient(circle at 15% 50%, rgba(79, 70, 229, 0.15), transparent 25%),
                radial-gradient(circle at 85% 30%, rgba(16, 185, 129, 0.1), transparent 25%);
    background-color: var(--bg-app);
}

.fullscreen-center .card {
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    background: rgba(255, 255, 255, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.8);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.05);
    padding: 40px;
    border-radius: var(--radius-lg);
}

/* ==========================================================================
   5. ARQUITETURA DO DASHBOARD (Layout Split Screen)
   ========================================================================== */
@media (min-width: 769px) {
    .app-layout {
        display: grid;
        grid-template-columns: 280px 1fr;
        min-height: 100vh;
    }
    .sidebar {
        position: sticky;
        top: 0;
        height: 100vh;
    }
}

.sidebar {
    background-color: var(--primary-bg);
    color: #e4e4e7;
    display: flex;
    flex-direction: column;
    z-index: 50;
    border-right: 1px solid #27272a;
}

.sidebar-header {
    padding: 32px 24px;
    font-size: 1.4rem;
    font-weight: 800;
    color: #ffffff;
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-menu {
    list-style: none;
    padding: 16px;
    flex: 1;
    overflow-y: auto;
}

.sidebar-menu li { margin-bottom: 6px; }

.sidebar-menu li a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: #a1a1aa;
    text-decoration: none;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 0.95rem;
    transition: all 0.2s ease;
}

.sidebar-menu li a:hover {
    background-color: var(--primary-hover);
    color: #ffffff;
    transform: translateX(4px);
}

.sidebar-menu li a.active {
    background-color: var(--accent);
    color: #ffffff;
    box-shadow: 0 4px 12px var(--accent-glow);
}

.main-content {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.topbar {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    height: 80px;
    padding: 0 40px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(0,0,0,0.04);
    position: sticky;
    top: 0;
    z-index: 40;
    animation: slideDown 0.5s var(--smooth);
}

.content-area {
    padding: 40px;
    flex: 1;
}

/* ==========================================================================
   6. CARDS, GRIDS E WIDGETS
   ========================================================================== */
.card {
    background-color: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-soft);
    box-shadow: var(--shadow-card);
    padding: 32px;
    margin-bottom: 24px;
    transition: box-shadow 0.3s ease, transform 0.3s ease;
}

.card:hover {
    box-shadow: var(--shadow-hover);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 24px;
    margin-bottom: 40px;
}

.stats-grid .card {
    padding: 28px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    position: relative;
    overflow: hidden;
    background: linear-gradient(145deg, #ffffff, #fafafa);
}

/* Elemento Circular Decorativo */
.stats-grid .card::after {
    content: '';
    position: absolute;
    top: -20px;
    right: -20px;
    width: 100px;
    height: 100px;
    border-radius: 50%;
    opacity: 0.1;
}
.stats-grid .card:nth-child(1)::after { background: var(--warning); }
.stats-grid .card:nth-child(2)::after { background: var(--success); }
.stats-grid .card:nth-child(3)::after { background: var(--danger); }

.control-bar {
    background-color: var(--bg-card);
    padding: 16px 24px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-soft);
    box-shadow: var(--shadow-micro);
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 32px;
}

/* ==========================================================================
   7. TABELAS DE ALTA PERFORMANCE
   ========================================================================== */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    border-radius: var(--radius-lg);
    background-color: var(--bg-card);
    border: 1px solid var(--border-soft);
    box-shadow: var(--shadow-card);
}

.table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    text-align: left;
    white-space: nowrap;
}

.table th {
    background-color: #fafafa;
    color: var(--text-muted);
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.08em;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-soft);
}

.table td {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-soft);
    font-size: 0.95rem;
    color: var(--text-body);
    transition: background-color 0.2s ease;
}

.table tbody tr:hover td {
    background-color: var(--bg-app);
}

/* ==========================================================================
   8. COMPONENTES OPERACIONAIS (Grid Mobile)
   ========================================================================== */
.lista-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 24px;
}

.chamado-item {
    background-color: var(--bg-card);
    padding: 28px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    border: 1px solid var(--border-soft);
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
    transition: transform 0.3s var(--spring), box-shadow 0.3s ease;
}

/* Identificador Lateral de Status */
.chamado-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 6px;
}
.chamado-item.status-PENDENTE::before { background: var(--warning); }
.chamado-item.status-APROVADO::before { background: var(--info); }
.chamado-item.status-RESOLVIDO::before { background: var(--success); }
.chamado-item.status-REJEITADO::before { background: var(--danger); }

.chamado-item:hover {
    transform: translateY(-5px) scale(1.01);
    box-shadow: var(--shadow-hover);
}

/* ==========================================================================
   9. BADGES SEMÂNTICOS
   ========================================================================== */
.badge {
    padding: 6px 14px;
    border-radius: var(--radius-pill);
    font-size: 0.75rem;
    font-weight: 800;
    letter-spacing: 0.05em;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-transform: uppercase;
}

.badge-master { background-color: #fef9c3; color: #854d0e; }
.badge-supervisor { background-color: #e0f2fe; color: #0369a1; }
.badge-funcionario { background-color: #f4f4f5; color: #3f3f46; }

.status-PENDENTE .badge-status { background-color: var(--warning-bg); color: #b45309; }
.status-APROVADO .badge-status { background-color: var(--info-bg); color: #1d4ed8; }
.status-RESOLVIDO .badge-status { background-color: var(--success-bg); color: #047857; }
.status-REJEITADO .badge-status { background-color: var(--danger-bg); color: #b91c1c; }

/* ==========================================================================
   10. INPUTS E FORMULÁRIOS
   ========================================================================== */
.form-group { margin-bottom: 24px; }
.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-title);
}

.form-control, input[type="text"], input[type="password"], input[type="number"], textarea, select {
    width: 100%;
    padding: 16px 20px;
    border: 1px solid var(--border-hard);
    border-radius: var(--radius-md);
    font-size: 16px;
    color: var(--text-title);
    background-color: #fafafa;
    box-shadow: var(--shadow-input);
    transition: all 0.2s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--accent);
    background-color: #ffffff;
    box-shadow: 0 0 0 4px var(--accent-glow), inset 0 1px 2px rgba(0,0,0,0.01);
}

textarea.form-control { resize: vertical; min-height: 120px; }

.file-label {
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px dashed var(--border-hard);
    color: var(--text-muted);
    background-color: #fafafa;
    padding: 24px;
    font-weight: 600;
    border-radius: var(--radius-md);
    transition: all 0.2s ease;
}
.file-label:hover {
    border-color: var(--accent);
    color: var(--accent);
    background-color: var(--accent-light);
}

/* ==========================================================================
   11. BOTÕES MAGNÉTICOS
   ========================================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 14px 28px;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 700;
    text-align: center;
    text-decoration: none;
    gap: 8px;
    transition: all 0.2s ease;
    user-select: none;
}

.btn:active { transform: scale(0.95); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }

.btn-block { width: 100%; }
.btn-sm { padding: 10px 18px; font-size: 0.85rem; border-radius: var(--radius-sm); }

.btn-primary { 
    background-color: var(--accent); color: #ffffff; 
    box-shadow: 0 4px 12px var(--accent-glow);
}
.btn-primary:hover { background-color: var(--accent-hover); box-shadow: 0 6px 16px var(--accent-glow); transform: translateY(-2px); }

.btn-success { 
    background-color: var(--success); color: #ffffff; 
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}
.btn-success:hover { background-color: var(--success-hover); transform: translateY(-2px); }

.btn-danger { 
    background-color: var(--danger); color: #ffffff; 
    box-shadow: 0 4px 12px rgba(244, 63, 94, 0.3);
}
.btn-danger:hover { background-color: #e11d48; transform: translateY(-2px); }

.btn-secondary { background-color: #f4f4f5; color: var(--text-title); border: 1px solid var(--border-hard); }
.btn-secondary:hover { background-color: #e4e4e7; }

.btn-outline { background-color: transparent; border: 2px solid #e4e4e7; color: var(--text-body); }
.btn-outline:hover { border-color: var(--text-title); color: var(--text-title); }

.btn-group { display: flex; gap: 12px; }

/* ==========================================================================
   12. SISTEMA DE MODAIS (Glassmorphism + Scale Animation)
   ========================================================================== */
.modal {
    display: none;
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(9, 9, 11, 0.5); 
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.modal-content {
    background: #ffffff;
    width: 100%;
    max-width: 650px;
    border-radius: var(--radius-lg);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    padding: 40px;
    max-height: 90vh;
    overflow-y: auto;
    animation: blurIn 0.4s var(--spring) forwards;
}

/* ==========================================================================
   13. APP NATIVO RESPONSIVO (Bottom Tab Bar & Scroll Fixes)
   ========================================================================== */
@media (max-width: 1024px) {
    .topbar { padding: 0 24px; }
    .content-area { padding: 24px; }
}

@media (max-width: 768px) {
    .app-layout { display: block; padding-bottom: 90px; }
    
    /* Menu Deslizante Horizontal (Estilo Pílulas) no Rodapé */
    .sidebar {
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
        height: auto;
        background-color: rgba(9, 9, 11, 0.98);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        border-top: 1px solid #27272a;
        padding: 12px 0 calc(12px + env(safe-area-inset-bottom)) 16px;
        z-index: 100;
    }
    
    .sidebar-header { display: none; }
    .sidebar-menu li[style] { display: none !important; }
    
    .sidebar-menu { 
        display: flex; 
        flex-direction: row;
        justify-content: flex-start;
        align-items: center;
        width: 100%;
        padding: 0 16px 0 0; 
        margin: 0; 
        overflow-x: auto; 
        scroll-snap-type: x mandatory;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none; 
    }
    
    .sidebar-menu::-webkit-scrollbar { display: none; }
    
    .sidebar-menu li { 
        margin: 0 12px 0 0; 
        flex-shrink: 0; 
        scroll-snap-align: start;
    }
    
    .sidebar-menu li a { 
        display: flex;
        flex-direction: row; 
        align-items: center;
        justify-content: center;
        padding: 12px 20px; 
        font-size: 0.95rem; 
        white-space: nowrap; 
        border-radius: var(--radius-pill); 
        background: rgba(255, 255, 255, 0.08);
        color: #d4d4d8;
    }
    
    .sidebar-menu li a:hover, .sidebar-menu li a.active {
        transform: none; 
        background-color: var(--accent);
        color: #ffffff;
        box-shadow: 0 4px 12px var(--accent-glow);
    }
    
    /* Layout Mobile Tweak */
    .topbar { height: 75px; padding: 0 20px; }
    .content-area { padding: 20px 16px; }
    
    .stats-grid { grid-template-columns: 1fr; gap: 16px; margin-bottom: 24px; }
    .stats-grid .card { padding: 24px; }
    .stats-grid .card::after { width: 80px; height: 80px; top: -15px; right: -15px; opacity: 0.05; }
    
    .control-bar { flex-direction: column; align-items: stretch; padding: 20px; }
    .control-bar .btn-group { flex-direction: column; width: 100%; margin-top: 16px; }
    .filters-group { width: 100%; flex-direction: column; align-items: flex-start; }
    .filters-group select { width: 100%; margin-top: 8px; }
    
    .modal-content { padding: 28px 20px; border-radius: var(--radius-md); }

    /* ======================================================================= */
    /* OTIMIZAÇÃO CRÍTICA PARA SCROLL HORIZONTAL DE TABELAS NO MOBILE          */
    /* ======================================================================= */
    .table-responsive {
        -webkit-overflow-scrolling: touch;
        overflow-x: auto !important;
        border-radius: var(--radius-md);
    }

    .table th, .table td {
        padding: 14px 16px; 
        font-size: 0.85rem;
    }
    
    .table th {
        font-size: 0.7rem;
        padding: 12px 16px;
    }

    /* Otimização visual para os botões secundários nos modais */
    .modal-content .btn-secondary, 
    .modal-content .btn-outline {
        border: 1px solid var(--border-hard) !important;
        background-color: transparent !important;
        color: var(--text-title) !important;
        box-shadow: none !important;
    }
}

/* ==========================================================================
   14. FOLHA DE IMPRESSÃO (A4 Pixel Perfect)
   ========================================================================== */
@media print {
    .sidebar, .topbar, .control-bar, .btn, .no-print, .file-label, .modal { display: none !important; }
    
    body, .app-layout, .main-content, .content-area, .card {
        background: transparent !important; 
        box-shadow: none !important; 
        border: none !important; 
        margin: 0 !important; 
        padding: 0 !important; 
        color: #000 !important; 
        width: 100% !important;
    }
    
    .table-responsive { overflow: visible !important; border: none !important; }
    .table { width: 100% !important; white-space: normal !important; }
    .table th, .table td { 
        border-bottom: 1px solid #000 !important; 
        padding: 10px !important; 
        font-size: 12px !important; 
        color: #000 !important; 
    }
    .table th { background-color: #f4f4f5 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    
    .table-responsive::before {
        content: "Relatório de Gestão e Ocorrências - Gerado Eletronicamente";
        display: block; font-size: 16px; font-weight: bold; text-align: center; margin-bottom: 20px; color: #000;
    }
}