/* =================================== */
/* GESTOR DE FINANÇAS - MINIMALISTA    */
/* =================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    /* Cores Principais */
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f1f5f9;
    
    /* Cores de Texto */
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-tertiary: #94a3b8;
    
    /* Cores de Acento */
    --accent-primary: #6366f1;
    --accent-primary-light: #e0e7ff;
    --accent-success: #10b981;
    --accent-success-light: #d1fae5;
    --accent-danger: #ef4444;
    --accent-danger-light: #fee2e2;
    --accent-warning: #f59e0b;
    --accent-warning-light: #fef3c7;
    
    /* Bordas */
    --border-color: #e2e8f0;
    --border-color-light: #f1f5f9;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 20px;
    
    /* Sombras */
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.06);
    
    /* Transições */
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ----------------------------------- */
/* RESET E BASE                        */
/* ----------------------------------- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 15px; /* Tamanho base (Computador) */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    height: 100vh;
    overflow: hidden;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    display: flex;
    flex-direction: column;
}

/* Scrollbar minimalista */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-tertiary); }

/* ----------------------------------- */
/* CABEÇALHO MOBILE E MARCA SIDEBAR    */
/* ----------------------------------- */
.mobile-header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    padding: 0.875rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 14px;
    position: sticky;
    top: 0;
    z-index: 1000;
    flex-shrink: 0;
}

.sidebar-brand {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--accent-primary);
    padding-bottom: 1.5rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.menu-toggle-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0.4rem;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.menu-toggle-btn:hover { background: var(--bg-tertiary); color: var(--accent-primary); }

/* ----------------------------------- */
/* TELAS DE LOGIN / CADASTRO           */
/* ----------------------------------- */
.auth-page {
    justify-content: center;
    align-items: center;
    padding: 2rem;
    background-color: var(--bg-primary);
}

.auth-container {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    padding: 2.5rem;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 400px;
    animation: fadeIn 0.4s ease;
}

.auth-header {
    text-align: center;
    margin-bottom: 2rem;
}

.auth-icon {
    width: 56px;
    height: 56px;
    background: var(--accent-primary-light);
    color: var(--accent-primary);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    margin: 0 auto 1rem;
}

.auth-header h2 {
    color: var(--text-primary);
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.auth-header p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-top: 4px;
}

.auth-message {
    text-align: center;
    margin-top: 1rem;
    font-weight: 500;
    font-size: 0.85rem;
    padding: 0.5rem;
    border-radius: var(--radius-sm);
}
.auth-message.error { background: var(--accent-danger-light); color: var(--accent-danger); }
.auth-message.success { background: var(--accent-success-light); color: var(--accent-success); }

.auth-back-link {
    display: block;
    text-align: center;
    margin-top: 1.5rem;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    transition: var(--transition);
}
.auth-back-link:hover { color: var(--accent-primary); }

/* ----------------------------------- */
/* LAYOUT PRINCIPAL                    */
/* ----------------------------------- */
.main-wrapper { flex-grow: 1; display: flex; height: 100%; overflow: hidden; }

.sidebar-overlay {
    position: fixed; inset: 0; background: rgba(0, 0, 0, 0.3); z-index: 1001;
    opacity: 0; visibility: hidden; transition: var(--transition); pointer-events: none;
}
body.sidebar-open .sidebar-overlay { opacity: 1; visibility: visible; pointer-events: auto; }

/* ----------------------------------- */
/* SIDEBAR                             */
/* ----------------------------------- */
.sidebar {
    position: fixed; 
    top: 0; 
    left: 0; 
    height: 100%; /* CORREÇÃO: Trocado de 100vh para 100% */
    width: 240px;
    background: var(--bg-secondary); 
    border-right: 1px solid var(--border-color);
    padding: 1.25rem; 
    padding-bottom: 2rem; /* CORREÇÃO: Adicionado espaço extra pro fundo */
    display: flex; 
    flex-direction: column;
    transform: translateX(-100%); 
    transition: transform 0.3s ease; 
    z-index: 1002; 
    overflow-y: auto;
}
.main-wrapper.sidebar-open .sidebar { transform: translateX(0); }

