/* 
   [SISTEMA: Gestão Financeira Familiar]
   [VERSÃO: 1.0]
   [DETALHE: Estilo CSS premium, tema escuro glassmorphism, responsividade móvel e animações de interface]
   [HISTÓRICO: Criada folha de estilos com design system moderno e animações de transição em 04/06/2026]
*/

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap');

:root {
    --bg-gradient: radial-gradient(circle at top right, #1a153b 0%, #0d0b18 100%);
    --panel-bg: rgba(20, 17, 38, 0.6);
    --panel-border: rgba(255, 255, 255, 0.08);
    --text-primary: #ffffff;
    --text-secondary: #a0aec0;
    --text-muted: #718096;
    
    /* Cores de Destaque */
    --primary: #9d4edd;
    --primary-glow: rgba(157, 78, 221, 0.4);
    --accent: #00f2fe;
    --accent-glow: rgba(0, 242, 254, 0.3);
    --danger: #ff4d4d;
    --success: #39ff14;
    --warning: #ffb366;
    
    --font-sans: 'Outfit', sans-serif;
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --radius-lg: 20px;
    --radius-md: 12px;
    --radius-sm: 8px;
    --shadow-neon: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

/* Reset Global */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: var(--font-sans);
    -webkit-tap-highlight-color: transparent;
}

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

/* Contêiner Geral da SPA */
#app {
    width: 100%;
    max-width: 1280px;
    min-height: 100vh;
    display: grid;
    grid-template-columns: 260px 1fr;
    position: relative;
}

/* Modos de Estado (Login/Setup) */
.auth-mode #app {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

/* Scrollbar Personalizada */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.02);
}
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
}

/* BARRA LATERAL (DESKTOP) */
aside {
    background: rgba(13, 11, 24, 0.85);
    border-right: 1px solid var(--panel-border);
    backdrop-filter: blur(20px);
    display: flex;
    flex-direction: column;
    padding: 30px 20px;
    height: 100vh;
    position: sticky;
    top: 0;
    z-index: 100;
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 40px;
    padding-left: 10px;
}

.logo-icon {
    font-size: 24px;
    color: var(--accent);
    filter: drop-shadow(0 0 8px var(--accent-glow));
    animation: pulse 2s infinite alternate;
}

.logo-text {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: 0.5px;
    background: linear-gradient(to right, var(--text-primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.nav-links {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-grow: 1;
}

.nav-item a {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 14px 16px;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: var(--radius-md);
    font-weight: 500;
    transition: var(--transition-smooth);
    border: 1px solid transparent;
}

.nav-item a:hover, .nav-item.active a {
    color: var(--text-primary);
    background: var(--panel-bg);
    border-color: var(--panel-border);
    box-shadow: var(--shadow-neon);
}

.nav-item.active a {
    background: linear-gradient(135deg, rgba(157, 78, 221, 0.15) 0%, rgba(0, 242, 254, 0.05) 100%);
    border-color: rgba(157, 78, 221, 0.3);
}

.nav-item a svg {
    width: 20px;
    height: 20px;
    transition: var(--transition-smooth);
}

.nav-item:hover a svg, .nav-item.active a svg {
    transform: scale(1.1);
    color: var(--accent);
}

.user-profile-badge {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 15px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius-md);
    margin-top: auto;
}

.avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 16px;
    color: #000;
    box-shadow: 0 0 10px rgba(0, 242, 254, 0.4);
}

.user-info {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.user-name {
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}

.user-role {
    font-size: 11px;
    color: var(--text-muted);
}

.logout-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    margin-left: auto;
    transition: var(--transition-smooth);
}

.logout-btn:hover {
    color: var(--danger);
    transform: scale(1.1);
}

/* ÁREA DE CONTEÚDO PRINCIPAL */
main {
    padding: 40px;
    overflow-y: auto;
    height: 100vh;
}

.view-section {
    display: none;
    animation: fadeIn 0.4s ease-out forwards;
}

.view-section.active {
    display: block;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

header h1 {
    font-size: 28px;
    font-weight: 700;
    background: linear-gradient(to right, #fff, #a0aec0);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* CARD GLASSMORPHISM */
.card {
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    backdrop-filter: blur(16px);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-neon);
    transition: var(--transition-smooth);
    overflow: hidden;
    position: relative;
}

.card:hover {
    border-color: rgba(255, 255, 255, 0.15);
}

/* DASHBOARD LAYOUT */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-bottom: 30px;
}

.kpi-card {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.kpi-title {
    font-size: 13px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
}

.kpi-value {
    font-size: 28px;
    font-weight: 700;
}

.kpi-value.expense { color: var(--danger); }
.kpi-value.savings { color: var(--accent); }
.kpi-value.neutral { color: var(--text-primary); }

.kpi-meta {
    font-size: 12px;
    color: var(--text-muted);
}

.dashboard-charts {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
}

/* BOTÃO DE AÇÃO RÁPIDA (FLOAT E COMUM) */
.btn {
    background: linear-gradient(135deg, var(--primary) 0%, #7b2cbf 100%);
    color: var(--text-primary);
    border: none;
    padding: 12px 24px;
    font-size: 14px;
    font-weight: 600;
    border-radius: var(--radius-md);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: var(--transition-smooth);
    box-shadow: 0 4px 15px rgba(157, 78, 221, 0.4);
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(157, 78, 221, 0.6);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--panel-border);
    box-shadow: none;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    box-shadow: none;
}

.btn-danger {
    background: linear-gradient(135deg, var(--danger) 0%, #cc0000 100%);
    box-shadow: 0 4px 15px rgba(255, 77, 77, 0.4);
}

.btn-danger:hover {
    box-shadow: 0 6px 20px rgba(255, 77, 77, 0.6);
}

.float-add-btn {
    display: none; /* Ativado no Mobile */
}

/* LISTA DE TRANSAÇÕES E TABELAS */
.transactions-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 20px;
    align-items: center;
}

.filter-bar select, .filter-bar input {
    background: rgba(13, 11, 24, 0.6);
    border: 1px solid var(--panel-border);
    color: var(--text-primary);
    padding: 10px 16px;
    border-radius: var(--radius-md);
    outline: none;
    font-size: 13px;
    min-width: 140px;
    transition: var(--transition-smooth);
}

.filter-bar select:focus, .filter-bar input:focus {
    border-color: var(--primary);
}

.transaction-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 550px;
    overflow-y: auto;
    padding-right: 5px;
}

.transaction-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius-md);
    transition: var(--transition-smooth);
}

