:root {
    --primary: #2e7d32;
    --primary-light: #4caf50;
    --bg: #f5f5f5;
    --text: #333;
    --card-bg: #fff;
    --error: #d32f2f;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body {
    background-color: var(--bg);
    color: var(--text);
    display: flex;
    justify-content: center;
    min-height: 100vh;
}

#app {
    width: 100%;
    max-width: 450px; 
    padding: 20px;
    padding-bottom: 80px; /* Espaço para a barra inferior */
    transition: max-width 0.3s ease;
}

/* Responsividade para Telas Maiores (Tablets e Chromebooks) */
@media (min-width: 768px) {
    #app {
        max-width: 900px;
    }

    #tab-graphics {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 20px;
        align-items: start;
    }

    #tab-graphics .card {
        margin-top: 0 !important;
        height: 100%;
    }

    /* Gráficos de linha do tempo ocupam a largura toda */
    #tab-graphics .card:nth-child(1), /* Monthly Frequency */
    #tab-graphics .card:nth-child(2), /* Weekly Frequency */
    #tab-graphics .card:nth-child(4), /* Monthly Investment */
    #tab-graphics .card:nth-child(5), /* Past vs. Upcoming */
    #tab-graphics .card:nth-child(6), /* Average Ticket */
    #tab-graphics .card:nth-child(7)  /* Open Lessons */ {
        grid-column: span 2;
    }

    #stats-summary {
        grid-column: span 2;
    }
}

/* Navegação Inferior */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 450px;
    background: white;
    display: flex;
    justify-content: space-around;
    padding: 10px 0;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
    z-index: 100;
}

.nav-item {
    background: none;
    border: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    color: #888;
    cursor: pointer;
    flex: 1;
}

.nav-item .icon { font-size: 1.4rem; }
.nav-item .label { font-size: 0.75rem; font-weight: 500; }

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

/* Estatísticas */
.stats-card {
    background: var(--primary);
    color: white;
    padding: 20px;
    border-radius: 12px;
    margin-top: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.stats-row {
    display: flex;
    justify-content: space-between;
    font-size: 1.1rem;
}

.stats-val { font-weight: 700; }

.chart-container {
    position: relative;
    height: 250px;
    width: 100%;
    margin-top: 10px;
}

/* Toast Notifications */
#toast-container {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    width: 90%;
    max-width: 400px;
}

.toast {
    background: #333;
    color: white;
    padding: 16px 24px;
    border-radius: 8px;
    margin-bottom: 10px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    display: flex;
    justify-content: space-between;
    align-items: center;
    animation: slideDown 0.3s ease-out;
}