.sidebar-btn {
    background: transparent; color: var(--text-secondary); border: none;
    padding: 0.7rem 0.875rem; border-radius: var(--radius-md); cursor: pointer;
    font-size: 0.9rem; font-weight: 500; display: flex; align-items: center;
    gap: 10px; transition: var(--transition); width: 100%; margin-bottom: 4px;
    text-decoration: none; text-align: left;
}
.sidebar-btn:hover { color: var(--text-primary); background: var(--bg-tertiary); }
.sidebar-btn.active { background: var(--accent-primary-light); color: var(--accent-primary); }
.sidebar-btn i { font-size: 1rem; width: 18px; text-align: center; }

.sidebar-divider { border: none; border-top: 1px solid var(--border-color); margin: 0.75rem 0; }
.logout-btn-sidebar { margin-top: auto; color: var(--accent-danger); }
.logout-btn-sidebar:hover { background: var(--accent-danger-light); }

/* ----------------------------------- */
/* CONTEÚDO PRINCIPAL                  */
/* ----------------------------------- */
.main-content { flex-grow: 1; padding: 1.5rem; width: 100%; height: 100%; overflow-y: auto; }
.content-wrapper { width: 100%; max-width: 1280px; margin: 0 auto; }

section { background: var(--bg-secondary); border: 1px solid var(--border-color); padding: 1.5rem; border-radius: var(--radius-lg); margin-bottom: 1.5rem; }
section h2 { font-size: 1.1rem; font-weight: 600; color: var(--text-primary); margin-bottom: 1.25rem; letter-spacing: -0.2px; }
section h3 { font-size: 0.95rem; font-weight: 500; color: var(--text-secondary); margin-bottom: 1rem; }

/* ----------------------------------- */
/* CARDS DE RESUMO                     */
/* ----------------------------------- */
.summary-cards { display: grid; grid-template-columns: 1fr; gap: 1rem; }
.card { display: flex; align-items: center; padding: 1.25rem; border-radius: var(--radius-lg); background: var(--bg-secondary); border: 1px solid var(--border-color); transition: var(--transition); }
.card:hover { border-color: var(--accent-primary); box-shadow: var(--shadow-md); }
.income-card:hover { border-color: var(--accent-success); }
.expense-card:hover { border-color: var(--accent-danger); }

.card-icon { width: 44px; height: 44px; border-radius: var(--radius-md); display: flex; align-items: center; justify-content: center; font-size: 1.1rem; margin-right: 1rem; flex-shrink: 0; }
.income-card .card-icon { background: var(--accent-success-light); color: var(--accent-success); }
.expense-card .card-icon { background: var(--accent-danger-light); color: var(--accent-danger); }
.balance-card .card-icon { background: var(--accent-primary-light); color: var(--accent-primary); }

.card-content h3 { color: var(--text-secondary); margin-bottom: 2px; font-size: 0.8rem; font-weight: 500; text-transform: uppercase; letter-spacing: 0.5px; }
.card-content p { font-size: 1.5rem; font-weight: 700; color: var(--text-primary); letter-spacing: -0.5px; }

/* ----------------------------------- */
/* GRÁFICOS                            */
/* ----------------------------------- */
.charts-container { display: grid; grid-template-columns: 1fr; gap: 1.5rem; }
.chart-block { background: var(--bg-tertiary); padding: 1.25rem; border-radius: var(--radius-md); }
.chart-wrapper { position: relative; width: 100%; height: 260px; margin-top: 0.75rem; }
.chart-wrapper canvas { position: absolute; inset: 0; width: 100% !important; height: 100% !important; }
.no-data-message { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); color: var(--text-tertiary); text-align: center; font-size: 0.9rem; }

