/* Global Styles */
:root {
    --primary-color: #003366;
    /* Azul Marinho Institucional */
    --secondary-color: #00AE9D;
    /* Verde Sicoob / Ação */
    --accent-color: #E0F2F1;
    /* Verde Pastel (Fundo Suave) */
    --text-primary: #333333;
    /* Cinza Escuro (Quase Preto) */
    --text-secondary: #666666;
    /* Cinza Médio */
    --bg-color: #F4F4F4;
    /* Cinza Power BI (Fundo de Relatório) */
    --card-bg: #FFFFFF;
    --success-color: #00AE9D;
    /* Verde Sicoob */
    --warning-color: #F39C12;
    /* Laranja Alerta */
    --danger-color: #D32F2F;
    --primary-color: #C62828;
    /* Renaforte Red */
    --primary-dark: #8E1C1C;
    --text-color: #333333;
    --bg-color: #f4f4f4;
    --white: #ffffff;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    --font-family: 'Inter', sans-serif;
    --sidebar-width: 250px;
    --header-height: 60px;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24);
    /* Sombra Material/BI */
    --shadow-md: 0 3px 6px rgba(0, 0, 0, 0.16), 0 3px 6px rgba(0, 0, 0, 0.23);
}

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

body {
    font-family: var(--font-family);
    background-color: var(--bg-color);
    margin: 0;
    padding: 0;
    color: var(--text-color);
    overflow-x: hidden;
}

/* Layout */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background-color: #1B1A19;
    /* Power BI Dark Theme Sidebar */
    color: #ffffff;
    display: flex;
    flex-direction: column;
    padding: 0;
    position: fixed;
    height: 100vh;
    z-index: 100;
    box-shadow: 2px 0 5px rgba(0, 0, 0, 0.1);
}

.brand {
    padding: 20px;
    background-color: #000000;
    /* Header Sidebar - Preto ou Azul Muito Escuro */
    text-align: center;
    border-bottom: 1px solid #333;
}

.brand-logo {
    max-width: 140px;
    height: auto;
    background-color: white;
    padding: 8px;
    border-radius: 4px;
}

.nav-menu {
    flex: 1;
    padding-top: 10px;
    display: flex;
    flex-direction: column;
}

.nav-item {
    background: transparent;
    border: none;
    color: #EAEAEA;
    padding: 15px 20px;
    text-align: left;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 15px;
    font-size: 14px;
    transition: all 0.2s;
    width: 100%;
    border-left: 4px solid transparent;
}

.nav-item:hover {
    background-color: #333333;
    color: #ffffff;
}

.nav-item.active {
    background-color: #252423;
    color: #ffffff;
    border-left: 4px solid var(--secondary-color);
    /* Destaque Verde */
    font-weight: 600;
}

.nav-item .material-icons-round {
    font-size: 20px;
    color: #ccc;
}

.nav-item.active .material-icons-round {
    color: var(--secondary-color);
}

.user-profile {
    padding: 20px;
    background-color: #252423;
    display: flex;
    align-items: center;
    gap: 12px;
    border-top: 1px solid #333;
}

.avatar {
    width: 32px;
    height: 32px;
    background-color: var(--secondary-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: white;
    font-size: 14px;
}

.info .name {
    font-size: 13px;
    font-weight: 600;
    color: #fff;
}

.info .role {
    font-size: 11px;
    color: #aaa;
}

/* Main Content */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    padding: 30px;
    /* Mais espaço interno */
    width: calc(100% - var(--sidebar-width));
}

/* Header */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    background-color: var(--card-bg);
    padding: 15px 25px;
    border-radius: 2px;
    /* Cantos menos arredondados (Business Style) */
    box-shadow: var(--shadow-sm);
    border-top: 3px solid var(--primary-color);
    /* Detalhe visual Power BI */
}

