/* =========================================
   1. VARIÁVEIS E RESET GLOBAL
   ========================================= */
:root {
    /* Cores do Ambiente (Mesa) */
    --desk-bg: #2C3E50;
    
    /* Cores do Papel e Texturas */
    --paper-bg: #FDFBF7;
    --paper-dots: #CCCCCC;
    
    /* Tipografia e Contraste */
    --text-primary: #111111;
    --text-secondary: #555555;
    --text-muted: #888888;
    
    /* Cores Funcionais (Semáforo Financeiro) */
    --color-expense: #C0392B;   /* Vermelho */
    --color-income: #27AE60;    /* Verde */
    --color-invest: #2980B9;    /* Azul */
    
    /* Cores das Abas Laterais */
    --tab-planner: #E67E22;     /* Laranja */
    --tab-diary: #2980B9;       /* Azul */
    
    /* Elementos de Interface */
    --color-dark: #34495E;
    --border-color: #BDC3C7;
    
    /* Fontes */
    --font-ui: 'Roboto', sans-serif;
    --font-hand: 'Patrick Hand', cursive; /* Fonte estilo manuscrito */
    
    /* Dimensões */
    --radius-std: 8px;
}

/* Reset Básico */
* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent; /* Remove flash de toque no mobile */
}

body {
    background-color: var(--desk-bg);
    margin: 0;
    font-family: var(--font-ui);
    color: var(--text-primary);
    display: flex;
    justify-content: center;
    min-height: 100vh;
    overflow-x: hidden; /* Previne rolagem horizontal durante animação 3D */
}

/* Scrollbar Bonita (WebKit) */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #CCC; border-radius: 10px; }

/* =========================================
   2. ESTRUTURA: MESA E CADERNO
   ========================================= */
.desk-container {
    width: 100%;
    max-width: 650px;
    padding: 10px;
    display: flex;
    position: relative;
    perspective: 1500px; /* Profundidade essencial para o efeito 3D */
}

.notebook-frame {
    flex-grow: 1;
    display: flex;
    min-height: 95vh;
    position: relative;
    z-index: 10;
}

/* --- ABAS LATERAIS (Estilo Fichário) --- */
.notebook-tabs {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 80px;
    margin-right: -4px; /* Encaixa levemente sob o caderno */
    z-index: 0;
}

.side-tab {
    width: 38px;
    height: 100px;
    padding: 10px 5px;
    border: none;
    border-radius: 12px 0 0 12px;
    background: #BDC3C7;
    color: #555;
    cursor: pointer;
    writing-mode: vertical-rl; /* Texto na vertical */
    text-orientation: mixed;
    font-weight: 700;
    font-size: 0.85rem;
    font-family: var(--font-ui);
    box-shadow: -3px 3px 6px rgba(0,0,0,0.2);
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.side-tab:hover { transform: translateX(-3px); }

.side-tab.active {
    width: 48px;
    color: white;
    transform: translateX(-5px);
    box-shadow: -4px 4px 8px rgba(0,0,0,0.3);
}

#tabPlanner.active { background-color: var(--tab-planner); }
#tabDiary.active { background-color: var(--tab-diary); }

/* --- ESPIRAL (ARAME REALISTA) --- */
.spiral-binding {
    width: 45px;
    flex-shrink: 0;
    background: repeating-linear-gradient(
        180deg, 
        #2c3e50 0px, #2c3e50 10px, 
        #95a5a6 10px, #ecf0f1 12px, #95a5a6 14px, 
        #2c3e50 14px, #2c3e50 25px
    );
    border-radius: 10px 0 0 10px;
    box-shadow: 5px 0 15px rgba(0,0,0,0.5);
    z-index: 20;
    position: relative;
}

/* --- PÁGINA DE PAPEL (ÁREA ANIMADA) --- */
.paper-page {
    flex-grow: 1;
    background-color: var(--paper-bg);
    padding: 20px;
    border-radius: 0 16px 16px 0;
    box-shadow: 10px 10px 30px rgba(0,0,0,0.4);
    overflow-y: auto;
    position: relative;
    
    /* Textura de Pontinhos (Dot Grid) */
    background-image: radial-gradient(var(--paper-dots) 1.5px, transparent 1.5px);
    background-size: 22px 22px;
    
    /* Configuração da Animação 3D */
    transform-origin: left center;
    backface-visibility: hidden;
    transition: transform 0.5s ease-in-out, opacity 0.5s;
}

/* Classes JS para virar a página */
.turn-out { transform: rotateY(-100deg); opacity: 0.6; pointer-events: none; }
.turn-in { animation: turnInAnim 0.6s cubic-bezier(0.4, 0, 0.2, 1) forwards; }

@keyframes turnInAnim {
    0% { transform: rotateY(-100deg); opacity: 0; }
    100% { transform: rotateY(0deg); opacity: 1; }
}

/* =========================================
   3. CABEÇALHO E NAVEGAÇÃO
   ========================================= */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 3px solid var(--color-dark);
    padding-bottom: 12px;
    margin-bottom: 20px;
}

