/* ========================================
   DESIGN SYSTEM - TEMAS CLARO E ESCURO
   Cor Predominante: Vermelho (#e74c3c)
   ======================================== */

:root {
    /* Variáveis de Cores - Tema Escuro (Padrão) */
    --bg-primary: #0f1419;
    --bg-secondary: #1a1f2e;
    --bg-tertiary: #252d3d;
    
    --text-primary: #ffffff;
    --text-secondary: #d8dce3; /* Mais claro para leitura em fundo escuro */
    --text-muted: #bfc6cc; /* Tom mais suave mas legível */
    --on-primary: #ffffff; /* Texto sobre elementos em vermelho */
    --surface-contrast: rgba(255,255,255,0.03);
    
    --border-color: #252d3d;
    
    /* Cores de Marca e Ação */
    --primary-red: #e74c3c;
    --primary-red-light: #ec7063;
    --primary-red-dark: #c0392b;
    
    --success: #27ae60;
    --warning: #f39c12;
    --danger: #e74c3c;
    --info: #3498db;
    
    /* Sombras */
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);
    
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Tema Claro */
[data-theme="light"] {
    --bg-primary: #f8f9fa;
    --bg-secondary: #ffffff;
    --bg-tertiary: #e9ecef;
    
    --text-primary: #212529;
    --text-secondary: #495057;
    --text-muted: #6c757d;
    
    --border-color: #dee2e6;
    
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
}

/* ========================================
   RESET E ESTILOS GLOBAIS
   ======================================== */

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.6;
    transition: background-color 0.3s, color 0.3s;
}

/* ========================================
   LAYOUT
   ======================================== */

.header {
    background: linear-gradient(135deg, var(--primary-red-dark) 0%, var(--primary-red) 100%);
    padding: 1rem 0;
    box-shadow: var(--shadow-lg);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 2rem;
}

.header span {
    font-size: 1.3rem;
    font-weight: 700;
    color: #ffffff;
    letter-spacing: 0.5px;
}

.main-wrapper {
    display: flex;
    min-height: calc(100vh - 65px);
}

.sidebar {
    width: 260px;
    background-color: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    padding: 1.5rem 0;
    position: sticky;
    top: 65px;
    height: calc(100vh - 65px);
    overflow-y: auto;
}

.sidebar ul {
    list-style: none;
}

.sidebar a {
    display: flex;
    align-items: center;
    padding: 0.9rem 1.5rem;
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 600;
    transition: var(--transition);
    border-left: 4px solid transparent;
    font-size: 0.95rem;
}

.sidebar a:hover, .sidebar li.active a {
    background-color: rgba(231, 76, 60, 0.1);
    color: var(--primary-red);
    border-left-color: var(--primary-red);
}

.sidebar a i {
    width: 20px;
    text-align: center;
}

.sidebar .submenu {
    background-color: rgba(0, 0, 0, 0.05);
    padding-left: 1rem;
}

.content {
    flex: 1;
    padding: 2rem;
    background-color: var(--bg-primary);
}

/* ========================================
   COMPONENTES
   ======================================== */

.card {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--primary-red);
}

.card-title {
    color: var(--primary-red) !important;
    font-size: 1.05rem;
    font-weight: 600;
    margin-bottom: 1.2rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--primary-red);
    display: block;
    width: 100%;
}

/* Garantir que títulos de card mantenham cor da marca mesmo com regras globais */
.card-title { color: var(--primary-red) !important; }

/* Regras altamente específicas para sobrescrever qualquer outro estilo */
.card h2.card-title, .card h3.card-title, .card .card-title {
    color: var(--primary-red) !important;
}

/* Garantir que a classe utilitária .text-red sempre aplique a cor da marca */
.text-red { color: var(--primary-red) !important; }

/* Acessibilidade: utilitários de contraste e foco */
.text-on-primary { color: var(--on-primary) !important; }
.bg-contrast { background-color: var(--surface-contrast) !important; }
.text-contrast { color: var(--text-primary) !important; }

/* Melhor foco para elementos interativos */
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
    box-shadow: 0 0 0 3px rgba(231,76,60,0.18);
    outline: none;
}

.sidebar a:focus-visible {
    border-left-color: var(--primary-red);
}

.form-control[disabled], .form-select[disabled] {
    color: var(--text-muted);
    opacity: 0.95;
}

/* Pequenas melhorias de UX/DX */
.clickable { cursor: pointer; }
.muted { color: var(--text-muted); }

/* Overrides para classes do Bootstrap para melhor legibilidade no tema escuro */
h1, h2, h3, h4, h5, h6 {
    color: var(--text-primary) !important;
}