/* ----------------------------------- */
/* FILTROS E PESQUISA                  */
/* ----------------------------------- */
.filters { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1rem; background: var(--bg-tertiary); padding: 1rem 1.25rem; border-radius: var(--radius-md); margin-bottom: 1.25rem; }
.filters-left { display: flex; flex-wrap: wrap; align-items: center; gap: 1rem; }
.filter-item label { font-size: 0.8rem; color: var(--text-secondary); margin-right: 6px; font-weight: 500; }

.filters select, .styled-select, .date-range-group input[type="date"] {
    background: var(--bg-secondary); color: var(--text-primary); border: 1px solid var(--border-color);
    border-radius: var(--radius-sm); padding: 0.5rem 0.75rem; font-size: 0.85rem; outline: none; transition: var(--transition);
}
.filters select:focus, .date-range-group input[type="date"]:focus { border-color: var(--accent-primary); }

.search-box { display: flex; align-items: center; background: var(--bg-secondary); border: 1px solid var(--border-color); border-radius: var(--radius-md); padding: 0.5rem 0.875rem; width: 100%; max-width: 240px; transition: var(--transition); }
.search-box:focus-within { border-color: var(--accent-primary); }
.search-box i { color: var(--text-tertiary); margin-right: 8px; font-size: 0.85rem; }
.search-box input { border: none; background: transparent; outline: none; width: 100%; color: var(--text-primary); font-size: 0.85rem; }
.search-box input::placeholder { color: var(--text-tertiary); }

/* ----------------------------------- */
/* TABELAS                             */
/* ----------------------------------- */
.table-container { overflow-x: auto; background: var(--bg-tertiary); border-radius: var(--radius-md); border: 1px solid var(--border-color); }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { padding: 0.875rem 1rem; text-align: left; border-bottom: 1px solid var(--border-color); color: var(--text-primary); }
th { background: var(--bg-secondary); color: var(--text-secondary); font-weight: 600; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.8px; }
tbody tr { transition: var(--transition); }
tbody tr:hover { background: rgba(99, 102, 241, 0.03); }
tbody tr:last-child td { border-bottom: none; }

.action-btn { border: none; padding: 0.4rem 0.875rem; border-radius: var(--radius-sm); cursor: pointer; margin-left: 4px; font-size: 0.75rem; font-weight: 500; transition: var(--transition); }
.edit-btn { background: var(--accent-primary-light); color: var(--accent-primary); }
.edit-btn:hover { background: var(--accent-primary); color: white; }
.delete-btn { background: var(--accent-danger-light); color: var(--accent-danger); }
.delete-btn:hover { background: var(--accent-danger); color: white; }

