/* ===== RESET E VARIÁVEIS CSS ===== */
/* Reset básico para garantir consistência */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Variáveis CSS para facilitar mudanças de cores e temas */
:root {
    /* Cores principais */
    --primary-color: #3498db;
    --secondary-color: #2ecc71;
    --accent-color: #e74c3c;
    --warning-color: #f39c12;

    /* Tons de fundo */
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --bg-tertiary: #e9ecef;

    /* Textos */
    --text-primary: #2c3e50;
    --text-secondary: #6c757d;
    --text-light: #ffffff;

    /* Sombras */
    --shadow-light: 0 2px 10px rgba(0,0,0,0.1);
    --shadow-medium: 0 4px 20px rgba(0,0,0,0.15);
    --shadow-heavy: 0 8px 30px rgba(0,0,0,0.2);

    /* Bordas */
    --border-radius: 12px;
    --border-color: #dee2e6;

    /* Animações */
    --transition-fast: 0.2s ease;
    --transition-normal: 0.3s ease;
    --transition-slow: 0.5s ease;
}

/* ===== ESTILOS GERAIS ===== */
/* Estilo base do corpo da página */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--bg-primary) 100%);
    min-height: 100vh;
}

/* Container principal */
main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* ===== HEADER E NAVEGAÇÃO ===== */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 20px;
    margin-bottom: 30px;
    background: var(--bg-primary);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-light);
}

header h1 {
    font-size: 2.5em;
    background: linear-gradient(45deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: titleGlow 2s ease-in-out infinite alternate;
}

@keyframes titleGlow {
    from { filter: brightness(1); }
    to { filter: brightness(1.2); }
}

nav ul {
    display: flex;
    list-style: none;
    gap: 30px;
}

nav a {
    text-decoration: none;
    color: var(--text-primary);
    font-weight: 500;
    transition: var(--transition-fast);
    position: relative;
}

nav a:hover {
    color: var(--primary-color);
}

nav a::after {
    content: '';
    position: absolute;
    width: 0;
    height: 2px;
    bottom: -5px;
    left: 0;
    background: var(--primary-color);
    transition: var(--transition-normal);
}

nav a:hover::after {
    width: 100%;
}

/* ===== SEÇÃO PRINCIPAL ===== */
section {
    text-align: center;
    padding: 60px 20px;
    background: var(--bg-primary);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-light);
    margin-bottom: 30px;
    position: relative;
    overflow: hidden;
}

section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><circle cx="20" cy="20" r="2" fill="%233498db" opacity="0.1"/><circle cx="80" cy="40" r="1.5" fill="%232ecc71" opacity="0.1"/><circle cx="40" cy="80" r="1" fill="%23e74c3c" opacity="0.1"/></svg>');
    pointer-events: none;
}

section h2 {
    font-size: 2.2em;
    margin-bottom: 20px;
    color: var(--text-primary);
}

section p {
    font-size: 1.2em;
    color: var(--text-secondary);
    margin-bottom: 30px;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

section button {
    background: linear-gradient(45deg, var(--primary-color), var(--secondary-color));
    color: var(--text-light);
    border: none;
    padding: 15px 30px;
    font-size: 1.1em;
    border-radius: 50px;
    cursor: pointer;
    transition: var(--transition-normal);
    box-shadow: var(--shadow-light);
    position: relative;
    overflow: hidden;
}

section button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: var(--transition-slow);
}

section button:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-medium);
}

section button:hover::before {
    left: 100%;
}

/* ===== INDICADOR DE STATUS FINANCEIRO ===== */
.financial-status {
    margin-bottom: 30px;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 20px;
    background: var(--bg-primary);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-light);
    border-left: 5px solid var(--secondary-color);
    animation: slideInFromLeft 0.8s ease-out;
}

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

.status-indicator[data-status="negative"] {
    border-left-color: var(--accent-color);
}

.status-icon {
    font-size: 2em;
    animation: bounce 2s infinite;
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-10px);
    }
    60% {
        transform: translateY(-5px);
    }
}

.status-text {
    font-weight: 600;
    color: var(--text-primary);
}