/* Diminuir tamanhos de títulos para padronizar */
h1 { font-size: 1.4rem; font-weight: 700; margin-bottom: 1.5rem; }
h2 { font-size: 1.1rem; font-weight: 600; margin-bottom: 1.2rem; }
h3 { font-size: 1rem; font-weight: 600; margin-bottom: 1rem; }
h4 { font-size: 0.9rem; font-weight: 600; margin-bottom: 0.8rem; }


.text-secondary { color: var(--text-secondary) !important; }
.text-dark { color: var(--text-primary) !important; }
.text-body { color: var(--text-primary) !important; }

/* Tabelas */
.table {
    color: var(--text-primary);
    background-color: transparent;
}

.table thead th {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    border-bottom: 2px solid var(--border-color);
    padding: 1rem;
}

.table td {
    padding: 1rem;
    vertical-align: middle;
    border-bottom: 1px solid var(--border-color);
    background-color: transparent;
    color: var(--text-primary); /* garantir contraste nas células */
}

/* Rótulos e textos de formulários devem ser legíveis sobre o card */
label, .form-group label {
    color: var(--text-primary);
    font-weight: 500;
    margin-bottom: 0.4rem;
    display: inline-block;
}

/* Ajuste de contraste para textos em cards e tabelas */
.card p, .card span, .table td {
    color: var(--text-primary) !important;
}

.text-muted {
    color: var(--text-muted) !important;
}

/* Correção para fundos claros em tema escuro que o usuário mencionou */
.bg-tertiary, .bg-light, .card.bg-light {
    background-color: var(--bg-tertiary) !important;
    color: var(--text-primary) !important;
}

/* Garantir que inputs não fiquem com fundo branco e letra clara ou vice-versa */
.form-control, .form-select {
    background-color: var(--bg-tertiary) !important;
    color: var(--text-primary) !important;
    border: 1px solid var(--border-color) !important;
}

.form-control:focus, .form-select:focus {
    background-color: var(--bg-secondary) !important;
    color: var(--text-primary) !important;
}

/* Ajuste para badges para garantir que o texto seja sempre legível */
.badge {
    font-weight: 600;
    padding: 0.4em 0.8em;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
}

/* Conteúdo textual dentro dos cards (infos do cliente) */
.card .card-content, .card .card-content p, .card .card-content strong, .card .card-content span {
    color: var(--text-primary);
}

/* Forçar linhas/table bodies a usar variáveis de tema para contraste correto */
.table tbody tr { background-color: transparent; }

/* Em containers com fundo claro (ex.: tema light), garantir contraste */
[data-theme="light"] .table thead th { background-color: var(--bg-tertiary); color: var(--text-primary); }
[data-theme="light"] .table td { background-color: transparent; color: var(--text-primary); }

/* Utilitários para formulários */
.full-width { grid-column: 1 / -1 !important; }
.textarea-large { min-height: 120px; }

/* Formulários */
.form-group {
    margin-bottom: 1.25rem;
}

.form-control, .form-select {
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: 8px;
    padding: 0.6rem 1rem;
}

.form-control:focus, .form-select:focus {
    background-color: var(--bg-secondary);
    border-color: var(--primary-red);
    color: var(--text-primary);
    box-shadow: 0 0 0 0.25rem rgba(231, 76, 60, 0.25);
}

.form-control::placeholder {
    color: var(--text-muted);
}

/* Botões */
.btn-primary {
    background-color: var(--primary-red);
    border-color: var(--primary-red);
    color: #ffffff !important;
    font-weight: 600;
}

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

.btn-secondary {
    background-color: var(--bg-tertiary);
    border-color: var(--border-color);
    color: var(--text-primary) !important;
}

/* Base para botões (padroniza comportamento) */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.6rem 0.9rem;
    border-radius: 8px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}

.btn-sm { padding: 0.4rem 0.7rem; font-size: 0.9rem; }
.btn-xs { padding: 0.25rem 0.5rem; font-size: 0.8rem; }
.btn-block { width: 100%; display: inline-flex; }

/* Variantes outline (existiam no markup mas não no CSS) */
.btn-outline-primary {
    background: transparent;
    color: var(--primary-red) !important;
    border-color: var(--primary-red);
}
.btn-outline-primary:hover { background: rgba(231,76,60,0.08); color: var(--text-primary) !important; }

.btn-outline-secondary {
    background: transparent;
    color: var(--text-primary) !important;
    border-color: var(--border-color);
}
.btn-outline-secondary:hover { background: rgba(255,255,255,0.02); }

