/* Importando Fonte Premium Outfit */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&display=swap');

:root {
    --primary-dark: #23120b;      /* Marrom café espresso profundo */
    --primary: #422a1d;           /* Marrom grão torrado médio */
    --primary-light: #6a4e3f;     /* Marrom suave café com leite */
    --accent: #b08246;            /* Bronze dourado */
    --accent-light: #e6c8a0;      /* Dourado suave/creme */
    --bg-app: #f9f6f0;            /* Fundo creme sutil */
    --bg-card: #ffffff;           /* Fundo dos cards branco */
    --text-main: #2b231f;         /* Texto principal marrom escuro */
    --text-muted: #7d726b;        /* Texto secundário/muted */
    --border-color: #ede7dc;      /* Bordas creme */
    
    /* Estados Financeiros */
    --success: #2c6e49;           /* Verde folha de café saudável */
    --success-bg: #eaf4ed;
    --danger: #b33939;            /* Vermelho cereja maduro (despesa) */
    --danger-bg: #f9eaea;
    --warning: #cc8400;           /* Ouro/Laranja para pendências */
    --warning-bg: #fff6e6;
    
    /* Medidas e Efeitos */
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 22px;
    --shadow-sm: 0 4px 6px -1px rgba(35, 18, 11, 0.05);
    --shadow: 0 10px 25px -5px rgba(35, 18, 11, 0.08);
    --shadow-lg: 0 20px 40px -10px rgba(35, 18, 11, 0.15);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-app);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding-bottom: 80px; /* Espaço para a barra de navegação no celular */
}

/* --- BARRA SUPERIOR (HEADER) --- */
header {
    background-color: var(--primary-dark);
    color: #ffffff;
    padding: calc(16px + env(safe-area-inset-top)) 24px 16px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-container img {
    width: 42px;
    height: 42px;
    border-radius: var(--radius-sm);
    border: 2px solid var(--accent);
    object-fit: cover;
}

.logo-container h1 {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, #ffffff, var(--accent-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.offline-badge {
    background-color: var(--warning);
    color: #ffffff;
    font-size: 11px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 50px;
    display: none; /* Ativado via JS se offline */
    align-items: center;
    gap: 5px;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { opacity: 0.8; }
    50% { opacity: 1; }
    100% { opacity: 0.8; }
}

/* --- ESTRUTURA PRINCIPAL --- */
.container {
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    padding: 24px 16px;
    flex-grow: 1;
}

.view-section {
    display: none; /* Controlado via JS */
    animation: fadeIn 0.4s ease-out;
}

.view-section.active {
    display: block;
}

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

/* --- ACORDES E CARD GRUPOS --- */
.dashboard-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 28px;
}

.card {
    background-color: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 24px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 5px;
    height: 100%;
    background-color: var(--primary);
}

.card.card-gasto::before { background-color: var(--danger); }
.card.card-arrecadado::before { background-color: var(--success); }
.card.card-saldo::before { background-color: var(--accent); }

.card-title {
    font-size: 14px;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.card-value {
    font-size: 32px;
    font-weight: 700;
    color: var(--text-main);
    letter-spacing: -1px;
}

/* --- ABA DUPLA (DESPESAS E HARVEST) --- */
.tabs {
    display: flex;
    gap: 8px;
    border-bottom: 2px solid var(--border-color);
    margin-bottom: 20px;
}

.tab-btn {
    background: none;
    border: none;
    padding: 12px 24px;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    position: relative;
    transition: var(--transition);
}

.tab-btn.active {
    color: var(--primary-dark);
}

.tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 100%;
    height: 3px;
    background-color: var(--primary-dark);
    border-radius: 50px;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* --- BOTÕES --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    font-size: 15px;
    font-weight: 600;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}

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

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

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

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

.btn-success {
    background-color: var(--success);
    color: #ffffff;
}

.btn-success:hover {
    background-color: #215135;
}

.btn-danger {
    background-color: var(--danger);
    color: #ffffff;
}

.btn-danger:hover {
    background-color: #8c2828;
}

.btn-icon {
    padding: 8px;
    border-radius: 50px;
}

/* --- TABELAS E AÇÕES --- */
.table-container {
    background-color: var(--bg-card);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow);
    overflow-x: auto;
    margin-bottom: 24px;
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

th {
    background-color: #faf8f5;
    padding: 16px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
}

td {
    padding: 16px;
    font-size: 15px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-main);
}

