/* app/static/css/main.css */

/* =========================================
   1. VARIÁVEIS GLOBAIS E RESET
   ========================================= */
:root {
    --primary-color: #0078d4;
    --primary-hover: #005a9e;
    --background-color: #f8f9fa;
    --surface-color: #ffffff;
    --text-color: #333333;
    --heading-color: #000000;
    --border-color: #e0e0e0;
    --shadow: 0 2px 6px rgba(0,0,0,0.08);
    --sidebar-width: 260px;
    --success-color: #28a745;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --info-color: #17a2b8;
}

* {
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    margin: 0;
    background-color: var(--background-color);
    color: var(--text-color);
    overflow-x: hidden;
}

/* =========================================
   2. LAYOUT PRINCIPAL (Sidebar + Conteúdo)
   ========================================= */
.container-app {
    display: flex;
    width: 100%;
    min-height: 100vh;
}

/* Área Principal */
.main-content {
    margin-left: var(--sidebar-width);
    width: calc(100% - var(--sidebar-width));
    transition: margin-left 0.3s ease, width 0.3s ease;
    padding-top: 60px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.content-wrapper {
    padding: 25px;
    flex: 1;
}

/* Barra Superior (Top Bar) */
.top-bar {
    background-color: var(--surface-color);
    padding: 0 25px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    height: 60px;
    position: fixed;
    top: 0;
    right: 0;
    width: calc(100% - var(--sidebar-width));
    z-index: 900;
    transition: width 0.3s ease, left 0.3s ease;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.menu-toggle {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: #555;
    padding: 8px;
    border-radius: 50%;
    transition: background 0.2s;
    z-index: 1001;
    display: flex;
    align-items: center;
    justify-content: center;
}
.menu-toggle:hover { background-color: rgba(0,0,0,0.05); }

.user-menu {
    display: flex;
    align-items: center;
    gap: 20px;
}

.user-name {
    font-weight: 600;
    font-size: 0.9rem;
    color: #555;
}

/* Sidebar Lateral */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--surface-color);
    height: 100vh;
    position: fixed;
    left: 0;
    top: 0;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: transform 0.3s ease;
    overflow-y: auto;
}

.logo {
    padding: 20px;
    text-align: center;
    border-bottom: 1px solid var(--border-color);
    background-color: var(--surface-color);
    position: sticky;
    top: 0;
    z-index: 10;
}

.logo h3 {
    margin: 0;
    color: var(--primary-color);
    font-weight: 800;
    letter-spacing: -0.5px;
}

/* Itens do Menu */
.menu-group {
    padding: 15px 0;
    border-bottom: 1px solid #f0f0f0;
}