/* Variantes informacionais */
.btn-info { background-color: var(--info); border-color: var(--info); color: var(--on-primary) !important; }
.btn-success { background-color: var(--success); border-color: var(--success); color: var(--on-primary) !important; }
.btn-danger { background-color: var(--danger); border-color: var(--danger); color: var(--on-primary) !important; }
.btn-warning { background-color: var(--warning); border-color: var(--warning); color: var(--on-primary) !important; }

/* Específico: botões usados na lista de equipamentos do cliente */
.filter-equip { white-space: normal; text-align: left; }
.filter-equip.btn-outline-primary { border-width: 1px; }

/* Container para lista de equipamentos */
.equipment-list { display: flex; flex-direction: column; gap: 10px; }

/* Utilitários faltantes usados nas views */
.justify-between { justify-content: space-between !important; }
.align-center { align-items: center !important; }

/* GRID para detalhes do cliente (substitui estilos inline) */
.client-detail-grid {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 2rem;
}

@media (max-width: 900px) {
    .client-detail-grid { grid-template-columns: 1fr; }
    .client-detail-grid .card { padding: 1rem; }
    .d-flex.justify-between { flex-direction: column; gap: 0.75rem; align-items: flex-start; }
    .quick-actions { flex-direction: column; }
    .form-grid { grid-template-columns: 1fr; }
    .table thead th, .table td { padding: 0.6rem; }
    .sidebar { display: none; }
}

/* Garante contraste em badges geradas dinamicamente sem cor de texto definida */
.badge { color: var(--on-primary); }

/* Conteúdo dentro do card com melhor legibilidade */
.card-content { line-height: 1.8; }

/* Utilitários de Cores */
.text-red { color: var(--primary-red) !important; }
.bg-red { background-color: var(--primary-red) !important; }

/* Grid Customizado para Forms */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
}

/* Seletor de Tema */
.theme-switch {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1001;
    background: var(--primary-red);
    color: white;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--shadow-lg);
    border: none;
}

/* Estilos para Impressão (OS) */
@media print {
    .header, .sidebar, .theme-switch, .btn:not(.print-visible) {
        display: none !important;
    }
    .main-wrapper { display: block; }
    .content { padding: 0; }
    .card { border: 1px solid #000; box-shadow: none; }
}

/* Ajustes para Dashboards e Badges */
.badge {
    padding: 0.5em 0.8em;
    border-radius: 6px;
    font-weight: 600;
}

.dashboard-stat {
    display: flex;
    flex-direction: column;
}

.dashboard-stat .value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
}

.dashboard-stat .label {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Layout do dashboard: cards compactos e sidebar mais visível */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 2rem;
    margin-top: 1rem;
}

.dashboard-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 140px;
    padding: 1.5rem;
    border-radius: 20px;
    position: relative;
    overflow: hidden;
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.2);
    border-color: var(--primary-red);
}

.stat-icon {
    font-size: 1.5rem;
    width: 45px;
    height: 45px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    border-radius: 12px;
    margin-bottom: 1rem;
}

.stat-card h2 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary) !important;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border: none;
    padding: 0;
}

.card-value {
    font-size: 1.8rem;
    font-weight: 800;
    margin: 0;
    color: var(--text-primary) !important;
}

.success-text { color: var(--success) !important; background: transparent; padding: 0; }
.danger-text { color: var(--danger) !important; background: transparent; padding: 0; }
.info-text { color: var(--info) !important; background: transparent; padding: 0; }
.warning-text { color: var(--warning) !important; background: transparent; padding: 0; }

.quick-actions {
    display: flex;
    gap: 1rem;
    margin-bottom: 2.5rem;
    flex-wrap: wrap;
}

.quick-actions .btn {
    padding: 0.8rem 1.5rem;
    border-radius: 12px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transition: all 0.3s ease;
    min-width: 160px;
}

.quick-actions .btn:hover {
    transform: scale(1.02);
}