/* ===== CARDS FLUTUANTES DO DASHBOARD ===== */
.dashboard-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.card {
    background: var(--bg-primary);
    padding: 25px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-light);
    text-align: center;
    transition: var(--transition-normal);
    position: relative;
    overflow: hidden;
}

.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-medium);
}

.floating-card {
    animation: float 6s ease-in-out infinite;
    opacity: 0;
    animation-fill-mode: forwards;
}

.floating-card:nth-child(1) { animation-delay: 0.1s; }
.floating-card:nth-child(2) { animation-delay: 0.2s; }
.floating-card:nth-child(3) { animation-delay: 0.3s; }

@keyframes float {
    0%, 100% {
        transform: translateY(0px);
        opacity: 1;
    }
    50% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

.card h4 {
    font-size: 1.2em;
    margin-bottom: 15px;
    color: var(--text-primary);
}

.card-value {
    font-size: 2em;
    font-weight: bold;
    color: var(--primary-color);
}

.progress-bar {
    width: 100%;
    height: 20px;
    background: var(--bg-tertiary);
    border-radius: 10px;
    overflow: hidden;
    margin-top: 10px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--secondary-color), var(--primary-color));
    width: 0%;
    transition: var(--transition-slow);
    border-radius: 10px;
}

/* ===== DICAS FINANCEIRAS ===== */
.financial-tip {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 20px;
    background: linear-gradient(135deg, #fff3cd 0%, #ffeaa7 100%);
    border: 2px solid var(--warning-color);
    border-radius: var(--border-radius);
    margin-bottom: 30px;
    animation: pulse 3s infinite;
}

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(243, 156, 18, 0.4);
    }
    50% {
        box-shadow: 0 0 0 10px rgba(243, 156, 18, 0);
    }
}

.tip-icon {
    font-size: 2.5em;
    animation: rotate 4s linear infinite;
}

@keyframes rotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.tip-content h4 {
    color: var(--text-primary);
    margin-bottom: 5px;
}

.tip-content p {
    color: var(--text-secondary);
    font-style: italic;
}

.tip-refresh {
    background: var(--warning-color);
    border: none;
    padding: 10px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2em;
    transition: var(--transition-fast);
    margin-left: auto;
}

.tip-refresh:hover {
    transform: scale(1.1);
    background: #e67e22;
}

/* ===== SELETOR DE TEMA ===== */
.theme-selector {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-bottom: 30px;
}

.theme-btn {
    padding: 12px 20px;
    border: 2px solid var(--border-color);
    background: var(--bg-primary);
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition-normal);
    font-size: 1em;
}

.theme-btn:hover {
    transform: scale(1.05);
    box-shadow: var(--shadow-light);
}

.theme-btn.active {
    border-color: var(--primary-color);
    background: var(--primary-color);
    color: var(--text-light);
}

/* ===== STREAK DE ECONOMIA ===== */
.saving-streak {
    text-align: center;
    margin-bottom: 30px;
    display: grid;
    gap: 14px;
    justify-items: center;
}

.streak-counter {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 15px 25px;
    background: linear-gradient(45deg, #ff6b6b, #ffa500);
    color: white;
    border-radius: 50px;
    box-shadow: var(--shadow-medium);
    animation: streakPulse 2s infinite;
}

@keyframes streakPulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

.flame-icon {
    font-size: 1.5em;
    animation: flameFlicker 1.5s infinite;
}

@keyframes flameFlicker {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1) rotate(5deg); }
}

#streakDays {
    font-size: 2em;
    font-weight: bold;
}

.streak-text {
    font-weight: 500;
}

.streak-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
}

.streak-btn {
    border: none;
    border-radius: 999px;
    padding: 10px 16px;
    background: var(--bg-primary);
    color: var(--text-primary);
    box-shadow: var(--shadow-light);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-fast);
}

.streak-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-medium);
}

.streak-btn--reset {
    background: var(--text-primary);
    color: var(--text-light);
}

/* ===== SALDO ATUAL ===== */
.balance {
    background: var(--bg-primary);
    padding: 30px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-light);
    text-align: center;
    margin-bottom: 30px;
    border: 3px solid var(--secondary-color);
}