.transaction-item:hover {
    background: rgba(255, 255, 255, 0.04);
    transform: translateX(3px);
}

.transaction-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

.category-icon-wrapper {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    background: rgba(255, 255, 255, 0.05);
}

.transaction-details {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.transaction-desc {
    font-size: 15px;
    font-weight: 600;
}

.transaction-meta {
    font-size: 12px;
    color: var(--text-muted);
    display: flex;
    gap: 10px;
}

.badge {
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-user {
    background: rgba(0, 242, 254, 0.15);
    color: var(--accent);
}

.transaction-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.transaction-amount {
    font-size: 16px;
    font-weight: 700;
    color: var(--danger);
}

.delete-action {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition-smooth);
}

.delete-action:hover {
    color: var(--danger);
    transform: scale(1.1);
}

/* SOBRAS MENSAIS (Tabela e Lançamento) */
.savings-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
}

.savings-table-container {
    overflow-x: auto;
}

table.finance-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

table.finance-table th {
    padding: 14px 16px;
    border-bottom: 2px solid var(--panel-border);
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

table.finance-table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--panel-border);
    font-size: 14px;
}

table.finance-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

/* FORMULÁRIO GERAL (MODAL) */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease-out;
}

.modal-overlay.active {
    display: flex;
    opacity: 1;
}

.modal {
    background: rgba(20, 17, 38, 0.95);
    border: 1px solid var(--panel-border);
    width: 90%;
    max-width: 450px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-neon);
    animation: modalSlideUp 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--panel-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 18px;
    font-weight: 700;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 20px;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
}

.form-group input, .form-group select, .form-group textarea {
    background: rgba(13, 11, 24, 0.6);
    border: 1px solid var(--panel-border);
    color: var(--text-primary);
    padding: 12px 16px;
    border-radius: var(--radius-md);
    outline: none;
    font-size: 14px;
    transition: var(--transition-smooth);
}

.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 10px rgba(157, 78, 221, 0.2);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