.menu-group h3 {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: #6c757d;
    padding: 0 20px 10px;
    margin: 0;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.menu-group a {
    display: flex;
    align-items: center;
    padding: 10px 20px;
    color: var(--text-color);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.95rem;
    transition: all 0.2s;
    border-left: 4px solid transparent;
}

.menu-group a:hover {
    background-color: #f8f9fa;
    color: var(--primary-color);
}

.menu-group a.active {
    background-color: #e9f5ff;
    color: var(--primary-color);
    border-left-color: var(--primary-color);
    font-weight: 600;
}

.menu-group a i {
    width: 24px;
    text-align: center;
    margin-right: 10px;
    font-size: 1rem;
}

/* =========================================
   3. COMPONENTES DE UI
   ========================================= */
.card, .form-container, .admin-container {
    background-color: var(--surface-color);
    border-radius: 8px;
    box-shadow: var(--shadow);
    padding: 25px;
    margin-bottom: 25px;
    border: 1px solid var(--border-color);
}

/* Tabelas */
.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: 0.95rem; }
.table th, .table td { padding: 12px 15px; text-align: left; border-bottom: 1px solid var(--border-color); vertical-align: middle; }
.table th { background-color: #f8f9fa; font-weight: 600; color: #495057; white-space: nowrap; }
.table tbody tr:hover { background-color: #fcfcfc; }

/* Botões */
.btn, .submit-button {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 10px 20px; background-color: var(--primary-color); color: white;
    border: none; border-radius: 6px; font-size: 0.95rem; font-weight: 600;
    cursor: pointer; text-decoration: none; transition: background-color 0.2s, transform 0.1s;
    line-height: 1.5;
}
.btn:hover, .submit-button:hover { background-color: var(--primary-hover); }
.btn:active { transform: translateY(1px); }
.btn-danger { background-color: var(--danger-color); }
.btn-danger:hover { background-color: #c82333; }
.btn-success { background-color: var(--success-color); }
.btn-success:hover { background-color: #218838; }
.btn-outline-primary { background-color: transparent; color: var(--primary-color); border: 1px solid var(--primary-color); }
.btn-outline-primary:hover { background-color: var(--primary-color); color: white; }
.btn-sm { padding: 6px 12px; font-size: 0.85rem; }

/* Forms */
.form-group { margin-bottom: 20px; }
.form-group label { display: block; margin-bottom: 8px; font-weight: 600; color: #495057; font-size: 0.9rem; }
input[type="text"], input[type="number"], input[type="date"], input[type="time"], input[type="email"], input[type="password"], select, textarea {
    width: 100%; padding: 10px 12px; border: 1px solid #ced4da; border-radius: 6px;
    font-size: 1rem; background-color: #fff; transition: border-color 0.2s; box-sizing: border-box;
}
input:focus, select:focus, textarea:focus {
    border-color: var(--primary-color); outline: none; box-shadow: 0 0 0 3px rgba(0, 120, 212, 0.15);
}

/* =========================================
   4. DASHBOARD
   ========================================= */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 20px; margin-bottom: 25px; }
.kpi-card {
    text-align: center; padding: 25px 20px; background: white; border-radius: 8px;
    box-shadow: var(--shadow); border: 1px solid var(--border-color); transition: transform 0.2s;
}
.kpi-card:hover { transform: translateY(-3px); }
.kpi-value { font-size: 2.2rem; font-weight: 700; color: var(--heading-color); line-height: 1.2; }
.kpi-label { font-size: 0.85rem; text-transform: uppercase; color: #6c757d; margin-top: 8px; letter-spacing: 0.5px; font-weight: 600; }
.header-container h1 { margin: 0; font-size: 1.8rem; color: var(--heading-color); }
.charts-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 25px; }

/* =========================================
   5. UTILITÁRIOS (Loader, Modal, Notif)
   ========================================= */
.loading-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(255,255,255,0.8); z-index: 2000; display: flex;
    justify-content: center; align-items: center; opacity: 0; pointer-events: none; transition: opacity 0.3s;
}
.loading-overlay.visible { opacity: 1; pointer-events: all; }
.spinner { width: 50px; height: 50px; border: 5px solid #f3f3f3; border-top: 5px solid var(--primary-color); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* Modal */
.modal-backdrop { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(0, 0, 0, 0.5); z-index: 1040; display: none; }
.modal {
    position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
    width: 90%; max-width: 800px; max-height: 90vh; background-color: #fff;
    border-radius: 8px; box-shadow: 0 5px 15px rgba(0,0,0,0.3); z-index: 1050;
    display: none; flex-direction: column;
}
.modal.show, .modal-backdrop.show { display: flex; }
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 15px 20px; border-bottom: 1px solid var(--border-color); }
.modal-body { padding: 20px; overflow-y: auto; }
.modal-close-btn { background: none; border: none; font-size: 1.5rem; cursor: pointer; color: #666; }

/* Notificações */
.notification-icon { position: relative; cursor: pointer; font-size: 1.2rem; color: #6c757d; margin-right: 15px; }
#notification-count { position: absolute; top: -5px; right: -8px; background-color: var(--danger-color); color: white; border-radius: 50%; padding: 2px 6px; font-size: 0.7rem; font-weight: bold; }
#notification-panel { position: absolute; top: 60px; right: 20px; width: 300px; max-height: 400px; overflow-y: auto; background-color: white; border: 1px solid var(--border-color); box-shadow: 0 4px 12px rgba(0,0,0,0.15); border-radius: 4px; z-index: 1000; }
#notification-panel h4 { padding: 10px 15px; margin: 0; background-color: #f8f8f8; border-bottom: 1px solid #eee; font-size: 0.9rem; }
#notification-panel ul { list-style: none; padding: 0; margin: 0; }
#notification-panel li { padding: 10px 15px; border-bottom: 1px solid #f0f0f0; font-size: 0.85rem; }

/* =========================================
   6. LOGIN (Glassmorphism)
   ========================================= */
body.login-page {
    background: linear-gradient(135deg, #0f2027 0%, #203a43 50%, #2c5364 100%);
    display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px;
}
.login-card {
    background: rgba(255, 255, 255, 0.95); backdrop-filter: blur(10px); padding: 40px 30px;
    border-radius: 16px; box-shadow: 0 15px 35px rgba(0, 0, 0, 0.4); width: 100%; max-width: 400px;
    text-align: center; border: 1px solid rgba(255, 255, 255, 0.2); position: relative; overflow: hidden;
    animation: slideUp 0.8s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.login-card::before { content: ''; position: absolute; top: 0; left: 0; width: 100%; height: 4px; background: linear-gradient(90deg, var(--primary-color), var(--info-color)); }
.login-title { font-size: 1.8rem; font-weight: 800; color: #333; margin-bottom: 5px; }
.login-subtitle { color: #666; font-size: 0.9rem; margin-bottom: 30px; }
.input-group-wrapper { position: relative; margin-bottom: 20px; text-align: left; }
.input-container { position: relative; }
.input-container i { position: absolute; left: 15px; top: 50%; transform: translateY(-50%); color: #a0a0a0; transition: color 0.3s; }
.login-card input { padding: 12px 12px 12px 45px; border-radius: 8px; background-color: #f9f9f9; border: 2px solid #e1e1e1; }
.login-card input:focus { border-color: var(--primary-color); background-color: #fff; }
.login-card input:focus + i { color: var(--primary-color); }
.btn-login { width: 100%; padding: 12px; border: none; border-radius: 8px; background: linear-gradient(135deg, var(--primary-color) 0%, #005a9e 100%); color: white; font-size: 1rem; font-weight: 700; cursor: pointer; transition: transform 0.2s, box-shadow 0.2s; margin-top: 10px; display: flex; justify-content: center; align-items: center; gap: 10px; }
.btn-login:hover { transform: translateY(-2px); box-shadow: 0 5px 15px rgba(0, 120, 212, 0.4); }
.forgot-password { margin-top: 20px; display: block; font-size: 0.85rem; color: #666; text-decoration: none; }
.forgot-password:hover { color: var(--primary-color); text-decoration: underline; }
@keyframes slideUp { from { opacity: 0; transform: translateY(30px); } to { opacity: 1; transform: translateY(0); } }

/* =========================================
   7. RESPONSIVIDADE & SIDEBAR TOGGLE (PC/Mobile)
   ========================================= */

/* Desktop: Quando sidebar está fechada */
@media (min-width: 993px) {
    body.sidebar-closed .sidebar {
        transform: translateX(-100%);
    }
    body.sidebar-closed .main-content, 
    body.sidebar-closed .top-bar {
        margin-left: 0;
        width: 100%;
    }
}

/* Mobile: Comportamento padrão */
@media (max-width: 992px) {
    .sidebar {
        transform: translateX(-100%);
        box-shadow: 5px 0 15px rgba(0,0,0,0.1);
    }
    .main-content, .top-bar {
        margin-left: 0;
        width: 100%;
    }
    /* Mobile: Quando menu está aberto */
    body.mobile-nav-active .sidebar {
        transform: translateX(0);
    }
    .charts-grid { grid-template-columns: 1fr; }
    .header-container { flex-direction: column; align-items: flex-start; gap: 10px; }
    .btn-group { width: 100%; overflow-x: auto; white-space: nowrap; padding-bottom: 5px; }
}

/* =========================================
   9. HUB DE SELEÇÃO (Cards de Setores)
   ========================================= */

.hub-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); /* Cria colunas responsivas */
    gap: 25px;
    margin-top: 30px;
}

.hub-card {
    background-color: var(--surface-color);
    padding: 40px 20px;
    border-radius: 12px;
    box-shadow: var(--shadow);
    text-decoration: none; /* Remove o sublinhado do link */
    color: var(--text-color);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
    border: 1px solid var(--border-color);
    text-align: center;
    position: relative;
    overflow: hidden;
}

/* Efeito Hover (Ao passar o mouse) */
.hub-card:hover {
    transform: translateY(-5px); /* Levanta o cartão */
    box-shadow: 0 12px 24px rgba(0,0,0,0.12);
    border-color: var(--primary-color);
}

/* Ícone do Cartão */
.hub-card i {
    font-size: 3.5rem;
    margin-bottom: 20px;
    color: var(--primary-color);
    transition: transform 0.3s ease;
}

.hub-card:hover i {
    transform: scale(1.1); /* Aumenta o ícone levemente */
}

/* Título do Cartão */
.hub-card h3 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--heading-color);
}

/* Texto de descrição (se houver) */
.hub-card p {
    margin-top: 10px;
    font-size: 0.9rem;
    color: #666;
    line-height: 1.4;
}

/* Pequeno detalhe visual no topo */
.hub-card::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: transparent;
    transition: background 0.3s;
}

.hub-card:hover::after {
    background: var(--primary-color);
}