tr:last-child td {
    border-bottom: none;
}

.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 50px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-success { background-color: var(--success-bg); color: var(--success); }
.badge-danger { background-color: var(--danger-bg); color: var(--danger); }
.badge-warning { background-color: var(--warning-bg); color: var(--warning); }
.badge-info { background-color: #e6f2ff; color: #0066cc; }

.actions-cell {
    display: flex;
    gap: 8px;
}

/* --- GRÁFICOS E DESEMPENHO --- */
.charts-wrapper {
    background-color: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 24px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow);
    margin-top: 24px;
    height: 350px;
}

/* --- TELA DE RELATÓRIO --- */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    background-color: var(--bg-card);
    padding: 16px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    margin-bottom: 24px;
    align-items: center;
}

.form-group-inline {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.form-group-inline label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
}

.form-control {
    padding: 8px 12px;
    font-size: 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background-color: #ffffff;
    color: var(--text-main);
    outline: none;
    transition: var(--transition);
}

.form-control:focus {
    border-color: var(--accent);
}

.report-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
}

@media (max-width: 768px) {
    .report-grid {
        grid-template-columns: 1fr;
    }
}

.report-summary-box {
    background-color: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 24px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow);
}

.report-header {
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 16px;
    margin-bottom: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.report-line {
    display: flex;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid #f6f1e8;
    font-size: 16px;
}

.report-line.total {
    border-top: 2px solid var(--border-color);
    border-bottom: none;
    font-weight: 700;
    font-size: 20px;
    padding-top: 18px;
    color: var(--primary-dark);
}

/* --- MODAIS --- */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(35, 18, 11, 0.4);
    backdrop-filter: blur(4px);
    display: none; /* Controlado via JS */
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 16px;
    animation: fadeIn 0.2s ease-out;
}

.modal.active {
    display: flex;
}

.modal-content {
    background-color: var(--bg-card);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 500px;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
    animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

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

.modal-header {
    background-color: var(--primary-dark);
    color: #ffffff;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 18px;
    font-weight: 600;
}

.close-modal {
    background: none;
    border: none;
    color: #ffffff;
    font-size: 24px;
    cursor: pointer;
}

.modal-body {
    padding: 20px;
}

.form-field {
    margin-bottom: 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-field label {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-main);
}

.modal-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* --- BARRA DE NAVEGAÇÃO MOBILE (BOTTOM BAR) --- */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background-color: var(--primary-dark);
    display: flex;
    justify-content: space-around;
    align-items: center;
    height: 70px;
    z-index: 90;
    box-shadow: 0 -4px 10px rgba(0,0,0,0.15);
}

.nav-item {
    background: none;
    border: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 11px;
    font-weight: 500;
    gap: 4px;
    flex-grow: 1;
    height: 100%;
    transition: var(--transition);
}

.nav-item svg {
    width: 24px;
    height: 24px;
    fill: currentColor;
    transition: var(--transition);
}

.nav-item.active {
    color: var(--accent-light);
}

.nav-item.active svg {
    transform: translateY(-2px);
    color: var(--accent);
}

/* --- RESPONSIVIDADE ADICIONAL --- */
@media (min-width: 769px) {
    body {
        padding-bottom: 0;
        padding-left: 260px; /* Sidebar layout no desktop */
    }
    
    .bottom-nav {
        width: 260px;
        height: 100vh;
        left: 0;
        top: 0;
        bottom: auto;
        flex-direction: column;
        justify-content: flex-start;
        padding-top: 80px;
        gap: 10px;
    }
    
    .nav-item {
        flex-direction: row;
        justify-content: flex-start;
        padding: 16px 24px;
        gap: 16px;
        width: 100%;
        height: auto;
        font-size: 16px;
    }

    header {
        position: fixed;
        left: 260px;
        right: 0;
        top: 0;
        z-index: 95;
    }

    .container {
        margin-top: 74px; /* Espaço para a header fixa */
    }
}

/* --- PRINT MEDIA STYLES --- */
@media print {
    body {
        background-color: #ffffff;
        color: #000000;
        padding: 0;
    }
    header, .bottom-nav, .btn, .filter-bar, .actions-cell, .modal {
        display: none !important;
    }
    .container {
        margin: 0;
        padding: 0;
    }
    .view-section {
        display: block !important;
        opacity: 1 !important;
    }
    .report-summary-box {
        box-shadow: none;
        border: 1px solid #000000;
    }
}

