/* =========================================
   1. CONFIGURACIÓN Y VARIABLES (Kakebo Theme)
   ========================================= */
@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700;800&family=Playfair+Display:ital,wght@0,600;0,700;1,600&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Great+Vibes&family=Nunito:wght@400;600;700;800&family=Playfair+Display:ital,wght@0,600;0,700;1,600&display=swap');

html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow-x: hidden;
}

:root {
    /* Paleta de Colores Coquette / Pastel */
    --bg-color: #FDF6F6;          /* Crema Rosado muy suave */
    --card-bg: #FFFFFF;           /* Blanco Puro */
    --primary-pink: #E8B4B8;      /* Rosa Principal */
    --primary-accent: #D48C94;    /* Rosa Oscuro (Acciones) */
    --secondary-cream: #FDF0E0;   /* Crema secundario */
    --text-brown: #5D4037;        /* Café (Texto Principal) */
    --text-light: #9E8882;        /* Café suave (Subtítulos) */
    --success-color: #A3C9A8;     /* Verde Salvia */
    --danger-color: #E69AB0;      /* Rojo Rosado */
    --border-soft: #F2E2E2;       /* Bordes sutiles */

    /* Sombras Suaves */
    --shadow-soft: 0 8px 24px rgba(149, 117, 117, 0.08);
    --shadow-hover: 0 12px 30px rgba(149, 117, 117, 0.15);
    --shadow-nav: 0 10px 40px rgba(93, 64, 55, 0.1);

    /* Radios */
    --radius-xl: 30px;
    --radius-lg: 20px;
    --radius-pill: 50px;
}

/* Patrón de Rosas SVG (Inline para no cargar imágenes externas) */
.floral-pattern {
    background-color: var(--bg-color);
    background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23E8B4B8' fill-opacity='0.15'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3Cpath d='M36 34c-2.2 0-4-1.8-4-4s1.8-4 4-4 4 1.8 4 4-1.8 4-4 4zm0-30c-2.2 0-4-1.8-4-4s1.8-4 4-4 4 1.8 4 4-1.8 4-4 4zM6 34c-2.2 0-4-1.8-4-4s1.8-4 4-4 4 1.8 4 4-1.8 4-4 4zM6 4C3.8 4 2 2.2 2 0s1.8-4 4-4 4 1.8 4 4-1.8 4-4 4z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
    font-family: 'Nunito', sans-serif;
    color: var(--text-brown);
    margin: 0;
    min-height: 100vh;
    padding-bottom: 100px;
}

/* Aplicamos el fondo floral al body */
body {
    background-color: var(--bg-color);
    background-image: url("data:image/svg+xml,%3Csvg width='52' height='52' viewBox='0 0 52 52' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23E8B4B8' fill-opacity='0.15'%3E%3Cpath d='M10 10c0-2.21-1.79-4-4-4-3.314 0-6-2.686-6-6h2c0 2.21 1.79 4 4 4 3.314 0 6 2.686 6 6 0 2.21 1.79 4 4 4 3.314 0 6 2.686 6 6 0 2.21 1.79 4 4 4v2c-2.21 0-4-1.79-4-4 0-3.314-2.686-6-6-6-2.21 0-4-1.79-4-4-3.314 0-6-2.686-6-6-2.21 0-4-1.79-4-4z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

h1, h2, h3, h4 {
    font-family: 'Playfair Display', serif;
    color: var(--text-brown);
    margin: 0;
    font-weight: 700;
}

.kakebo-font {
    font-family: 'Great Vibes', cursive;
    font-size: 3.5rem !important;
    font-weight: 400;
    margin-bottom: 0;
    line-height: 1.2;
}

/* =========================================
   2. LAYOUT RESPONSIVE
   ========================================= */
.container {
    width: 100%;
    margin: 0 auto;
    padding: 1.5rem;
    max-width: 100%;
}

@media (min-width: 768px) {
    .container { max-width: 720px; padding-top: 3rem; }
}

@media (min-width: 1024px) {
    .container {
        max-width: 1000px;
        padding-left: 120px;
        padding-bottom: 2rem;
    }
}

/* =========================================
   3. COMPONENTES UI
   ========================================= */

/* Header */
.app-header {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 2rem;
    padding-top: 10px;
}

.header-text {
    text-align: center;
}
.header-text h1 { font-size: 3.5rem; letter-spacing: -0.5px; margin-bottom: 5px; }
.header-text p { color: var(--text-light); font-size: 0.9rem; }

/* Botón Salir (Header) */
.logout-btn-header {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    background: white;
    border: 1px solid var(--border-soft);
    color: var(--primary-accent);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--shadow-soft);
    transition: all 0.2s;
}
.logout-btn-header:hover { transform: scale(1.05); color: var(--danger-color); }
.logout-btn-header svg { width: 20px; height: 20px; }

/* Tarjetas */
.cute-card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-soft);
    border: 1px solid white;
    margin-bottom: 1.5rem;
}