.brand {
    font-family: var(--font-hand);
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: 1px;
}

.header-controls { display: flex; align-items: center; gap: 8px; }

/* Navegador de Mês Compacto */
.month-nav-compact {
    display: flex;
    align-items: center;
    background: #FFF;
    border: 2px solid var(--text-secondary);
    border-radius: 8px;
    padding: 2px;
}

.month-label {
    text-align: center; cursor: pointer; padding: 0 5px; min-width: 85px;
}
#displayMonth { display: block; font-weight: 900; font-size: 0.8rem; }
#displayYear { font-size: 0.75rem; color: var(--text-secondary); font-weight: 700; }

.nav-arrow {
    background: transparent; border: none; font-size: 1.2rem;
    cursor: pointer; color: var(--color-dark); padding: 2px 8px;
}
.nav-arrow:active { background: #DDD; border-radius: 4px; }

/* Botões do Topo */
.btn-tool {
    background: var(--color-dark); border: none; border-radius: 6px;
    padding: 6px 10px; cursor: pointer; font-size: 1.2rem; color: white;
    box-shadow: 2px 2px 5px rgba(0,0,0,0.2);
}
.btn-privacy {
    background: none; border: none; font-size: 1.3rem;
    cursor: pointer; padding: 0 5px;
}

/* Efeito de Borrão (Privacidade) */
.blur-value {
    color: transparent !important;
    text-shadow: 0 0 10px rgba(0,0,0,0.45);
    cursor: pointer;
    user-select: none;
}

/* Barra de Notificação */
.notification-bar {
    background: #FDEDEC; border-left: 5px solid var(--color-expense);
    color: var(--color-expense); padding: 10px; border-radius: 4px;
    margin-bottom: 15px; font-size: 0.9rem; font-weight: bold;
    display: flex; justify-content: space-between; align-items: center;
    animation: slideDown 0.4s ease-out;
}
.notification-bar button {
    background: var(--color-expense); color: white; border: none;
    padding: 4px 10px; border-radius: 4px; font-weight: bold; cursor: pointer;
}
@keyframes slideDown { from { transform: translateY(-10px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* =========================================
   4. VISÃO: PLANEJAMENTO (CHECKLIST)
   ========================================= */
.planner-summary {
    background: #FFF; border: 1px solid var(--border-color);
    padding: 12px; border-radius: var(--radius-std); margin-bottom: 20px;
}
.progress-info { display: flex; justify-content: space-between; font-weight: 700; font-size: 0.85rem; margin-bottom: 6px; color: var(--text-secondary); }
.progress-bar-container { width: 100%; height: 12px; background: #EEE; border-radius: 6px; overflow: hidden; border: 1px solid #CCC; }
.progress-bar { height: 100%; background: var(--color-income); transition: width 0.6s ease; }

.add-plan-box {
    background: #FFF; border: 2px dashed #999; padding: 15px;
    border-radius: var(--radius-std); margin-bottom: 25px;
}
.section-title { margin: 0 0 10px 0; font-size: 0.85rem; font-weight: 800; color: var(--text-muted); text-transform: uppercase; }
.add-plan-box input, .add-plan-box select {
    width: 100%; padding: 10px; margin-bottom: 10px; border: 1px solid #CCC;
    border-radius: 6px; font-family: var(--font-ui); font-size: 1rem;
}
.plan-row { display: flex; gap: 8px; }
.btn-add-plan {
    width: 100%; background: var(--color-dark); color: white; border: none;
    padding: 12px; font-weight: 700; cursor: pointer; border-radius: 6px;
}

/* Listas do Planejamento */
.checklist-container { padding-bottom: 20px; }
.check-title { margin: 20px 0 8px 0; font-size: 1rem; font-family: var(--font-hand); border-bottom: 2px solid #EEE; }
.text-red { color: var(--color-expense); } .text-green { color: var(--color-income); } .text-blue { color: var(--color-invest); }

.checklist-item {
    display: flex; align-items: center; background: rgba(255,255,255,0.8);
    padding: 10px; border-bottom: 1px solid #DDD; margin-bottom: 6px; border-radius: 6px;
}
.check-box-custom {
    width: 26px; height: 26px; border: 2px solid var(--text-secondary); border-radius: 6px;
    margin-right: 12px; display: flex; justify-content: center; align-items: center;
    cursor: pointer; background: white; flex-shrink: 0; color: transparent; font-weight: bold;
}
.check-box-custom.checked { background: var(--color-income); border-color: var(--color-income); color: white; }
.check-info { flex-grow: 1; overflow: hidden; }
.check-name { font-weight: 700; font-size: 0.95rem; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.check-meta { font-size: 0.8rem; color: var(--text-muted); }
.check-val { font-weight: 700; font-size: 0.95rem; white-space: nowrap; margin-left: 5px; }
.checklist-item.done { opacity: 0.5; }
.checklist-item.done .check-name { text-decoration: line-through; }

/* =========================================
   5. VISÃO: DIÁRIO (LANÇAMENTOS)
   ========================================= */
/* Resumo (Cards) */
.summary-box {
    display: flex; background: #FFF; border: 2px solid var(--color-dark);
    border-radius: var(--radius-std); padding: 15px 5px; margin-bottom: 10px;
}
.sum-col { flex: 1; text-align: center; }
.sum-col label { font-size: 0.7rem; font-weight: 800; text-transform: uppercase; display: block; color: var(--text-muted); margin-bottom: 4px; }
.sum-col span { font-weight: 800; font-size: 1rem; word-break: break-all; }
.sum-divider { width: 1px; background: #CCC; margin: 0 4px; }
.val-green { color: var(--color-income); } .val-red { color: var(--color-expense); } .val-blue { color: var(--color-invest); } .val-neutral { color: var(--text-primary); }

.sum-balance-row {
    text-align: center; font-weight: 700; margin-bottom: 20px; font-size: 0.95rem;
    color: var(--text-secondary); background: rgba(0,0,0,0.05); padding: 8px; border-radius: 6px;
}

/* Abas Internas */
.tabs-container { display: flex; gap: 8px; margin-bottom: 15px; }
.tab-btn {
    flex: 1; padding: 10px; border: 1px solid #CCC; border-radius: 6px;
    background: #EEE; color: #777; font-weight: 700; font-size: 0.85rem;
    cursor: pointer; transition: all 0.2s;
}
.tab-btn.active { color: white; border-color: transparent; transform: translateY(-2px); box-shadow: 0 2px 4px rgba(0,0,0,0.2); }
#btnTabExpense.active { background: var(--color-expense); }
#btnTabIncome.active { background: var(--color-income); }
#btnTabInvest.active { background: var(--color-invest); }

/* Formulário e Inputs */
.form-container { background: #FFF; border: 1px solid #CCC; padding: 15px; border-radius: var(--radius-std); margin-bottom: 25px; }
.category-grid { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 15px; }
.cat-chip {
    padding: 8px 14px; background: #F4F4F4; border: 1px solid #CCC; border-radius: 20px;
    cursor: pointer; font-size: 0.85rem; flex-grow: 1; text-align: center; min-width: 70px;
}
.cat-chip.selected { background: var(--color-dark); color: white; border-color: black; font-weight: 700; }
.cat-chip.add-btn { border-style: dashed; background: #E3F2FD; border-color: var(--color-invest); color: var(--color-invest); font-weight: bold; }

.input-group-row { display: flex; gap: 10px; margin-bottom: 10px; }
.input-wrapper { display: flex; flex-direction: column; flex: 1; }
.input-wrapper.grow { flex: 2; }
.input-wrapper label { font-size: 0.75rem; font-weight: 700; margin-bottom: 4px; color: var(--text-muted); }
input { width: 100%; padding: 12px; border: 2px solid #CCC; border-radius: 6px; font-size: 1rem; font-family: var(--font-ui); background: #FFF; }
.full-input { flex-grow: 1; }
.btn-save {
    background: var(--color-dark); color: white; border: none; padding: 0 25px;
    border-radius: 6px; font-weight: 700; cursor: pointer; font-size: 1rem;
    box-shadow: 0 3px 0 #1A252F;
}
.btn-save:active { transform: translateY(3px); box-shadow: none; }

/* Lista Histórico com Botão de Excluir */
.list-container { border-top: 3px solid var(--color-dark); padding-top: 15px; }
.list-title { font-family: var(--font-hand); font-size: 1.5rem; color: var(--text-secondary); margin-bottom: 10px; }
.hist-item {
    display: flex; justify-content: space-between; align-items: center;
    background: #FFF; border-bottom: 1px solid #E0E0E0; padding: 12px 8px;
}
.hist-date {
    background: var(--color-dark); color: white; padding: 5px 8px; border-radius: 4px;
    font-size: 0.8rem; font-weight: 700; margin-right: 12px; min-width: 45px; text-align: center;
}
.hist-info { flex-grow: 1; }
.hist-cat { font-weight: 700; font-size: 0.95rem; display: block; }
.hist-desc { font-size: 0.85rem; color: #777; }

/* Botão de Deletar no Diário */
.btn-delete {
    border: none; background: none; color: #CCC; font-weight: bold;
    font-size: 1.2rem; cursor: pointer; padding: 5px; margin-left: 10px;
}
.btn-delete:hover { color: var(--color-expense); }

/* Dica (Post-it) */
.tip-postit {
    background: #FFF9C4; color: #444; padding: 15px; margin-top: 30px; margin-bottom: 20px;
    border: 1px solid #FBC02D; box-shadow: 3px 3px 6px rgba(0,0,0,0.1);
    transform: rotate(-1deg); font-family: var(--font-hand); font-size: 1.1rem;
}

/* =========================================
   6. MODAIS E OVERLAYS
   ========================================= */
.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(44, 62, 80, 0.9); z-index: 1000;
    display: flex; justify-content: center; align-items: center;
    opacity: 0; pointer-events: none; transition: opacity 0.3s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }

.modal-card {
    background: #FFF; width: 90%; max-width: 380px; padding: 25px;
    border-radius: 12px; border: 4px solid var(--color-dark); text-align: center;
    max-height: 90vh; overflow-y: auto; box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    transform: scale(0.9); transition: transform 0.3s;
}
.modal-overlay.open .modal-card { transform: scale(1); }
.modal-card h3 { margin-top: 0; font-family: var(--font-hand); font-size: 1.8rem; color: var(--color-dark); }

.modal-section { border-bottom: 1px dashed #CCC; padding-bottom: 15px; margin-bottom: 15px; }
.modal-section h4 { margin: 0 0 10px 0; font-size: 1rem; color: var(--text-primary); }
.modal-select { width: 100%; padding: 10px; margin: 5px 0 15px 0; border: 2px solid #CCC; border-radius: 6px; font-size: 1rem; background: #FFF; }

.modal-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.btn-action {
    padding: 12px 15px; border: none; color: white; font-weight: 700;
    cursor: pointer; border-radius: 6px; font-size: 0.9rem; flex: 1; min-width: 100px;
}
.btn-action.pdf { background: var(--color-expense); }
.btn-action.csv { background: var(--color-income); }
.btn-action.backup { background: var(--color-dark); }
.btn-action.restore { background: var(--tab-planner); }
.btn-action.install { background: #27AE60; width: 100%; margin-bottom: 5px; }

.year-nav { display: flex; justify-content: center; align-items: center; gap: 20px; font-size: 1.3rem; font-weight: 700; margin-bottom: 15px; }
.month-grid-modal { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 15px; }
.m-btn { padding: 12px; border: 1px solid #CCC; cursor: pointer; font-weight: 700; background: #F5F5F5; border-radius: 4px; }
.m-btn.selected { background: var(--color-dark); color: white; border-color: black; }
.btn-cancel { background: none; border: none; text-decoration: underline; cursor: pointer; color: #777; margin-top: 10px; font-size: 1rem; }

/* =========================================
   7. RESPONSIVIDADE (MOBILE)
   ========================================= */
@media (max-width: 480px) {
    .desk-container { padding: 5px; }
    
    .notebook-tabs { margin-top: 60px; margin-right: -2px; }
    .side-tab { width: 30px; font-size: 0.75rem; height: 80px; }
    .side-tab.active { width: 38px; }
    
    .notebook-frame { min-height: 90vh; }
    .spiral-binding { width: 35px; }
    .paper-page { padding: 15px 10px; border-radius: 0 10px 10px 0; }
    
    .brand { font-size: 1.5rem; }
    .month-nav-compact { padding: 2px; }
    .month-label { width: 75px; padding: 0 2px; }
    #displayMonth { font-size: 0.75rem; }
    
    .checklist-item { flex-wrap: wrap; }
    .check-val { width: 100%; margin-left: 38px; margin-top: 5px; font-size: 0.9rem; color: #333; }
    
    .cat-chip { min-width: 60px; padding: 8px 10px; font-size: 0.8rem; }
    .modal-card { width: 95%; padding: 15px; }
}
