/* ============================================================
   LIFE OS — Estilos globales premium
   Complementa Tailwind CSS con efectos y componentes custom
   ============================================================ */

/* ——— Variables de tema ——— */
:root {
    --primary:        #6366f1;
    --primary-light:  #8b5cf6;
    --surface:        #ffffff;
    --surface-raised: #f8fafc;
    --border:         #e2e8f0;
    --text:           #1e293b;
    --text-muted:     #64748b;
    --shadow:         0 4px 24px rgba(99, 102, 241, 0.08);
    --radius:         16px;
    --radius-sm:      10px;
    --radius-lg:      24px;
    --transition:     all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.dark {
    --primary:        #818cf8;
    --surface:        #1a1a2e;
    --surface-raised: #13132a;
    --border:         rgba(148, 163, 184, 0.1);
    --text:           #f1f5f9;
    --text-muted:     #94a3b8;
    --shadow:         0 4px 24px rgba(0, 0, 0, 0.4);
}

/* ——— Reset y base ——— */
*, *::before, *::after { box-sizing: border-box; }

html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ——— Safe area para notch de iPhone ——— */
.safe-area-pb { padding-bottom: env(safe-area-inset-bottom, 0px); }

/* ——— Scrollbar custom ——— */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(99,102,241,0.3); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: rgba(99,102,241,0.6); }

/* ============================================================
   COMPONENTES DE CARDS
   ============================================================ */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    transition: var(--transition);
}

.card:hover { transform: translateY(-2px); box-shadow: 0 8px 32px rgba(99,102,241,.12); }

.card-glass {
    background: rgba(255,255,255,0.7);
    backdrop-filter: blur(16px) saturate(180%);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
    border: 1px solid rgba(255,255,255,0.6);
    border-radius: var(--radius);
}

.dark .card-glass {
    background: rgba(26,26,46,0.7);
    border: 1px solid rgba(148,163,184,0.08);
}

/* Gradiente premium para KPI cards */
.card-gradient {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: white;
    border: none;
}