/* SEÇÃO DE OBJETIVOS (METAS) */
.goals-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.goal-card {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.goal-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.goal-title {
    font-size: 16px;
    font-weight: 700;
}

.goal-date {
    font-size: 11px;
    color: var(--text-muted);
}

.goal-values {
    display: flex;
    justify-content: space-between;
    font-size: 14px;
    margin-top: 10px;
}

.goal-current {
    font-weight: 700;
    color: var(--accent);
}

.goal-target {
    font-weight: 600;
    color: var(--text-secondary);
}

.goal-progress-bar-container {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    overflow: hidden;
    margin-top: 5px;
}

.goal-progress-bar {
    height: 100%;
    background: linear-gradient(to right, var(--primary), var(--accent));
    border-radius: 10px;
    transition: width 0.8s ease-out;
}

.goal-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 10px;
}

/* CONFIGURAÇÕES / PERFIL */
.config-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

/* LOGIN / SETUP VIEW */
.auth-container {
    width: 100%;
    max-width: 400px;
    animation: fadeIn 0.5s ease-out forwards;
}

.auth-header {
    text-align: center;
    margin-bottom: 30px;
}

.auth-header h2 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 8px;
}

.auth-header p {
    font-size: 13px;
    color: var(--text-secondary);
}

/* GRÁFICO PERSONALIZADO SVG (CASO NÃO USE CHARTJS) */
.chart-container-pure {
    position: relative;
    height: 250px;
    width: 100%;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    padding-top: 20px;
    border-bottom: 1px solid var(--panel-border);
}

.chart-bar-pure-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: calc(100% / 12);
    height: 100%;
    justify-content: flex-end;
    gap: 8px;
}

.chart-bar-pure {
    width: 16px;
    background: linear-gradient(to top, var(--primary), var(--accent));
    border-top-left-radius: 4px;
    border-top-right-radius: 4px;
    transition: height 0.5s ease-out;
    position: relative;
}

.chart-bar-pure:hover::after {
    content: attr(data-value);
    position: absolute;
    top: -25px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.8);
    color: #fff;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 4px;
    white-space: nowrap;
    border: 1px solid var(--panel-border);
}

.chart-label-pure {
    font-size: 10px;
    color: var(--text-muted);
}

/* ANIMAÇÕES */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes modalSlideUp {
    from { opacity: 0; transform: translateY(50px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
    0% { filter: drop-shadow(0 0 4px var(--accent-glow)); transform: scale(1); }
    100% { filter: drop-shadow(0 0 12px var(--accent)); transform: scale(1.05); }
}

/* RESPONSIVIDADE CELULAR (MOBILE-FIRST) */
@media (max-width: 768px) {
    #app {
        grid-template-columns: 1fr;
        padding-bottom: 80px; /* Espaço para o menu inferior */
    }
    
    /* Esconder Barra Lateral lateral e transformar em menu inferior */
    aside {
        position: fixed;
        bottom: 0;
        left: 0;
        top: auto;
        width: 100%;
        height: 70px;
        flex-direction: row;
        padding: 5px 15px;
        border-right: none;
        border-top: 1px solid var(--panel-border);
        box-shadow: 0 -8px 32px 0 rgba(0, 0, 0, 0.4);
        align-items: center;
        justify-content: space-around;
        border-radius: 0;
    }
    
    .logo-container, .user-profile-badge {
        display: none;
    }
    
    .nav-links {
        flex-direction: row;
        width: 100%;
        justify-content: space-around;
        align-items: center;
        gap: 0;
    }
    
    .nav-item a {
        flex-direction: column;
        gap: 4px;
        padding: 8px 12px;
        font-size: 10px;
        align-items: center;
    }
    
    .nav-item a svg {
        width: 22px;
        height: 22px;
    }
    
    main {
        padding: 20px;
        height: calc(100vh - 70px);
    }
    
    header h1 {
        font-size: 22px;
    }
    
    .dashboard-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .dashboard-charts {
        grid-template-columns: 1fr;
    }
    
    .savings-grid, .config-container {
        grid-template-columns: 1fr;
    }
    
    /* Botão flutuante no celular */
    .float-add-btn {
        display: flex;
        position: fixed;
        bottom: 90px;
        right: 20px;
        width: 56px;
        height: 56px;
        border-radius: 50%;
        background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
        align-items: center;
        justify-content: center;
        box-shadow: 0 4px 15px rgba(157, 78, 221, 0.6);
        border: none;
        color: #fff;
        cursor: pointer;
        z-index: 99;
        transition: var(--transition-smooth);
    }
    
    .float-add-btn:active {
        transform: scale(0.9);
    }
    
    .float-add-btn svg {
        width: 24px;
        height: 24px;
    }
}