.tasks-sidebar-content {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.tasks-section {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 1.5rem;
}

.tasks-section h3 {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 1.2rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Ensure chart bars remain visible */
.chart-bar { background: linear-gradient(180deg, var(--primary-red-light), var(--primary-red-dark)); }

/* Utilitários de Dashboard */
.mb-4 { margin-bottom: 2rem !important; }
.mt-4 { margin-top: 2rem !important; }
.text-muted { color: var(--text-muted) !important; }
.fs-sm { font-size: 0.85rem !important; }
.flex-1 { flex: 1 !important; }
.d-flex { display: flex !important; }
.gap-2 { gap: 0.5rem !important; }
.gap-3 { gap: 1rem !important; }

.chart-container {
    min-height: 300px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
}

.chart-bars {
    width: 100%;
    height: 200px;
    display: flex;
    align-items: flex-end;
    gap: 10px;
    padding: 20px;
}

.chart-bar {
    flex: 1;
    background: var(--primary-red);
    border-radius: 4px 4px 0 0;
    transition: height 0.5s ease;
}

.quick-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
}

/* Utilitários de Layout e Tabelas */
.d-flex { display: flex !important; }
.justify-between { justify-content: space-between !important; }
.align-center { align-items: center !important; }
.flex-wrap { flex-wrap: wrap !important; }
.gap-1 { gap: 0.5rem !important; }
.gap-2 { gap: 1rem !important; }
.w-100 { width: 100% !important; }

.grid-search {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 1rem;
    align-items: end;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1rem;
    background-color: var(--bg-secondary);
    border-radius: 8px;
    overflow: hidden;
}

th {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    text-align: left;
    padding: 1rem;
    font-weight: 600;
    border-bottom: 2px solid var(--border-color);
}

td {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
}

tr:hover td {
    background-color: rgba(231, 76, 60, 0.05);
}

/* Paginação */
.pagination {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
}

.pagination a {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    text-decoration: none;
    color: var(--text-secondary);
    transition: var(--transition);
}

.pagination a:hover, .pagination a.active {
    background-color: var(--primary-red);
    color: white;
    border-color: var(--primary-red);
}

.overflow-x-auto {
    overflow-x: auto;
}

/* Estilos de Login */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: radial-gradient(circle at top right, rgba(231, 76, 60, 0.05), transparent), 
                radial-gradient(circle at bottom left, rgba(231, 76, 60, 0.05), transparent),
                var(--bg-primary);
    padding: 1.5rem;
}

.login-container {
    width: 100%;
    max-width: 420px;
    animation: fadeIn 0.6s ease-out;
}

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

.login-card {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    padding: 3rem 2.5rem;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
    position: relative;
    overflow: hidden;
}

.login-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(90deg, var(--primary-red), var(--primary-red-light));
}

.login-header {
    text-align: center;
    margin-bottom: 2.5rem;
}

.login-header h1 {
    font-size: 2.2rem;
    font-weight: 800;
    color: var(--text-primary) !important;
    margin-bottom: 0.75rem;
    letter-spacing: -1px;
}

.login-header h1 span {
    color: var(--primary-red);
}

.login-header p {
    font-size: 0.95rem;
    color: var(--text-muted);
}

.login-card .form-group {
    display: block !important;
    width: 100% !important;
    margin-bottom: 1.5rem !important;
}

.login-card .form-group label {
    display: block !important;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-secondary);
    margin-bottom: 0.6rem;
}

.login-card .form-control {
    display: block !important;
    width: 100% !important;
}

.login-card .form-control {
    height: 52px;
    background-color: var(--bg-tertiary) !important;
    border: 2px solid transparent !important;
    border-radius: 12px;
    padding: 0 1.2rem;
    font-size: 1rem;
    transition: var(--transition);
}

.login-card .form-control:focus {
    border-color: var(--primary-red) !important;
    background-color: var(--bg-secondary) !important;
    box-shadow: 0 0 0 4px rgba(231, 76, 60, 0.1);
}

.login-card .btn-primary {
    height: 52px;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-top: 1rem;
    box-shadow: 0 8px 16px rgba(231, 76, 60, 0.2);
    transition: all 0.3s ease;
}

.login-card .btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 20px rgba(231, 76, 60, 0.3);
}