.card-gradient-green  { background: linear-gradient(135deg, #10b981, #059669); color: white; border: none; }
.card-gradient-orange { background: linear-gradient(135deg, #f59e0b, #d97706); color: white; border: none; }
.card-gradient-red    { background: linear-gradient(135deg, #ef4444, #dc2626); color: white; border: none; }
.card-gradient-blue   { background: linear-gradient(135deg, #3b82f6, #2563eb); color: white; border: none; }

/* ============================================================
   TIPOGRAFÍA ESPECIAL
   ============================================================ */

.kpi-value {
    font-size: clamp(1.5rem, 5vw, 2.5rem);
    font-weight: 800;
    letter-spacing: -0.03em;
    line-height: 1.1;
}

.section-title {
    font-size: .875rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 1rem;
}

/* ============================================================
   BADGES
   ============================================================ */

.badge {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    padding: .2rem .65rem;
    border-radius: 99px;
    font-size: .72rem;
    font-weight: 600;
}

.badge-green  { background: rgba(16,185,129,.15);  color: #059669; }
.badge-red    { background: rgba(239,68,68,.15);   color: #dc2626; }
.badge-yellow { background: rgba(245,158,11,.15);  color: #d97706; }
.badge-blue   { background: rgba(59,130,246,.15);  color: #2563eb; }
.badge-purple { background: rgba(139,92,246,.15);  color: #7c3aed; }
.badge-gray   { background: rgba(148,163,184,.15); color: #64748b; }

.badge-currency {
    font-size: .65rem;
    font-weight: 700;
    padding: .15rem .4rem;
    border-radius: 6px;
    background: rgba(99,102,241,.12);
    color: var(--primary);
    margin-left: .25rem;
}

/* ============================================================
   BARRA DE PROGRESO
   ============================================================ */

.progress-bar {
    height: 8px;
    border-radius: 99px;
    background: rgba(148,163,184,.2);
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    border-radius: 99px;
    transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.progress-fill::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,.3) 50%, transparent 100%);
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0%   { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.progress-fill.danger { background: linear-gradient(90deg, #ef4444, #f97316); }
.progress-fill.warn   { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.progress-fill.ok     { background: linear-gradient(90deg, #6366f1, #8b5cf6); }
.progress-fill.great  { background: linear-gradient(90deg, #10b981, #06b6d4); }

/* ============================================================
   SEMÁFORO HOGAR
   ============================================================ */

.semaforo {
    width: 10px; height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 0 8px currentColor;
}
.semaforo.verde   { background: #10b981; color: #10b981; }
.semaforo.amarillo { background: #f59e0b; color: #f59e0b; animation: pulse-yellow 2s infinite; }
.semaforo.rojo    { background: #ef4444; color: #ef4444; animation: pulse-red 1.5s infinite; }

@keyframes pulse-yellow {
    0%,100% { box-shadow: 0 0 4px #f59e0b; }
    50%      { box-shadow: 0 0 12px #f59e0b; }
}
@keyframes pulse-red {
    0%,100% { box-shadow: 0 0 4px #ef4444; }
    50%      { box-shadow: 0 0 16px #ef4444; }
}

/* ============================================================
   EMOJIS DE ESTADO DE ÁNIMO
   ============================================================ */

.emoji-estado {
    cursor: pointer;
    font-size: 2rem;
    padding: .5rem;
    border-radius: 12px;
    transition: var(--transition);
    border: 2px solid transparent;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.emoji-estado:hover   { transform: scale(1.2); background: rgba(99,102,241,.1); }
.emoji-estado.selected {
    border-color: var(--primary);
    background: rgba(99,102,241,.15);
    transform: scale(1.15);
    box-shadow: 0 0 0 4px rgba(99,102,241,.2);
}

/* ============================================================
   STREAK (racha de días)
   ============================================================ */

.streak-badge {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .4rem .9rem;
    border-radius: 99px;
    background: linear-gradient(135deg, #f59e0b, #ef4444);
    color: white;
    font-weight: 700;
    font-size: .85rem;
    box-shadow: 0 4px 12px rgba(245,158,11,.4);
}

/* ============================================================
   INPUTS GLOBALES
   ============================================================ */

.input-field {
    transition: var(--transition);
}
.input-field:focus {
    box-shadow: 0 0 0 3px rgba(99,102,241,.2);
    border-color: var(--primary) !important;
}

/* ============================================================
   MODAL
   ============================================================ */

.modal-overlay { transition: opacity .25s ease; }
.modal-overlay.hidden { opacity: 0; pointer-events: none; }
.modal-overlay:not(.hidden) { opacity: 1; }

.modal-content {
    max-height: 92vh;
    overflow-y: auto;
}

/* ============================================================
   TOAST
   ============================================================ */

.toast {
    pointer-events: all;
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .875rem 1.25rem;
    border-radius: 14px;
    background: white;
    color: #1e293b;
    box-shadow: 0 8px 32px rgba(0,0,0,.16);
    font-size: .875rem;
    font-weight: 500;
    min-width: 280px;
    animation: slideInRight .3s cubic-bezier(.4,0,.2,1);
    border-left: 4px solid var(--primary);
}

.dark .toast {
    background: #1e1e3a;
    color: #f1f5f9;
    box-shadow: 0 8px 32px rgba(0,0,0,.5);
}

.toast.success { border-color: #10b981; }
.toast.error   { border-color: #ef4444; }
.toast.warn    { border-color: #f59e0b; }

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

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

/* ============================================================
   TRANSACCIONES — lista
   ============================================================ */

.tx-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: .875rem 1rem;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    cursor: default;
}

.tx-row:hover { background: rgba(99,102,241,.05); }

.tx-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.tx-amount.ingreso       { color: #10b981; font-weight: 700; }
.tx-amount.gasto         { color: #ef4444; font-weight: 700; }
.tx-amount.transferencia { color: #6366f1; font-weight: 700; }

/* ============================================================
   NAVEGACIÓN LATERAL — activo
   ============================================================ */

.nav-link { position: relative; }

/* ============================================================
   BOTTOM NAV — item activo
   ============================================================ */

.bottom-nav-item { position: relative; }

/* ============================================================
   CHART CONTAINERS
   ============================================================ */

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

/* ============================================================
   CHECKBOX CUSTOM
   ============================================================ */

.checkbox-custom {
    width: 20px; height: 20px;
    border-radius: 6px;
    border: 2px solid var(--border);
    background: var(--surface);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: var(--transition);
}

.checkbox-custom.checked {
    background: var(--primary);
    border-color: var(--primary);
}

.checkbox-custom.checked::after {
    content: '';
    display: block;
    width: 4px; height: 8px;
    border: 2px solid white;
    border-top: none;
    border-left: none;
    transform: rotate(45deg) translate(-1px, -1px);
}

/* ============================================================
   ANIMACIONES DE ENTRADA DE PÁGINA
   ============================================================ */

@keyframes fadeIn  { from { opacity: 0; }           to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: translateY(0); } }

.animate-fade-in { animation: fadeIn .35s ease both; }
.animate-slide-up { animation: slideUp .4s cubic-bezier(.4,0,.2,1) both; }

.stagger-1 { animation-delay: .05s; }
.stagger-2 { animation-delay: .1s; }
.stagger-3 { animation-delay: .15s; }
.stagger-4 { animation-delay: .2s; }
.stagger-5 { animation-delay: .25s; }

/* ============================================================
   RESPONSIVE — ocultar sidebar en mobile, mostrar en desktop
   ============================================================ */

@media (max-width: 1023px) {
    .topbar { left: 0 !important; }
}

@media (min-width: 1024px) {
    .bottom-nav { display: none; }
}

/* ============================================================
   MODO SISTEMA (prefers-color-scheme)
   ============================================================ */

@media (prefers-color-scheme: dark) {
    html[data-tema="sistema"] { --surface: #1a1a2e; }
    html[data-tema="sistema"] body { background-color: #0d0d1f; color: #f1f5f9; }
}
