/* =================================== */
/* RESET E ESTILOS GERAIS (MOBILE-FIRST) */
/* =================================== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}
html, body {
    height: 100%;
}
body {
    font-family: Arial, sans-serif;
    background-color: #f4f7f6;
    color: #333;
    display: flex;
    flex-direction: column;
}

/* =================================== */
/* HEADER E LAYOUT PRINCIPAL           */
/* =================================== */
header {
    background-color: #4CAF50;
    color: white;
    padding: 0.8rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 1000;
    flex-shrink: 0;
}
.header-content {
    display: flex;
    align-items: center;
    gap: 15px;
}
header h1 {
    font-size: 1.2rem;
    margin: 0;
}
.menu-toggle-btn {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    display: block;
}
#logout-btn {
    display: none;
}
.main-wrapper {
    flex-grow: 1;
    display: flex;
    position: relative;
}
.main-wrapper::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease-in-out, visibility 0s 0.3s;
}
.main-wrapper.sidebar-open::before {
    opacity: 1;
    visibility: visible;
    transition: opacity 0.3s ease-in-out;
}

/* =================================== */
/* SIDEBAR (MOBILE-FIRST: ESCONDIDA)   */
/* =================================== */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: 250px;
    background-color: #343a40;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    transform: translateX(-100%);
    transition: transform 0.3s ease-in-out;
    z-index: 1001;
    overflow-y: auto;
}
.main-wrapper.sidebar-open .sidebar {
    transform: translateX(0);
}
.sidebar-btn {
    background-color: transparent;
    color: #f1f1f1;
    border: none;
    padding: 12px 10px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: color 0.2s, background-color 0.2s;
    width: 100%;
    margin-bottom: 10px;
    text-decoration: none;
    text-align: left;
}
.sidebar-btn:hover {
    color: #4CAF50;
}
.sidebar-btn.active {
    background-color: #4CAF50 !important;
    color: white !important;
}
.sidebar-divider {
    border: 0;
    border-top: 1px solid #555;
    margin: 1rem 0;
}
.logout-btn-sidebar {
    margin-top: auto;
    color: #f1f1f1;
}
.logout-btn-sidebar:hover {
    color: #dc3545;
}

/* =================================== */
/* CONTEÚDO PRINCIPAL                  */
/* =================================== */
.main-content {
    flex-grow: 1;
    padding: 15px;
    width: 100%;
}
.content-wrapper {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
}
section {
    background-color: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
    margin-bottom: 20px;
}
h2 {
    font-size: 1.25rem;
    color: #4CAF50;
    padding-bottom: 10px;
    border-bottom: 1px solid #eee;
    margin-bottom: 20px;
}
h3 {
    font-size: 1rem;
    color: #555;
}