.balance h3 {
    color: var(--text-primary);
    margin-bottom: 15px;
    font-size: 1.3em;
}

.balance-amount {
    font-size: 3em;
    font-weight: bold;
    color: var(--secondary-color);
    text-shadow: 2px 2px 4px rgba(0,0,0,0.1);
}

/* ===== FORMULÁRIO DE TRANSAÇÕES ===== */
.transactions-form {
    background: var(--bg-primary);
    padding: 30px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-light);
    margin-bottom: 30px;
}

.transactions-form h3 {
    text-align: center;
    margin-bottom: 25px;
    color: var(--text-primary);
}

.transactions-form form {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 15px;
    align-items: flex-end;
}

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

.field-group label {
    font-size: 0.95em;
    font-weight: 600;
    color: var(--text-primary);
}

.field-group--action {
    justify-content: flex-end;
}

.transactions-form input,
.transactions-form select {
    padding: 12px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1em;
    transition: var(--transition-fast);
    background: var(--bg-primary);
    color: var(--text-primary);
}

.transactions-form input:focus,
.transactions-form select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.transactions-form button {
    background: var(--primary-color);
    color: var(--text-light);
    border: none;
    padding: 12px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1em;
    font-weight: 600;
    transition: var(--transition-fast);
    min-height: 48px;
}

.transactions-form button:hover {
    background: #2980b9;
    transform: translateY(-1px);
}

/* ===== GRÁFICO DE DESPESAS ===== */
.expense-chart {
    background: var(--bg-primary);
    padding: 30px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-light);
    margin-bottom: 30px;
}

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

.chart-header h3 {
    margin-bottom: 8px;
    color: var(--text-primary);
}

.chart-header p {
    color: var(--text-secondary);
}

.chart-container {
    display: flex;
    align-items: flex-end;
    justify-content: flex-start;
    height: 300px;
    gap: 16px;
    overflow-x: auto;
    padding-bottom: 8px;
}

.chart-empty {
    margin-top: 20px;
    padding: 18px;
    text-align: center;
    color: var(--text-secondary);
    background: var(--bg-secondary);
    border: 1px dashed var(--border-color);
    border-radius: 12px;
}

.chart-empty[hidden] {
    display: none;
}

.chart-column {
    flex: 1;
    min-width: 90px;
    max-width: 120px;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
}

.chart-bar {
    width: 100%;
    background: linear-gradient(to top, var(--primary-color), var(--secondary-color));
    border-radius: 12px 12px 0 0;
    position: relative;
    cursor: default;
    transition: var(--transition-normal);
    min-height: 24px;
    display: flex;
    align-items: start;
    justify-content: center;
    padding-top: 10px;
}

.chart-bar:hover {
    opacity: 0.8;
    transform: scale(1.05);
}

.bar-label {
    background: rgba(44, 62, 80, 0.92);
    color: var(--text-light);
    padding: 4px 8px;
    border-radius: 999px;
    font-size: 0.8em;
    white-space: nowrap;
}

.chart-category {
    text-align: center;
    font-size: 0.9em;
    color: var(--text-secondary);
}

/* ===== LISTA DE TRANSAÇÕES ===== */
.transactions-section {
    background: var(--bg-primary);
    padding: 30px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-light);
}

.transactions-section h2 {
    text-align: center;
    margin-bottom: 20px;
    color: var(--text-primary);
}

.transactions-list {
    display: grid;
    gap: 14px;
}

.transactions-empty {
    text-align: center;
    color: var(--text-secondary);
    padding: 24px;
    background: var(--bg-secondary);
    border: 1px dashed var(--border-color);
    border-radius: 12px;
}

.transaction-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 18px 20px;
    background: var(--bg-secondary);
    border-radius: 14px;
    box-shadow: var(--shadow-light);
    animation: slideIn 0.3s ease;
}

.transaction-item--income {
    border-left: 5px solid var(--secondary-color);
}

.transaction-item--expense {
    border-left: 5px solid var(--accent-color);
}