/* ----------------------------------- */
/* MODAIS & FORMULÁRIOS                */
/* ----------------------------------- */
.modal { display: none; position: fixed; inset: 0; z-index: 2000; background-color: rgba(0, 0, 0, 0.4); backdrop-filter: blur(4px); justify-content: center; align-items: center; padding: 1rem; animation: fadeIn 0.2s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-content { background: var(--bg-secondary); border: 1px solid var(--border-color); box-shadow: var(--shadow-lg); padding: 1.75rem; border-radius: var(--radius-xl); width: 100%; max-width: 420px; position: relative; animation: slideUp 0.25s ease; }
@keyframes slideUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

.modal-content h2 { color: var(--text-primary); text-align: center; margin-bottom: 1.5rem; font-size: 1.15rem; font-weight: 600; }
.close-button { position: absolute; top: 1rem; right: 1rem; font-size: 1.4rem; color: var(--text-tertiary); cursor: pointer; transition: var(--transition); background: none; border: none; width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; border-radius: var(--radius-sm); }
.close-button:hover { color: var(--accent-danger); background: var(--accent-danger-light); }

.form-group { margin-bottom: 1rem; }
.form-group label { display: block; margin-bottom: 0.4rem; font-weight: 500; color: var(--text-secondary); font-size: 0.85rem; text-align: left;}
.form-group input, .form-group select { width: 100%; padding: 0.65rem 0.875rem; background: var(--bg-tertiary); border: 1px solid var(--border-color); border-radius: var(--radius-sm); font-size: 0.9rem; color: var(--text-primary); transition: var(--transition); }
.form-group input:focus, .form-group select:focus { border-color: var(--accent-primary); outline: none; background: var(--bg-secondary); }

.btn-primary, button[type="submit"] { background: var(--accent-primary); color: white; border: none; font-weight: 600; font-size: 0.95rem; margin-top: 0.5rem; width: 100%; padding: 0.75rem 1rem; border-radius: var(--radius-md); cursor: pointer; transition: var(--transition); }
.btn-primary:hover, button[type="submit"]:hover { background: #4f46e5; transform: translateY(-1px); box-shadow: var(--shadow-sm); }

.modal-buttons { display: flex; justify-content: center; gap: 0.75rem; margin-top: 1.25rem; }
.confirm-btn { border: none; padding: 0.6rem 1.5rem; border-radius: var(--radius-md); cursor: pointer; color: white; font-weight: 600; font-size: 0.9rem; transition: var(--transition); }
.confirm-yes { background: var(--accent-success); } .confirm-yes:hover { background: #059669; }
.confirm-no { background: var(--accent-danger); } .confirm-no:hover { background: #dc2626; }

/* ----------------------------------- */
/* ALERTAS (TOASTS)                    */
/* ----------------------------------- */
#custom-alert-container { position: fixed; top: 70px; right: 1rem; z-index: 3000; display: flex; flex-direction: column; gap: 0.5rem; }
.custom-alert { padding: 0.875rem 1.25rem; color: white; border-radius: var(--radius-md); font-weight: 500; font-size: 0.85rem; box-shadow: var(--shadow-md); animation: slideIn 0.3s ease; display: flex; align-items: center; gap: 0.5rem; }
.custom-alert.success { background: var(--accent-success); }
.custom-alert.error { background: var(--accent-danger); }
@keyframes slideIn { 0% { transform: translateX(100%); opacity: 0; } 100% { transform: translateX(0); opacity: 1; } }

/* ========================================== */
/* ESTILIZAÇÃO DOS DROPDOWNS (CHOICES.JS)     */
/* ========================================== */
.choices { margin-bottom: 0 !important; }
.choices__inner { background-color: var(--bg-tertiary) !important; border: 1px solid var(--border-color) !important; border-radius: var(--radius-sm) !important; padding: 0.35rem 0.875rem !important; min-height: auto !important; font-size: 0.9rem !important; color: var(--text-primary) !important; box-shadow: none !important; }
.choices[data-type*="select-one"]::after { border-color: var(--text-secondary) transparent transparent transparent !important; margin-top: -2.5px !important; }
.choices[data-type*="select-one"].is-open::after { border-color: transparent transparent var(--text-secondary) transparent !important; margin-top: -7.5px !important; }
.choices__list--dropdown { background-color: var(--bg-secondary) !important; border: 1px solid var(--border-color) !important; border-radius: var(--radius-sm) !important; box-shadow: var(--shadow-lg) !important; z-index: 9999 !important; padding: 0 !important; width: auto !important; min-width: 100% !important; }
.choices__list--dropdown .choices__item { font-size: 0.9rem !important; color: var(--text-primary) !important; padding: 0.6rem 1rem !important; white-space: nowrap !important; }
.choices__list--dropdown .choices__item--selectable.is-highlighted { background-color: var(--accent-primary-light) !important; color: var(--accent-primary) !important; }

/* ----------------------------------- */
/* RESPONSIVIDADE                      */
/* ----------------------------------- */
@media (min-width: 768px) {
    .menu-toggle-btn, .mobile-header, .main-wrapper::before { display: none; }
    .sidebar { position: relative; transform: translateX(0); flex-shrink: 0; height: 100%; }
    .main-wrapper { flex-direction: row; }
    .main-content { padding: 2rem; }
    .summary-cards { grid-template-columns: repeat(3, 1fr); }
    .charts-container { grid-template-columns: 1fr 1fr; }
    .chart-wrapper { height: auto; aspect-ratio: 16 / 10; }
    #daily-chart-section .chart-wrapper { max-width: 75%; margin: 0 auto; }
    .search-box { margin-left: auto; }
}

@media (min-width: 1200px) {
    .sidebar { width: 260px; padding: 1.5rem; }
    .card-content p { font-size: 1.75rem; }
}


@media (max-width: 480px) {
    html {
        font-size: 15px; 
    }
    .mobile-header { padding: 1rem 1.25rem; }
    .main-content { padding: 1rem; }
    section { padding: 1rem; }
    .card { padding: 1rem; }
    .card-icon { width: 38px; height: 38px; font-size: 1rem; }
    .modal-content { padding: 1.25rem; }
}

/* ========================================== */
/* ESTILIZAÇÃO DO CALENDÁRIO (FLATPICKR)      */
/* ========================================== */
.flatpickr-custom-footer {
    display: flex;
    justify-content: space-between;
    padding: 10px;
    border-top: 1px solid var(--border-color);
    background: var(--bg-secondary);
    border-radius: 0 0 5px 5px;
}

.fp-btn-clear, .fp-btn-today {
    background: none;
    border: none;
    color: var(--accent-primary);
    font-weight: 600;
    cursor: pointer;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    transition: var(--transition);
}

.fp-btn-clear:hover {
    background: var(--accent-danger-light);
    color: var(--accent-danger);
}

.fp-btn-today:hover {
    background: var(--accent-primary-light);
}

/* Força o cursor pointer no calendário */
.flatpickr-calendar {
    font-family: 'Inter', sans-serif !important;
    box-shadow: var(--shadow-lg) !important;
    border: 1px solid var(--border-color) !important;
}

/* ========================================== */
/* MODAL: GERENCIAR CATEGORIAS                */
/* ========================================== */
.manage-categories-content {
    max-width: 450px;
    padding: 2rem;
}
.manage-categories-content h2 {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1.8rem;
    font-size: 1.25rem;
    color: var(--text-primary);
}
.category-form {
    display: flex;
    gap: 12px;
    margin-bottom: 28px;
    align-items: center;
}
.category-input-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0 1rem;
    height: 46px;
    transition: var(--transition);
}
.category-input-wrapper:focus-within {
    border-color: var(--accent-primary);
    background: var(--bg-secondary);
    box-shadow: 0 0 0 3px var(--accent-primary-light);
}
.category-input-wrapper i {
    color: var(--text-tertiary);
    margin-right: 10px;
    font-size: 0.9rem;
}
.category-input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 0.8rem 0;
    color: var(--text-primary);
    font-size: 0.95rem;
    outline: none;
}
button[type="submit"].btn-primary.add-category-btn {
    width: 46px;
    height: 46px;
    margin-top: 0;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    flex-shrink: 0;
    box-shadow: 0 4px 10px rgba(99, 102, 241, 0.3);
}
button[type="submit"].btn-primary.add-category-btn i {
    font-size: 1.1rem;
    margin: 0;
}
.category-table-container {
    max-height: 300px;
    overflow-y: auto;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
}
.category-table-container table {
    margin-bottom: 0;
}
.category-table-container th {
    position: sticky;
    top: 0;
    background: var(--bg-tertiary);
    z-index: 10;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
    padding: 0.8rem 1rem;
    border-bottom: 1px solid var(--border-color);
}
.category-table-container td {
    padding: 0.75rem 1rem;
    font-size: 0.95rem;
    color: var(--text-primary);
    font-weight: 500;
}
.category-table-container td .action-btn {
    margin-left: 0;
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--text-tertiary);
}
.category-table-container td .action-btn:hover {
    background: var(--accent-danger-light);
    color: var(--accent-danger);
    transform: scale(1.05);
}
.category-table-container tr:last-child td {
    border-bottom: none;
}