.toast.success { background: var(--primary); }
.toast.error { background: var(--error); }
.toast.warning { background: #fbc02d; color: #333; }

@keyframes slideDown {
    from { transform: translateY(-100%); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.screen {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.hidden {
    display: none !important;
}

.card {
    background: var(--card-bg);
    padding: 24px;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    width: 100%;
}

h2 { font-size: 1.5rem; margin-bottom: 0; }
.card h2 { margin-bottom: 15px; }
h3 { margin-bottom: 10px; color: #666; font-size: 1.1rem; }

.form-group {
    margin-bottom: 20px;
    position: relative;
}

.password-container {
    position: relative;
    width: 100%;
}

.toggle-password {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    cursor: pointer;
    user-select: none;
    font-size: 1.2rem;
    z-index: 10;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    font-size: 0.9rem;
}

input {
    width: 100%;
    padding: 14px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 1rem;
    -webkit-appearance: none;
}

input[type="checkbox"] {
    width: auto;
    padding: 0;
    -webkit-appearance: checkbox;
    appearance: checkbox;
}

input:focus {
    border-color: var(--primary);
    outline: none;
    box-shadow: 0 0 0 2px rgba(46, 125, 50, 0.2);
}

.btn-primary {
    width: 100%;
    padding: 16px;
    background-color: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-primary:active {
    background-color: #1b5e20;
}

.btn-text {
    background: none;
    border: none;
    color: var(--primary);
    font-weight: 600;
    padding: 5px;
    cursor: pointer;
}

.error {
    color: var(--error);
    font-size: 0.85rem;
    margin-top: 10px;
}

/* Lista de Aulas */
.history-section {
    margin-top: 10px;
}

/* Tabela de Registros Estilo Excel */
.records-table {
    width: 100%;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    border-collapse: collapse;
    font-size: 0.85rem;
}

.records-header {
    background: #f0f0f0;
    font-weight: 700;
    color: #555;
    border-bottom: 2px solid #ddd;
}

.record-row {
    display: grid;
    grid-template-columns: 130px 1fr 90px 140px;
    align-items: center;
    border-bottom: 1px solid #eee;
}

.record-row:last-child { border-bottom: none; }
.record-row:nth-child(even) { background-color: #fafafa; }

.record-cell {
    padding: 12px 8px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cell-date { font-weight: 500; }
.cell-details { color: #777; font-size: 0.75rem; }
.cell-total { font-weight: 700; color: var(--primary); text-align: right; }
.cell-actions { text-align: right; display: flex; justify-content: flex-end; }

.btn-icon {
    font-size: 1rem;
    padding: 4px;
}

.btn-edit { color: #1976d2; }
.btn-delete { color: var(--error); }

.editing-mode {
    border: 2px solid var(--primary);
    background-color: #e8f5e9;
}

#tab-bulk {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    gap: 20px;
}

#tab-bulk .card {
    width: 100%;
    max-width: 500px; /* Mantém os filtros centralizados e não muito largos */
    margin-left: auto;
    margin-right: auto;
}

/* A tabela de preview pode ser mais larga em telas maiores */
#tab-bulk .card:has(.full-table) {
    max-width: 100%;
}

/* Ajustes para Tablets (10 polegadas+) e Desktops */
@media (min-width: 768px) {
    #tab-bulk {
        padding: 20px;
    }
    
    #tab-bulk .card {
        max-width: 600px;
    }

    #tab-bulk .card:has(.full-table) {
        max-width: 95%;
    }
}

.btn-cancel {
    margin-top: 10px;
    background-color: #9e9e9e;
}

/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.modal-content {
    width: 90%;
    max-width: 400px;
}

.btn-pay { color: #43a047; }

/* Full Table Styles (RegTab) */
.full-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
    background: white;
}

.full-table th, .full-table td {
    border: 1px solid #ddd;
    padding: 8px;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: clip; /* Corta a palavra sem adicionar reticências */
}

/* Ajusta largura da coluna ID */
.full-table th:nth-child(1), .full-table td:nth-child(1) { width: 35px; }

/* Ajuste específico para a Bulk Table que tem checkbox na frente */
.bulk-table th:nth-child(1), .bulk-table td:nth-child(1) { 
    width: 30px; 
    min-width: 30px;
    text-align: center; 
    overflow: visible;
}
.bulk-table th:nth-child(2), .bulk-table td:nth-child(2) { width: 35px; } /* ID */
.bulk-table th:nth-child(3), .bulk-table td:nth-child(3) { width: 100px; } /* Date */

/* Ajusta largura da coluna data */
.full-table:not(.bulk-table) th:nth-child(2), .full-table:not(.bulk-table) td:nth-child(2) { width: 100px; }

/* Ajusta largura da coluna Time */
.full-table th:nth-child(3), .full-table td:nth-child(3) { width: 68px; }

/* Ajusta largura da coluna Dur */
.full-table th:nth-child(4), .full-table td:nth-child(4) { width: 50px; }

/* Ajusta as colunas restantes (5 a 14) reduzindo aproximadamente 10% */
.full-table th:nth-child(5), .full-table td:nth-child(5) { width: 63px; }  /* Rate */
.full-table th:nth-child(6), .full-table td:nth-child(6) { width: 72px; }  /* Total */
.full-table th:nth-child(7), .full-table td:nth-child(7) { width: 90px; }  /* Name */
.full-table th:nth-child(8), .full-table td:nth-child(8) { width: 36px; }  /* Mod */
.full-table th:nth-child(9), .full-table td:nth-child(9) { width: 54px; }  /* Peak */
.full-table th:nth-child(10), .full-table td:nth-child(10) { width: 54px; }  /* Type */
.full-table th:nth-child(11), .full-table td:nth-child(11) { width: 45px; } /* Play */
.full-table th:nth-child(12), .full-table td:nth-child(12) { width: 81px; } /* Method */
.full-table th:nth-child(13), .full-table td:nth-child(13) { width: 63px; } /* Status */
.full-table th:nth-child(14), .full-table td:nth-child(14) { width: 60px; } /* Sess */
.full-table th:nth-child(15), .full-table td:nth-child(15) { width: 54px; } /* Exc */

/* A última coluna (Note) ocupa o resto */
.full-table th:nth-child(16), .full-table td:nth-child(16) {
    width: auto;
}



.full-table th {
    background-color: #f4f4f4;
    cursor: pointer;
    position: sticky;
    top: 0;
    user-select: none;
    white-space: nowrap;
}

.full-table th:hover {
    background-color: #e0e0e0;
}

.full-table tr:nth-child(even) {
    background-color: #fafafa;
}

.full-table tr:hover {
    background-color: #f1f1f1;
}


/* Telas Grandes (Laptops/Desktops 13"+) */
@media (min-width: 1200px) {
    #app {
        max-width: 900px; /* Tamanho de Tablet padrão para o app */
        margin-left: auto;
        margin-right: auto;
    }

    /* Somente o RegTab e Bulk podem expandir para a largura total */
    body:has(.nav-item[data-tab="regtab"].active) #app,
    body:has(.nav-item[data-tab="bulk"].active) #app {
        max-width: 98%;
    }

    .bottom-nav {
        max-width: 600px; /* Mantém a navegação centralizada */
    }
}

/* Destaque para o campo Nome na tela de Insert */
#name {
    color: var(--primary);
    font-weight: 700;
    font-size: 1.1rem;
    border: 2px solid rgba(46, 125, 50, 0.3);
}

#name::placeholder {
    font-weight: 400;
    color: #bbb;
}

/* Destaque para o rótulo do campo Nome */
label[for="name"] {
    color: var(--primary);
    font-weight: 700;
    font-size: 1rem;
}
.version-info { text-align: center; font-size: 0.7rem; color: #aaa; margin-top: 30px; padding-bottom: 20px; font-style: italic; }
.loading-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); display: flex; justify-content: center; align-items: center; z-index: 9999; color: white; font-weight: bold; font-size: 1.2rem; flex-direction: column; gap: 15px; }