/* ========================================== */
/* ESTILOS PARA OS ALERTAS (POP-UPS DE NOTIFICAÇÃO) */
/* ========================================== */
#custom-alert-container {
    position: fixed;
    top: 80px;
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 10px;
}
.custom-alert {
    padding: 15px 20px;
    color: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    font-size: 1rem;
    font-weight: 500;
    opacity: 0;
    transform: translateX(100%);
    animation: slideIn 0.5s forwards;
}
.custom-alert.success {
    background-color: #28a745;
}
.custom-alert.error {
    background-color: #dc3545;
}
@keyframes slideIn {
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* CARDS DE RESUMO */
.summary-cards {
    display: grid;
    grid-template-columns: 1fr;
    gap: 15px;
}
.card {
    display: flex;
    align-items: center;
    padding: 15px;
    border-radius: 8px;
    color: white;
}
.income-card { background-color: #28a745; }
.expense-card { background-color: #dc3545; }
.balance-card { background-color: #007bff; }
.card-icon {
    font-size: 1.8rem;
    margin-right: 15px;
}
.card-content h3 {
    color: white;
    margin-bottom: 5px;
}
.card-content p {
    margin: 0;
    font-size: 1.5rem;
    font-weight: bold;
}

/* GRÁFICOS */
.charts-container {
    display: grid;
    grid-template-columns: 1fr;
    gap: 30px;
}

/* ===== MODIFICAÇÃO AQUI ===== */
.chart-wrapper {
    position: relative;
    width: 100%;
    height: 320px; /* Altura fixa para o gráfico em telas pequenas */
    max-width: 100%;
}
/* ===== FIM DA MODIFICAÇÃO ===== */

.chart-wrapper canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}
.no-data-message {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #888;
    text-align: center;
}

/* FILTROS E TABELAS */
.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-bottom: 20px;
    align-items: center;
}
.table-container {
    overflow-x: auto;
}
table {
    width: 100%;
    border-collapse: collapse;
}
th, td {
    padding: 12px 10px;
    border-bottom: 1px solid #ddd;
    text-align: left;
    vertical-align: middle;
}
.action-btn {
    border: none;
    padding: 5px 10px;
    border-radius: 4px;
    color: white;
    cursor: pointer;
    margin-left: 5px;
}
.edit-btn { background-color: #007bff; }
.delete-btn { background-color: #dc3545; }

/* =================================== */
/* ESTILOS DOS MODAIS (JANELAS POP-UP) */
/* =================================== */
.modal {
    display: none;
    position: fixed;
    z-index: 1002;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.6);
    justify-content: center;
    align-items: center;
    padding: 15px;
}
.modal-content {
    background-color: #fefefe;
    padding: 30px;
    border-radius: 10px;
    width: 100%;
    max-width: 450px;
    text-align: center;
    position: relative;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
.modal-content .close-button {
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 1.5rem;
    cursor: pointer;
}
.form-group {
    margin-bottom: 15px;
}
.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    text-align: left;
}
.form-group input, .form-group select {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 1rem;
}
button[type="submit"] {
    background-color: #4CAF50;
    color: white;
    border: none;
    font-weight: bold;
    margin-top: 15px;
    width: 100%;
    padding: 12px 20px;
    border-radius: 8px;
    cursor: pointer;
}

/* ESTILOS PARA MODAL DE CONFIRMAÇÃO */
.modal-buttons {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 20px;
}
.confirm-btn {
    border: none;
    padding: 10px 25px;
    border-radius: 5px;
    cursor: pointer;
    color: white;
    font-weight: bold;
    font-size: 1rem;
}
.confirm-yes {
    background-color: #28a745;
}
.confirm-no {
    background-color: #dc3545;
}

/* ======================================================= */
/* ESTILOS PARA DESKTOP - LAYOUT FIXO E VISÍVEL            */
/* ======================================================= */
@media (min-width: 768px) {
    .menu-toggle-btn, .main-wrapper::before {
        display: none;
    }
    #logout-btn {
        display: block;
        background-color: #dc3545;
        color: white;
        border: none;
        padding: 10px 15px;
        border-radius: 8px;
        cursor: pointer;
        font-size: 0.9rem;
        font-weight: bold;
    }
    .logout-btn-sidebar {
        display: none;
    }
    .sidebar {
        position: static;
        height: auto;
        transform: translateX(0);
        flex-shrink: 0;
    }
    .main-wrapper {
        flex-direction: row;
        overflow-y: hidden;
    }
    .main-content {
        flex-grow: 1;
        overflow-y: auto;
        padding: 20px 30px;
    }
    .summary-cards {
        grid-template-columns: repeat(3, 1fr);
    }
    .charts-container {
        grid-template-columns: 1fr 1fr;
    }
    /* ===== MODIFICAÇÃO AQUI ===== */
    .chart-wrapper {
        height: auto; /* Reseta a altura para auto */
        aspect-ratio: 16 / 10; /* Retorna à proporção de tela mais larga para desktop */
    }
    /* ===== FIM DA MODIFICAÇÃO ===== */
    #daily-chart-section .chart-wrapper {
        max-width: 80%;
        margin: 0 auto;
    }
}
/* =================================== */
/* NOVO ESTILO DOS FILTROS E PESQUISA  */
/* =================================== */

.filters {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between; /* Separa Esquerda e Direita */
    gap: 15px;
    background-color: #fff;
    padding: 15px 0; /* Espaçamento vertical */
    border-bottom: 1px solid #f0f0f0;
    margin-bottom: 20px;
}

/* Grupo da esquerda (Datas + Categoria) */
.filters-left {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 20px;
}

.filter-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.filter-item label {
    margin-bottom: 0;
    font-size: 0.9rem;
    color: #666;
    white-space: nowrap;
}

/* Estilo dos Inputs de Data (Gerados pelo JS) */
.date-range-group input[type="date"] {
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 0.9rem;
    color: #444;
    background-color: #f9f9f9;
    outline: none;
    transition: all 0.2s;
}

.date-range-group input[type="date"]:focus {
    border-color: #4CAF50;
    background-color: #fff;
    box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.1);
}

/* Estilo do Select de Categoria (Mais bonito) */
.styled-select {
    appearance: none; /* Remove seta padrão feia */
    -webkit-appearance: none;
    background-color: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 8px 30px 8px 12px;
    font-size: 0.9rem;
    color: #333;
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23666' d='M6 8.825L1.175 4 2.238 2.938 6 6.7l3.763-3.762L10.825 4z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    min-width: 140px;
    transition: border-color 0.2s;
}

.styled-select:focus {
    border-color: #4CAF50;
    outline: none;
}

.styled-select:hover {
    border-color: #bbb;
}

/* Estilo da Caixa de Pesquisa (Pílula arredondada) */
.search-box {
    display: flex;
    align-items: center;
    background-color: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 20px; /* Borda arredondada */
    padding: 6px 15px;
    width: 100%;
    max-width: 250px;
    transition: box-shadow 0.2s, border-color 0.2s;
}

/* Em telas grandes, empurra a pesquisa para a direita se o justify-content falhar */
@media (min-width: 768px) {
    .search-box {
        margin-left: auto; 
    }
}

.search-box:focus-within {
    border-color: #4CAF50;
    box-shadow: 0 2px 8px rgba(76, 175, 80, 0.1);
}

.search-box i {
    color: #aaa;
    margin-right: 8px;
    font-size: 0.9rem;
}

.search-box input {
    border: none;
    background: transparent;
    outline: none;
    width: 100%;
    font-size: 0.95rem;
    color: #333;
}

.search-box input::placeholder {
    color: #bbb;
}