.transaction-main {
    display: flex;
    align-items: center;
    gap: 14px;
    flex: 1;
    min-width: 0;
}

.transaction-icon {
    font-size: 1.5em;
}

.transaction-content {
    display: grid;
    gap: 8px;
    flex: 1;
    min-width: 0;
}

.transaction-topline {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: flex-start;
}

.transaction-description {
    font-size: 1em;
    color: var(--text-primary);
    word-break: break-word;
}

.transaction-value {
    font-weight: 700;
    white-space: nowrap;
}

.transaction-value--income {
    color: var(--secondary-color);
}

.transaction-value--expense {
    color: var(--accent-color);
}

.transaction-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    color: var(--text-secondary);
    font-size: 0.95em;
}

.transaction-tag,
.transaction-date {
    padding: 4px 10px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 999px;
}

.transaction-remove {
    border: none;
    background: transparent;
    color: var(--accent-color);
    font-weight: 700;
    cursor: pointer;
    padding: 10px 12px;
    border-radius: 10px;
    transition: var(--transition-fast);
}

.transaction-remove:hover {
    background: rgba(231, 76, 60, 0.1);
}

/* ===== SISTEMA DE CELEBRAÇÃO ===== */
.celebration-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
    opacity: 0;
    transition: var(--transition-normal);
}

.celebration-container.active {
    opacity: 1;
}

.confetti-piece {
    position: absolute;
    width: 10px;
    height: 10px;
    background: #ffd700;
    animation: confettiFall 3s linear infinite;
}

.confetti-piece:nth-child(1) {
    left: 10%;
    animation-delay: 0s;
    background: #ff6b6b;
}
.confetti-piece:nth-child(2) {
    left: 20%;
    animation-delay: 0.2s;
    background: #4ecdc4;
}
.confetti-piece:nth-child(3) {
    left: 30%;
    animation-delay: 0.4s;
    background: #45b7d1;
}
.confetti-piece:nth-child(4) {
    left: 40%;
    animation-delay: 0.6s;
    background: #f9ca24;
}
.confetti-piece:nth-child(5) {
    left: 50%;
    animation-delay: 0.8s;
    background: #f0932b;
}
.confetti-piece:nth-child(6) {
    left: 60%;
    animation-delay: 1s;
    background: #eb4d4b;
}
.confetti-piece:nth-child(7) {
    left: 70%;
    animation-delay: 1.2s;
    background: #6c5ce7;
}
.confetti-piece:nth-child(8) {
    left: 80%;
    animation-delay: 1.4s;
    background: #a29bfe;
}

@keyframes confettiFall {
    0% {
        top: -10px;
        transform: rotate(0deg) scale(1);
    }
    100% {
        top: 100vh;
        transform: rotate(720deg) scale(0);
    }
}

/* ===== RESPONSIVIDADE ===== */
@media (max-width: 768px) {
    main {
        padding: 15px;
    }

    header {
        flex-direction: column;
        gap: 20px;
        text-align: center;
    }

    nav ul {
        flex-wrap: wrap;
        justify-content: center;
        gap: 20px;
    }

    .dashboard-cards {
        grid-template-columns: 1fr;
    }

    .transactions-form form {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }

    .chart-container {
        height: 260px;
    }

    .transaction-item {
        flex-direction: column;
        align-items: stretch;
    }

    .transaction-topline {
        flex-direction: column;
        align-items: flex-start;
    }

    .transaction-remove {
        align-self: flex-end;
    }

    .financial-tip {
        flex-direction: column;
        text-align: center;
    }

    .theme-selector {
        flex-wrap: wrap;
    }

    .streak-actions {
        width: 100%;
    }
}

@media (max-width: 480px) {
    header h1 {
        font-size: 2em;
    }

    section h2 {
        font-size: 1.8em;
    }

    .balance-amount {
        font-size: 2.5em;
    }

    .transactions-form form {
        grid-template-columns: 1fr;
    }

    .card {
        padding: 20px;
    }

    .card-value {
        font-size: 1.8em;
    }

    .chart-container {
        height: 220px;
    }
}