/* --- TARJETAS INTERACTIVAS (Ingresos/Disponible) --- */
.interactive-card {
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative;
    overflow: hidden;
}

.interactive-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.1);
}

.interactive-card:active {
    transform: scale(0.97);
}

/* Indicador sutil de "ver más" */
.interactive-card::after {
    content: '👆 ver detalle';
    position: absolute;
    bottom: 5px;
    left: 0;
    width: 100%;
    text-align: center;
    font-size: 0.6rem;
    color: var(--text-light);
    opacity: 0;
    transition: opacity 0.3s;
}

.interactive-card:hover::after {
    opacity: 1;
}

/* Barra de progreso mini dentro del detalle */
.mini-progress-bg {
    width: 100%;
    height: 6px;
    background-color: #F0F0F0;
    border-radius: 4px;
    margin-top: 8px;
    overflow: hidden;
}
.mini-progress-fill {
    height: 100%;
    background-color: var(--primary-accent);
}

/* Gráfico */
.chart-container {
    display: flex;
    justify-content: center;
    margin: 2rem 0;
}
.donut-chart {
    width: 200px;
    height: 200px;
    border-radius: 50%;
    background: #F0F0F0;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-soft);
}
.donut-inner {
    width: 155px;
    height: 155px;
    background: var(--card-bg);
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-shadow: inset 0 5px 15px rgba(0,0,0,0.03);
}
.donut-value { font-size: 1.5rem; font-weight: 800; color: var(--text-brown); }
.donut-text { font-size: 0.85rem; color: var(--text-light); text-transform: uppercase; letter-spacing: 1px; }

