:root {
    --bg-main: #0f172a;
    --bg-card: rgba(30, 41, 59, 0.7);
    --bg-card-hover: rgba(30, 41, 59, 0.9);
    --accent: #3b82f6;
    --accent-glow: rgba(59, 130, 246, 0.5);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --income: #10b981;
    --expense: #ef4444;
    --border: rgba(255, 255, 255, 0.1);
    --radius: 16px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    min-height: 100vh;
    padding: 2rem;
    overflow-x: hidden;
}

/* Background mesh gradient */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at 0% 0%, rgba(59, 130, 246, 0.15) 0%, transparent 50%),
                radial-gradient(circle at 100% 100%, rgba(16, 185, 129, 0.1) 0%, transparent 50%);
    z-index: -1;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
}

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

.logo {
    font-size: 1.5rem;
    font-weight: 800;
    background: linear-gradient(to right, #3b82f6, #10b981);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.025em;
}

/* Stats Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.card {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    transition: var(--transition);
}

.card:hover {
    transform: translateY(-4px);
    border-color: rgba(255, 255, 255, 0.2);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

.card-title {
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.card-value {
    font-size: 2rem;
    font-weight: 700;
}

.income-text { color: var(--income); }
.expense-text { color: var(--expense); }

/* Main Content Layout */
.main-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.5rem;
}

/* Transactions Table */
.transactions-card {
    grid-column: span 1;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.btn {
    padding: 0.625rem 1.25rem;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    border: none;
    font-size: 0.875rem;
}

.btn-primary {
    background: var(--accent);
    color: white;
}

.btn-primary:hover {
    background: #2563eb;
    box-shadow: 0 0 20px var(--accent-glow);
}

.transaction-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 0;
    border-bottom: 1px solid var(--border);
}

.transaction-item:last-child {
    border-bottom: none;
}

.transaction-info {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.category-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.05);
}

.transaction-details h4 {
    font-size: 0.9375rem;
    margin-bottom: 0.25rem;
}

.transaction-details p {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.transaction-amount {
    font-weight: 600;
    font-size: 1rem;
}

.btn-icon-delete {
    background: rgba(239, 68, 68, 0.1);
    color: var(--expense);
    border: none;
    padding: 0.5rem;
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.4;
}

.transaction-item:hover .btn-icon-delete {
    opacity: 1;
}

.btn-icon-delete:hover {
    background: var(--expense);
    color: white;
    box-shadow: 0 0 15px rgba(239, 68, 68, 0.4);
}

/* Modal Overlay */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

/* Modales de lista (Conceptos, Grupos) */
#modal-list-concepts, #modal-list-groups {
    z-index: 1100;
}

/* Modales de formulario (Nuevo Concepto, Nuevo Grupo) */
#modal-concept, #modal-group {
    z-index: 1200;
}