.top-bar h2 {
    font-size: 20px;
    font-weight: 600;
    color: var(--primary-color);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.actions {
    display: flex;
    gap: 10px;
}

/* Buttons */
.btn {
    padding: 8px 20px;
    border: none;
    border-radius: 2px;
    cursor: pointer;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    transition: all 0.2s;
    text-transform: uppercase;
    /* Estilo botão BI */
    letter-spacing: 0.5px;
}

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

.btn-primary:hover {
    background-color: #002244;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.btn-secondary {
    background-color: #ffffff;
    color: var(--text-primary);
    border: 1px solid #ddd;
}

.btn-secondary:hover {
    background-color: #f9f9f9;
    border-color: #ccc;
}

/* Filter Bar (New) */
.filter-bar {
    display: flex;
    gap: 20px;
    margin-bottom: 25px;
    background-color: var(--card-bg);
    /* Fundo branco ou claro */
    padding: 15px 25px;
    border-radius: 2px;
    box-shadow: var(--shadow-sm);
    flex-wrap: wrap;
    align-items: center;
    border-left: 4px solid var(--secondary-color);
    /* Marcador visual */
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.filter-group label {
    font-size: 11px;
    color: var(--text-secondary);
    font-weight: 700;
    text-transform: uppercase;
}

.filter-select {
    padding: 8px 12px;
    border: 1px solid #ccc;
    border-radius: 2px;
    font-family: var(--font-family);
    min-width: 180px;
    font-size: 13px;
    color: var(--text-primary);
    background-color: #fff;
}

.filter-select:focus {
    border-color: var(--primary-color);
    outline: none;
}

/* Dashboard Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 25px;
    margin-bottom: 30px;
}

.stat-card {
    background: var(--card-bg);
    padding: 20px;
    border-radius: 2px;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 130px;
    position: relative;
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* Faixa colorida superior (Estilo Power BI Card) */
.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
}

.stat-card.blue::before {
    background-color: var(--primary-color);
}

.stat-card.green::before {
    background-color: var(--secondary-color);
}

.stat-card.orange::before {
    background-color: var(--warning-color);
}

.stat-card.purple::before {
    background-color: #6A1B9A;
}

.stat-header {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-secondary);
    font-size: 12px;
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.stat-header .material-icons-round {
    font-size: 18px;
    color: #888;
    /* Ícone discreto */
}

/* Destaque de cor no ícone opcional */
.stat-card.blue .stat-header .material-icons-round {
    color: var(--primary-color);
}

.stat-card.green .stat-header .material-icons-round {
    color: var(--secondary-color);
}

.stat-value {
    font-size: 32px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 10px 0;
}

.stat-subtext {
    font-size: 11px;
    color: #999;
}

/* Charts */
.chart-container-wrapper {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 25px;
    margin-bottom: 40px;
}

.chart-card {
    background: var(--card-bg);
    padding: 20px;
    border-radius: 2px;
    box-shadow: var(--shadow-sm);
    height: 420px;
    display: flex;
    flex-direction: column;
}

.chart-card h3 {
    font-size: 15px;
    color: var(--primary-color);
    margin-bottom: 20px;
    font-weight: 700;
    text-transform: uppercase;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
}

.chart-box {
    position: relative;
    flex: 1;
    /* Ocupa o resto do espaço */
    width: 100%;
}

/* Table */
.table-card {
    background: var(--card-bg);
    padding: 20px;
    border-radius: 2px;
    box-shadow: var(--shadow-sm);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.data-table th,
.data-table td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid #eee;
}

.data-table th {
    background-color: #f7f7f7;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    font-size: 12px;
    border-top: 1px solid #eee;
}

.data-table tr:hover {
    background-color: #fcfcfc;
}

.search-box {
    display: flex;
    align-items: center;
    background: #ffffff;
    border: 1px solid #ccc;
    border-radius: 2px;
    padding: 5px 10px;
    width: 300px;
    margin-bottom: 15px;
}

.search-box input {
    border: none;
    outline: none;
    padding: 5px;
    flex: 1;
    font-family: var(--font-family);
    font-size: 13px;
}

.search-box .material-icons-round {
    color: #888;
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    /* Fundo escuro BI */
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal {
    background: white;
    padding: 24px;
    border-radius: 2px;
    width: 500px;
    box-shadow: var(--shadow-md);
    border-top: 4px solid var(--secondary-color);
}

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

.modal-header h3 {
    color: var(--primary-color);
    font-size: 18px;
}

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

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    font-size: 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 2px;
    font-family: var(--font-family);
    font-size: 13px;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
}

/* Footer */
.app-footer {
    text-align: center;
    margin-top: 40px;
    color: #999;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.qty-input {
    width: 80px;
    padding: 4px;
    text-align: right;
    border: 1px solid transparent;
    background: transparent;
    font-weight: 600;
    color: var(--text-primary);
}

.qty-input:hover,
.qty-input:focus {
    border: 1px solid #ccc;
    background: white;
}

.action-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: #888;
    padding: 4px;
    transition: color 0.2s;
}

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

/* Responsive */
@media (max-width: 900px) {
    .app-container {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        height: auto;
        position: relative;
        z-index: 1000;
        /* Ensure it stays on top if needed */
    }
    
    .nav-menu {
        flex-direction: row;
        overflow-x: auto;
        padding-bottom: 0;
        /* Remove extra padding if present */
    }
    
    .nav-item {
        flex: 1;
        padding: 15px 10px;
        justify-content: center;
        text-align: center;
        white-space: nowrap;
        border-left: none;
        border-bottom: 4px solid transparent;
    }

    .nav-item.active {
        border-left: none;
        border-bottom: 4px solid var(--secondary-color);
    }

    /* Hide text on very small screens if needed, or adjust */
    .nav-item span.material-icons-round {
        margin-right: 5px;
    }

    .user-profile {
        display: none; /* Hide profile in top/sidebar on mobile to save space, or move it */
    }

    .main-content {
        margin-left: 0;
        width: 100%;
        padding: 15px;
        margin-top: 0;
    }

    .stats-grid {
        grid-template-columns: 1fr; /* Stack cards */
    }

    .chart-container-wrapper {
        grid-template-columns: 1fr;
    }

    .filter-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 15px;
    }

    .filter-group {
        width: 100%;
    }
    
    .filter-select {
        width: 100%;
        min-width: unset; /* Let it fill the container */
    }
    
    .top-bar {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }
    
    .actions {
        width: 100%;
        flex-wrap: wrap;
        justify-content: flex-start;
    }

    .actions .btn {
        flex: 1;
        justify-content: center;
        white-space: nowrap;
    }
}

@media (max-width: 600px) {
    .modal {
        width: 95%;
        margin: 10px;
        max-height: 90vh;
        overflow-y: auto;
    }

    .search-box {
        width: 100%;
    }

    .data-table {
        min-width: 600px; /* Ensure table doesn't squash comfortably */
    }
    
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .login-container {
        padding: 15px;
    }
    
    .login-card {
        padding: 25px 20px;
    }
}