/* --- TELA DE LOGIN PREMIUM --- */
.login-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: radial-gradient(circle at center, var(--primary) 0%, var(--primary-dark) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 20px;
}

.login-card {
    background-color: var(--bg-card);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 400px;
    padding: 40px 30px;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
    text-align: center;
    animation: slideUp 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.login-header img {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 3px solid var(--accent);
    object-fit: cover;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}

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

.login-header p {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 24px;
}

.btn-login {
    width: 100%;
    margin-top: 12px;
    font-size: 16px;
    padding: 14px;
    border-radius: var(--radius-sm);
}

.login-error {
    color: var(--danger);
    background-color: var(--danger-bg);
    border: 1px solid #f5c2c2;
    padding: 10px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    margin-bottom: 16px;
    font-weight: 600;
    text-align: center;
}

.login-footer {
    margin-top: 24px;
    color: var(--text-muted);
    font-size: 11px;
}

/* Header greeting styles */
.logo-container span {
    display: block;
    margin-top: 2px;
}

.btn-logout {
    transition: var(--transition);
}

.btn-logout:hover {
    background-color: #8c2828 !important;
}

/* --- ADAPTAÇÕES MOBILE COMPACTAS --- */
@media (max-width: 600px) {
    /* Fontes do cabeçalho */
    header {
        padding: 12px 16px;
    }
    
    .logo-container h1 {
        font-size: 18px;
    }
    
    .logo-container img {
        width: 32px;
        height: 32px;
    }
    
    /* Abas de navegação */
    .tabs {
        overflow-x: auto;
        white-space: nowrap;
        display: flex;
        gap: 4px;
        padding-bottom: 8px;
        -webkit-overflow-scrolling: touch;
        border-bottom: 2px solid var(--border-color);
    }
    
    .tab-btn {
        padding: 8px 14px;
        font-size: 13px;
        flex-shrink: 0;
    }
    
    /* Cards no Dashboard */
    .dashboard-summary {
        gap: 12px;
        margin-bottom: 16px;
    }
    
    .card {
        padding: 14px;
        border-radius: var(--radius-sm);
    }
    
    .card-title {
        font-size: 11px;
        margin-bottom: 4px;
    }
    
    .card-value {
        font-size: 20px;
    }
    
    /* Botões da Dashboard */
    .view-section button.btn-primary {
        flex-grow: 1;
        padding: 8px 12px;
        font-size: 12px;
    }
    
    /* Tabelas compactas */
    table th {
        padding: 8px 10px;
        font-size: 11px;
    }
    
    table td {
        padding: 8px 10px;
        font-size: 12px;
    }
    
    /* Botões em tabelas */
    .actions-cell .btn {
        padding: 6px 10px;
        font-size: 11px;
    }
    
    /* Navegação inferior */
    .bottom-nav {
        height: 58px;
    }
    
    .nav-item {
        font-size: 9px;
        gap: 2px;
    }
    
    .nav-item svg {
        width: 20px;
        height: 20px;
    }
    
    /* Modais */
    .modal-content {
        max-width: 95%;
        border-radius: var(--radius-md);
    }
    
    .modal-body {
        padding: 14px;
    }
    
    .modal-footer {
        padding: 10px 14px;
    }
    
    .form-field label {
        font-size: 12px;
    }
    
    .form-control {
        font-size: 13px;
        padding: 8px;
    }
    
    /* Relatórios */
    .filter-bar {
        padding: 10px;
        gap: 8px;
    }
    
    .form-group-inline {
        width: 100%;
    }
    
    .report-summary-box {
        padding: 14px;
    }
    
    .report-line {
        font-size: 13px;
        padding: 8px 0;
    }
    
    .report-line.total {
        font-size: 16px;
        padding-top: 12px;
    }
}

/* Níveis de Acesso: Ocultar botões para não-administradores */
body.not-admin .actions-cell,
body.not-admin th:last-child {
    display: none !important;
}

/* --- FOOTER DO APLICATIVO --- */
.app-footer {
    text-align: center;
    padding: 20px 16px;
    margin-top: 40px;
    border-top: 1px solid var(--border-color);
    font-size: 11px;
    color: var(--text-muted);
    background-color: var(--bg-card);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}

.app-footer p {
    margin: 4px 0;
}

.app-footer strong {
    color: var(--accent);
}