.modal {
    background: var(--bg-main);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 100%;
    max-width: 450px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 2rem;
    position: relative;
    animation: modalIn 0.3s ease-out;
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.95) translateY(10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.form-group {
    margin-bottom: 1.25rem;
}

label {
    display: block;
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

input, select {
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    padding: 0.75rem;
    border-radius: 10px;
    color: white;
    outline: none;
    transition: var(--transition);
    appearance: none;
    cursor: pointer;
}

select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 1rem;
    padding-right: 2.5rem;
}

input:focus, select:focus {
    border-color: var(--accent);
    background: rgba(255, 255, 255, 0.1);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

optgroup {
    background-color: #1e293b;
    color: var(--accent);
    font-weight: 700;
    font-style: normal;
    padding: 8px;
}

option {
    background-color: #1e293b;
    color: var(--text-primary);
    padding: 10px;
}

/* Animations */
.fade-in {
    animation: fadeIn 0.5s ease-out forwards;
}

/* Floating Action Button */
.fab {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 4px 20px var(--accent-glow);
    display: none; /* Solo visible en móvil */
    align-items: center;
    justify-content: center;
    border: none;
    cursor: pointer;
    z-index: 100;
}

/* Responsive */
@media (max-width: 768px) {
    body {
        padding: 1rem;
    }

    header {
        margin-bottom: 2rem;
    }

    .user-profile {
        display: none !important; /* Usar FAB en móvil */
    }

    .fab {
        display: flex;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .main-grid {
        grid-template-columns: 1fr;
    }

    .modal {
        max-width: 95%;
        margin: 1rem;
        padding: 1.5rem;
    }
}

/* Custom Bars */
.bars-container {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.bar-item {
    width: 100%;
}

.bar-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
}

.bar-label {
    font-weight: 500;
    color: var(--text-secondary);
}

.bar-value {
    font-weight: 700;
}

.bar-bg {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
    overflow: hidden;
}

.bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 1s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Urgency States */
.urgency-overdue { border-left: 4px solid var(--expense) !important; padding-left: 1rem !important; }
.urgency-soon { border-left: 4px solid #f59e0b !important; padding-left: 1rem !important; }
.urgency-upcoming { border-left: 4px solid var(--accent) !important; padding-left: 1rem !important; }

/* Quick Action Button */
.btn-quick-check {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(16, 185, 129, 0.1);
    color: var(--income);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    border: none;
}

.btn-quick-check:hover {
    background: var(--income);
    color: white;
    transform: scale(1.1);
    box-shadow: 0 0 15px rgba(16, 185, 129, 0.4);
}

/* Skeleton Animation */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.skeleton-pulse {
    animation: pulse 1.5s infinite ease-in-out;
}

.skeleton-box {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
}

/* Success Message */
.success-card {
    text-align: center;
    padding: 2rem 1rem;
    background: rgba(16, 185, 129, 0.05);
    border: 1px dashed var(--income);
    border-radius: var(--radius);
}

/* Predictive Bubbles */
.bubble {
    background: var(--bg-card);
    border: 1px solid var(--border);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.bubble:hover {
    border-color: var(--accent);
    background: rgba(59, 130, 246, 0.1);
    transform: translateY(-2px);
}

/* Quick Amount Buttons */
.btn-quick-amount {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 0.25rem 0.6rem;
    border-radius: 6px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: var(--transition);
}

.btn-quick-amount:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--text-secondary);
    color: white;
}

/* Streak Animation */
@keyframes flameScale {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); filter: drop-shadow(0 0 5px #fb923c); }
}

#streak-container i {
    animation: flameScale 2s infinite ease-in-out;
}

/* Liquid Balance Animation */
.liquid-card {
    padding: 0 !important;
    overflow: hidden;
    height: 180px;
    position: relative;
    background: #1e293b;
}

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

.liquid-wave {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 200%;
    height: 100%;
    background: linear-gradient(180deg, var(--accent) 0%, #1e40af 100%);
    opacity: 0.6;
    transition: top 1.5s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 40%;
    animation: wave 10s infinite linear;
}

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

.liquid-content {
    position: relative;
    z-index: 10;
    padding: 1.5rem;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

/* Insight Card */
.insight-card {
    cursor: grab;
    user-select: none;
    transition: transform 0.4s ease, opacity 0.4s ease;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 180px;
}

.insight-card:active {
    cursor: grabbing;
}

.insight-content h4 {
    margin-bottom: 0.5rem;
    font-size: 1rem;
}

.insight-content p {
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

.insight-footer {
    font-size: 0.65rem;
    text-align: center;
    opacity: 0.5;
}

/* Achievements */
.achievement-badge {
    min-width: 60px;
    height: 60px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: var(--transition);
}

.achievement-badge.unlocked {
    background: rgba(250, 204, 21, 0.1);
    border-color: #facc15;
    color: #facc15;
    transform: scale(1.1);
    box-shadow: 0 0 15px rgba(250, 204, 21, 0.2);
}

.achievement-badge.unlocked::after {
    content: '✓';
    position: absolute;
    bottom: -2px;
    right: -2px;
    background: var(--income);
    color: white;
    font-size: 0.6rem;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.achievement-tooltip {
    position: absolute;
    bottom: -30px;
    font-size: 0.6rem;
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.3s;
}

.achievement-badge:hover .achievement-tooltip {
    opacity: 1;
}

/* Dynamic Themes */
.theme-healthy { --accent: #10b981; --accent-glow: rgba(16, 185, 129, 0.5); }
.theme-warning { --accent: #f59e0b; --accent-glow: rgba(245, 158, 11, 0.5); }
.theme-danger { --accent: #ef4444; --accent-glow: rgba(239, 68, 68, 0.5); }

/* Daily Quests */
.quest-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.02);
    transition: var(--transition);
}

.quest-item.completed {
    opacity: 0.6;
}

.quest-item.completed i {
    color: var(--income) !important;
}

.quest-item.completed .quest-text {
    text-decoration: line-through;
    color: var(--text-secondary);
}

.quest-checkbox {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.completed .quest-checkbox {
    background: var(--income);
    border-color: var(--income);
}

.quest-text {
    font-size: 0.8rem;
    font-weight: 500;
}

.quest-xp {
    margin-left: auto;
    font-size: 0.7rem;
    color: #facc15;
    background: rgba(250, 204, 21, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
}

.mascot-wrapper:hover #mascot-tooltip {
    opacity: 1 !important;
}

#mascot-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    right: 15px;
    border: 5px solid transparent;
    border-top-color: white;
}