.login-footer {
    text-align: center;
    margin-top: 2.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

/* Responsividade Login */
@media (max-width: 480px) {
    .login-card {
        padding: 2rem 1.5rem;
    }
    .login-header h1 {
        font-size: 1.8rem;
    }
}

.alert {
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    border-left: 4px solid;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.alert-danger {
    background-color: rgba(231, 76, 60, 0.1);
    border-left-color: var(--danger);
    color: var(--danger);
}

/* Autocomplete e Utilitários Extras */
.autocomplete-results {
    position: absolute;
    z-index: 1000;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    width: 100%;
    max-height: 200px;
    overflow-y: auto;
    box-shadow: var(--shadow-md);
}

.autocomplete-item {
    padding: 10px;
    cursor: pointer;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    color: var(--text-primary);
}

.autocomplete-item:hover {
    background: var(--bg-tertiary);
    color: var(--primary-red);
}

.justify-end { justify-content: flex-end !important; }
.m-0 { margin: 0 !important; }
.p-0 { padding: 0 !important; }
.border-top { border-top: 1px solid var(--border-color) !important; }
.rounded { border-radius: 8px !important; }
.border { border: 1px solid var(--border-color) !important; }

/* Utilitários Finais */
.align-end { align-items: flex-end !important; }
.text-end { text-align: right !important; }
.text-center { text-align: center !important; }
.cursor-help { cursor: help !important; }
.cursor-pointer { cursor: pointer !important; }
.fs-5 { font-size: 1.25rem !important; }
.bg-tertiary { background-color: var(--bg-tertiary) !important; }
.fw-bold { font-weight: 700 !important; }
.d-inline { display: inline !important; }
.d-inline-block { display: inline-block !important; }
.text-white { color: #ffffff !important; }
.text-info { color: var(--info) !important; }
.text-success { color: var(--success) !important; }
.text-danger { color: var(--danger) !important; }
.text-warning { color: var(--warning) !important; }
.mb-0 { margin-bottom: 0 !important; }
.mb-1 { margin-bottom: 0.25rem !important; }
.mb-2 { margin-bottom: 0.5rem !important; }
.mb-3 { margin-bottom: 1rem !important; }
.mt-2 { margin-top: 0.5rem !important; }
.mt-3 { margin-top: 1rem !important; }
.py-3 { padding-top: 1rem !important; padding-bottom: 1rem !important; }

/* ==========================
   Responsividade (tablet / mobile)
   ========================== */

@media (max-width: 992px) {
    .main-wrapper { flex-direction: column; }
    .sidebar { position: relative; width: 100%; height: auto; top: 0; border-right: none; border-bottom: 1px solid var(--border-color); }
    .dashboard-grid { grid-template-columns: 1fr; }
    .tasks-sidebar-content { order: 2; }
    .main-content-area { order: 1; }
    .dashboard-cards { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; }
    .quick-actions { justify-content: flex-start; }
}

@media (max-width: 768px) {
    body { font-size: 13px; }
    .container { padding: 1rem; }
    .header .container { padding: 0 1rem; }
    .dashboard-grid { grid-template-columns: 1fr; gap: 1rem; }
    .dashboard-cards { grid-template-columns: 1fr; }
    .stat-card { padding: 0.9rem; min-height: auto; }
    .stat-card h2 { font-size: 0.95rem; }
    .card-value { font-size: 1.4rem; }
    .quick-actions { flex-direction: column; gap: 0.75rem; }
    .quick-actions .btn { width: 100%; min-width: auto; }
    .tasks-sidebar-content { width: 100%; }
    .theme-switch { bottom: 14px; right: 14px; width: 40px; height: 40px; }
    .sidebar a { padding: 0.6rem 1rem; }
    .chart-bars { padding: 12px; height: 160px; }
}

/* Estilos para o Fluxo de Atividades */
.activity-feed .list-group-item {
    transition: all 0.2s ease;
}

.activity-feed .list-group-item:hover {
    background: var(--bg-tertiary) !important;
    border-radius: 12px;
    transform: translateX(5px);
}

.activity-icon {
    box-shadow: var(--shadow-sm);
}

/* --- LIMPEZA E RESPONSIVIDADE FINAL --- */

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 2000; /* Acima de tudo */
    backdrop-filter: blur(3px);
}

/* Ajuste do Submenu (Bug de Configurações) */
.submenu {
    list-style: none;
    padding: 0;
    margin: 0;
    background: rgba(0, 0, 0, 0.15); 
    border-radius: 4px;
}
.submenu li a {
    padding: 10px 15px 10px 50px !important;
    font-size: 0.85rem !important;
    border-left: none !important;
}

/* Seta do Dropdown */
.dropdown-toggle { position: relative; }
.dropdown-toggle::after {
    content: '\f107';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    position: absolute;
    right: 15px;
    transition: transform 0.3s;
}
.submenu-open .dropdown-toggle::after { transform: rotate(180deg); }

@media (max-width: 992px) {
    /* Impede que o layout antigo quebre a sidebar mobile */
    .main-wrapper { flex-direction: row !important; } 
    
    .sidebar {
        position: fixed !important;
        left: -280px !important; /* Escondido */
        top: 0 !important;
        height: 100vh !important;
        width: 260px !important;
        z-index: 3000 !important;
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
        display: block !important; /* Força aparecer no DOM */
        box-shadow: 10px 0 20px rgba(0,0,0,0.2);
    }

    .sidebar.active {
        left: 0 !important;
    }

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

    .content {
        margin-left: 0 !important;
        width: 100% !important;
        padding: 1rem !important;
    }
}

/* Ajuste extra para telas bem pequenas */
@media (max-width: 576px) {
    .header span { font-size: 1rem; }
    .card { padding: 1rem; }
}
