/* ===== RESET E BASE ===== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background: #f5f7fb;
    color: #1e293b;
    padding: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    -webkit-tap-highlight-color: transparent;
}

#app {
    max-width: 500px;
    width: 100%;
    background: white;
    border-radius: 28px 28px 0 0;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.08);
    padding: 24px 20px 80px;
    flex: 1;
    min-height: 100vh;
    position: relative;
}

/* ===== CABEÇALHO ===== */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.header h1 {
    font-size: 1.4rem;
    font-weight: 600;
    letter-spacing: -0.3px;
    color: #0f172a;
}

/* ===== PÁGINAS ===== */
.page {
    display: none;
    animation: fade 0.2s ease;
}

.page.active {
    display: block;
}

@keyframes fade {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ===== FORMULÁRIO ===== */
.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: #475569;
    margin-bottom: 4px;
}

.form-group select,
.form-group input {
    width: 100%;
    padding: 12px 14px;
    font-size: 1rem;
    border: 1.5px solid #e2e8f0;
    border-radius: 14px;
    background: white;
    transition: 0.2s;
    color: #0f172a;
    appearance: auto;
    -webkit-appearance: auto;
}

.form-group select:focus,
.form-group input:focus {
    outline: none;
    border-color: #1e293b;
    box-shadow: 0 0 0 3px rgba(30, 41, 59, 0.1);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.btn-save {
    width: 100%;
    padding: 14px;
    background: #1e293b;
    color: white;
    border: none;
    border-radius: 40px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: 0.15s;
    margin-top: 6px;
}

.btn-save:active {
    transform: scale(0.97);
    background: #0f172a;
}

.btn-secondary {
    background: #eef2f6;
    color: #1e293b;
    padding: 10px 18px;
    border: none;
    border-radius: 40px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: 0.15s;
}

.btn-secondary:active {
    transform: scale(0.97);
    background: #d1d9e6;
}

/* ===== HISTÓRICO (CARDS) ===== */
.list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.list-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
}

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: #94a3b8;
    font-size: 0.95rem;
}

.card-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.card-item {
    background: #f8fafc;
    border-radius: 20px;
    padding: 16px 18px;
    border: 1px solid #eef2f6;
    transition: 0.15s;
    cursor: pointer;
}

.card-item:active {
    transform: scale(0.98);
    background: #f1f5f9;
}

.card-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
    flex-wrap: wrap;
}

.card-materia {
    font-weight: 600;
    font-size: 1rem;
    color: #0f172a;
}

.card-data {
    font-size: 0.8rem;
    color: #64748b;
    background: #eef2f6;
    padding: 2px 12px;
    border-radius: 40px;
    white-space: nowrap;
}

.card-assunto {
    font-size: 0.85rem;
    color: #475569;
    margin-top: 4px;
    word-break: break-word;
}

.card-stats {
    display: flex;
    gap: 16px;
    margin-top: 10px;
    flex-wrap: wrap;
    align-items: center;
}

.card-stats span {
    font-size: 0.85rem;
    color: #334155;
    background: white;
    padding: 2px 12px;
    border-radius: 40px;
    border: 1px solid #e2e8f0;
}

.card-acerto {
    font-weight: 600;
    color: #0f172a;
    background: #d9f0e1 !important;
    border-color: #b0d9c1 !important;
}

.card-detalhes {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px dashed #d1d9e6;
    font-size: 0.85rem;
    color: #475569;
    display: none;
}

.card-detalhes.open {
    display: block;
}

.card-detalhes p {
    margin: 4px 0;
}

.btn-delete {
    background: none;
    border: none;
    color: #94a3b8;
    font-size: 0.75rem;
    text-decoration: underline;
    cursor: pointer;
    padding: 4px 0;
    margin-top: 6px;
}

.btn-delete:active {
    color: #b91c1c;
}

/* ===== DASHBOARD ===== */
.dashboard-grid {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.stat-cards {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.stat-card {
    background: #f8fafc;
    border-radius: 16px;
    padding: 14px 12px;
    text-align: center;
    border: 1px solid #eef2f6;
}

.stat-card .label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #64748b;
}

.stat-card .value {
    font-size: 1.3rem;
    font-weight: 700;
    margin-top: 4px;
    color: #0f172a;
}

.charts-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.charts-row .chart-container {
    background: #f8fafc;
    border-radius: 16px;
    padding: 12px;
    border: 1px solid #eef2f6;
}

.charts-row .chart-container h3 {
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 6px;
    color: #0f172a;
    text-align: center;
}

.charts-row .chart-container canvas {
    max-height: 150px;
    max-width: 100%;
}

/* ===== LISTA DE MATÉRIAS E ASSUNTOS ===== */
.lista-items {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.item-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f8fafc;
    padding: 10px 14px;
    border-radius: 12px;
    border: 1px solid #eef2f6;
}

.item-row .nome {
    font-weight: 500;
}

.item-row .acoes {
    display: flex;
    gap: 8px;
}

.item-row .acoes button {
    background: none;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    font-size: 0.85rem;
    padding: 4px 8px;
    border-radius: 6px;
    transition: 0.15s;
}

.item-row .acoes button:hover {
    background: #eef2f6;
}

.item-row .acoes button.excluir:hover {
    color: #b91c1c;
}

/* ===== NAVEGAÇÃO INFERIOR ===== */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    max-width: 500px;
    margin: 0 auto;
    background: white;
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 10px 12px 14px;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.06);
    border-radius: 28px 28px 0 0;
    z-index: 100;
    border-top: 1px solid #eef2f6;
    padding-bottom: env(safe-area-inset-bottom, 14px);
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: none;
    border: none;
    padding: 4px 12px;
    cursor: pointer;
    font-size: 0.7rem;
    color: #94a3b8;
    transition: 0.15s;
    gap: 2px;
    min-width: 60px;
    -webkit-tap-highlight-color: transparent;
}

.nav-item .icon {
    font-size: 1.5rem;
    line-height: 1;
}

.nav-item .label {
    font-weight: 500;
    letter-spacing: 0.3px;
}

.nav-item.active {
    color: #1e293b;
}

.nav-item.active .icon {
    transform: scale(1.05);
}

.nav-item:active {
    transform: scale(0.94);
}

/* ===== TOAST ===== */
.toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: #1e293b;
    color: white;
    padding: 12px 24px;
    border-radius: 40px;
    font-size: 0.9rem;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    max-width: 90%;
    text-align: center;
    z-index: 200;
}

.toast.show {
    opacity: 1;
    pointer-events: auto;
}

/* ===== RESPONSIVO ===== */
@media (max-width: 500px) {
    .charts-row {
        grid-template-columns: 1fr;
    }
    .charts-row .chart-container canvas {
        max-height: 180px;
    }
}

@media (max-width: 420px) {
    #app {
        padding: 16px 16px 80px;
    }
    .form-row {
        grid-template-columns: 1fr;
    }
    .header h1 {
        font-size: 1.2rem;
    }
    .stat-cards {
        grid-template-columns: 1fr 1fr;
    }
}