/* Grid Resumen */
.summary-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 2rem;
}
.summary-card-small {
    background: var(--card-bg);
    padding: 1rem 0.5rem;
    border-radius: var(--radius-lg);
    text-align: center;
    box-shadow: var(--shadow-soft);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 110px;
}
.summary-card-small:nth-child(1) { background-color: #F3E5F5; }
.summary-card-small:nth-child(2) { background-color: #FFEBEE; }
.summary-card-small:nth-child(3) { background-color: #FFF8E1; }
.sc-icon { font-size: 1.6rem; margin-bottom: 0.5rem; }
.sc-label { font-size: 0.75rem; color: var(--text-light); font-weight: 600; }
.sc-value { font-size: 0.9rem; font-weight: 800; color: var(--text-brown); word-break: break-all; }

/* FORMULARIOS */
.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    margin-left: 15px;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-light);
}

.kakebo-input {
    width: 100%;
    padding: 12px 20px;
    border: 2px solid var(--border-soft);
    border-radius: var(--radius-pill);
    background-color: #FAFAFA;
    font-family: 'Nunito', sans-serif;
    font-size: 0.95rem;
    color: var(--text-brown);
    outline: none;
    transition: all 0.3s ease;
    /* Eliminar estilo nativo */
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

select.kakebo-input {
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235D4037' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 1em;
    padding-right: 2.5rem;
    background-color: #FFF;
}

.kakebo-input:focus {
    border-color: var(--primary-pink);
    background-color: #FFF;
    box-shadow: 0 0 0 4px rgba(232, 180, 184, 0.2);
}

.flex-input-group .kakebo-input {
    margin: 0;
}

.expense-row-content {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 14px 24px;
    border: 2px solid var(--border-soft);
    border-radius: var(--radius-pill);
    background-color: #FAFAFA;
    font-family: 'Nunito', sans-serif;
    font-size: 1rem;
    color: var(--text-brown);
    outline: none;
    transition: all 0.3s ease;

    /* FIX: Quitar estilo por defecto del sistema operativo */
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

/* Flecha personalizada para el Select */
.form-group select {
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235D4037' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 1.2rem center;
    background-size: 1em;
    padding-right: 3rem; /* Espacio para que el texto no tape la flecha */
}

.form-group input:focus,
.form-group select:focus {
    border-color: var(--primary-pink);
    background-color: #FFF;
    box-shadow: 0 0 0 4px rgba(232, 180, 184, 0.2);
}

/* Botones */
.btn {
    border: none;
    padding: 14px 28px;
    border-radius: var(--radius-pill);
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
    text-align: center;
    transition: all 0.2s;
    display: inline-block;
}
.btn:hover { transform: translateY(-2px); }
.btn-primary {
    background-color: var(--primary-pink);
    color: white;
    background-image: linear-gradient(135deg, var(--primary-pink) 0%, var(--primary-accent) 100%);
    box-shadow: 0 4px 15px rgba(232, 180, 184, 0.4);
}
.btn-danger { background-color: var(--danger-color); color: white; }

.btn-circle {
    width: 50px !important;
    height: 50px !important;
    padding: 0 !important; /* Quitar padding lateral para que no se estire */
    border-radius: 50% !important;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0; /* Evita que se aplaste en móviles */
    aspect-ratio: 1 / 1; /* Asegura proporción 1:1 */
}

.form-row-responsive,
.form-responsive-stack {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* En Tablet/PC: Fila (uno al lado del otro) */
@media (min-width: 768px) {
    .form-row-responsive {
        flex-direction: row;
    }

    .form-responsive-stack {
        flex-direction: row;
        align-items: center; /* Alinear botón con inputs */
    }

    /* Ajuste para que el botón no sea enorme en PC */
    .form-responsive-stack button {
        width: auto;
        padding: 0 20px;
    }
}

/* Listas */
.section-title {
    font-size: 1.3rem;
    margin-bottom: 1.2rem;
    margin-top: 2rem;
    padding-left: 10px;
    border-left: 4px solid var(--primary-pink);
}

.expense-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 5px;
    border-bottom: 1px dashed var(--border-soft);
}
.expense-item:last-child { border-bottom: none; }

/* Checkbox */
input[type="checkbox"] {
    width: 20px;
    height: 20px;
    accent-color: var(--primary-accent);
    margin-right: 12px;
    cursor: pointer;
}

/* Estilos para Lista de Deseos (Barra de Progreso Cute) */
.wish-progress-track {
    width: 100%;
    height: 12px;
    background-color: #F0F0F0;
    border-radius: 10px;
    overflow: hidden;
    margin-top: 8px;
    border: 1px solid white;
    box-shadow: inset 0 2px 5px rgba(0,0,0,0.05);
}
.wish-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--success-color), #81C784);
    border-radius: 10px;
    transition: width 1s ease-in-out;
}

.cat-badge {
    font-size: 0.65rem;
    padding: 2px 8px;
    border-radius: 10px;
    text-transform: uppercase;
    font-weight: 800;
    margin-top: 5px;
    letter-spacing: 0.5px;
}
.cat-badge.expense { background-color: #FFEBEE; color: var(--danger-color); }
.cat-badge.income { background-color: #E8F5E9; color: var(--success-color); }
.cat-badge.wish { background-color: #E3F2FD; color: #1E88E5; }

/* =========================================
   4. NAVEGACIÓN (Dock Simétrico)
   ========================================= */
.bottom-nav {
    position: fixed;
    bottom: 25px;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 350px; /* Un poco más angosto para 3 items */
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: var(--radius-pill);
    display: flex;
    justify-content: space-between; /* Distribuye 3 items */
    align-items: center;
    padding: 12px 30px;
    box-shadow: var(--shadow-nav);
    z-index: 1000;
    border: 1px solid rgba(255,255,255,0.5);
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    color: #C0B0B0;
    text-decoration: none;
    font-size: 0.7rem;
    gap: 4px;
    position: relative;
    width: 50px; /* Ancho fijo para centrar bien */
}
.nav-item svg { width: 24px; height: 24px; stroke-width: 2.2px; }
.nav-item.active { color: var(--primary-accent); }

/* FAB Central */
.nav-fab {
    width: 55px;
    height: 55px;
    background: linear-gradient(135deg, var(--primary-pink), var(--primary-accent));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    margin-top: -45px;
    border: 5px solid var(--bg-color);
    box-shadow: 0 10px 25px rgba(232, 180, 184, 0.6);
}

/* =========================================
   5. MODALES Y AUTH
   ========================================= */

/* Overlay */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: rgba(93, 64, 55, 0.25);
    backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}
[x-cloak] { display: none !important; }

/* Contenido Modal */
.modal-content {
    background-color: var(--card-bg);
    padding: 2rem;
    width: 90%;
    max-width: 400px;
    border-radius: var(--radius-xl);
    box-shadow: 0 20px 50px rgba(0,0,0,0.1);
    border: 1px solid white;
    animation: modalPop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes modalPop {
    from { opacity: 0; transform: scale(0.95) translateY(10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}
.modal-content select {
    width: 100%;
    padding: 12px 20px;
    border: 2px solid var(--border-soft);
    border-radius: var(--radius-pill);
    background-color: #FAFAFA;
    font-family: 'Nunito', sans-serif;
    font-size: 0.95rem;
    color: var(--text-brown);
    outline: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    /* Flecha personalizada */
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235D4037' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 1em;
}

.date-filter-container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    background-color: rgba(255, 255, 255, 0.6);
    padding: 8px 15px;
    border-radius: var(--radius-pill);
    margin: 0 auto 2rem auto;
    border: 1px solid white;
    width: fit-content;
    box-shadow: var(--shadow-soft);
}

.filter-controls {
    display: flex;
    gap: 10px;
}

.filter-select {
    padding: 10px 20px;
    border: 1px solid white;
    border-radius: var(--radius-pill);
    background-color: #FFF;
    font-family: 'Nunito', sans-serif;
    color: var(--text-brown);
    font-weight: 700;
    cursor: pointer;
    outline: none;
    transition: all 0.2s;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);

    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235D4037' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 0.8rem center;
    background-size: 0.8em;
    padding-right: 2.5rem;
}

.filter-select:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

/* Header Modal */
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}
.modal-header h3 { font-size: 1.4rem; color: var(--text-brown); }

/* Botón Cerrar Modal (Estilizado) */
.btn-close-modal {
    background: #F5F5F5;
    border: none;
    color: var(--text-light);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}
.btn-close-modal:hover {
    background: var(--danger-color);
    color: white;
}

/* Login Container Fix */
.auth-container-fix {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    overflow: hidden;
    background-image: url("data:image/svg+xml,%3Csvg width='52' height='52' viewBox='0 0 52 52' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23E8B4B8' fill-opacity='0.2'%3E%3Cpath d='M10 10c0-2.21-1.79-4-4-4-3.314 0-6-2.686-6-6h2c0 2.21 1.79 4 4 4 3.314 0 6 2.686 6 6 0 2.21 1.79 4 4 4 3.314 0 6 2.686 6 6 0 2.21 1.79 4 4 4v2c-2.21 0-4-1.79-4-4 0-3.314-2.686-6-6-6-2.21 0-4-1.79-4-4-3.314 0-6-2.686-6-6-2.21 0-4-1.79-4-4z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

/* Botón Link (SVG) */
.btn-link-action {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
}
.btn-link-action svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.btn-link-action.is-linked { color: var(--success-color); background: rgba(163, 201, 168, 0.2); }
.btn-link-action.not-linked { color: #D7CCC8; }
.btn-link-action.not-linked:hover { color: var(--primary-accent); }