/* ============================================================
   SPENDLY CLARITY — style.css v3.0  |  Premium FinTech Dark UI
   ============================================================ */

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

/* ── RESET & TOKENS ────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:       #020811;
  --surface:  #030D1E;
  --card:     #0A1628;
  --deep:     #060F1E;
  --border:   #152236;
  --muted:    #3A5270;
  --mid:      #4A6080;
  --soft:     #8AA3BF;
  --text:     #C5D8EE;
  --bright:   #EEF4FF;
  --green:    #10B981;
  --blue:     #2563EB;
  --amber:    #F59E0B;
  --red:      #EF4444;
  --font:     'Sora', -apple-system, BlinkMacSystemFont, sans-serif;
  --mono:     'DM Mono', 'Courier New', monospace;
  --r-sm:     10px;
  --r-md:     14px;
  --r-lg:     18px;
  --r-xl:     24px;
  --r-2xl:    32px;
}

body {
  background: var(--bg);
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  font-family: var(--font);
  color: var(--bright);
}

/* ── MARCO DEL TELÉFONO ─────────────────────────────────────── */
.phone-container {
  width: 100%;
  max-width: 390px;
  height: 844px;
  background: var(--surface);
  border-radius: 44px;
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow:
    0 0 0 1px var(--border),
    0 40px 100px rgba(0,0,0,.95),
    0 0 80px rgba(37,99,235,.05);
}

/* ── STATUS BAR ─────────────────────────────────────────────── */
.status-bar {
  padding: 14px 28px 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}
.status-time { font-size: 12px; font-weight: 600; font-family: var(--mono); }
.status-icons { display: flex; align-items: flex-end; gap: 4px; }
.signal-bars  { display: flex; align-items: flex-end; gap: 3px; }
.bar { width: 3px; border-radius: 1px; background: var(--bright); }
.b1 { height: 5px; } .b2 { height: 8px; }
.b3 { height: 11px; } .b4 { height: 14px; background: var(--muted); }
.battery-icon {
  width: 22px; height: 11px; border: 1.5px solid var(--bright);
  border-radius: 3px; margin-left: 6px;
  display: flex; align-items: center; padding: 1.5px 2px;
}
.battery-fill { width: 12px; height: 100%; background: var(--green); border-radius: 1px; }

/* ── HEADER ──────────────────────────────────────────────────── */
header {
  padding: 12px 24px 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}
.header-eyebrow {
  font-size: 10px; color: var(--muted);
  letter-spacing: 2.5px; font-weight: 700;
}
.header-title { font-size: 17px; font-weight: 700; margin-top: 3px; }
.avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: linear-gradient(135deg, #1C3A6E, #2563EB);
  border: 2px solid rgba(37,99,235,.35);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 700; cursor: pointer;
  box-shadow: 0 0 16px rgba(37,99,235,.28);
  transition: box-shadow .2s;
}
.avatar:hover { box-shadow: 0 0 24px rgba(37,99,235,.45); }

/* ── SCROLL AREA ─────────────────────────────────────────────── */
.scroll-area {
  flex: 1; overflow-y: auto;
  scrollbar-width: none;
  padding-bottom: 8px;
}
.scroll-area::-webkit-scrollbar { display: none; }

/* ── BALANCE HERO ────────────────────────────────────────────── */
.balance-section { padding: 20px 24px 0; }
.balance-label {
  font-size: 11px; color: var(--muted);
  letter-spacing: 2px; font-weight: 600; margin-bottom: 8px;
}
.balance-row {
  display: flex; align-items: flex-end; gap: 4px; line-height: 1;
}
.balance-main  { font-size: 40px; font-weight: 700; font-family: var(--mono); letter-spacing: -1px; }
.balance-cents { font-size: 22px; color: var(--mid); font-family: var(--mono); margin-bottom: 2px; }
.balance-change { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.badge-up {
  background: rgba(16,185,129,.1); border: 1px solid rgba(16,185,129,.25);
  color: var(--green); font-size: 12px; font-weight: 600;
  padding: 4px 12px; border-radius: 20px;
}
.balance-compare { font-size: 11px; color: var(--muted); }

/* ── CHART.JS WRAPPER ────────────────────────────────────────── */
.chart-wrap {
  height: 130px; margin-top: 16px; padding: 0 8px;
  position: relative;
}
.chart-wrap canvas { width: 100% !important; height: 100% !important; }

/* ── INGRESOS VS EGRESOS ─────────────────────────────────────── */
.ie-row { padding: 6px 24px 0; display: flex; gap: 10px; }
.ie-card {
  flex: 1; background: var(--card);
  border-radius: var(--r-md); padding: 14px 16px;
  transition: border-color .3s;
}
.ie-card.income  { border: 1px solid rgba(16,185,129,.2); }
.ie-card.expense { border: 1px solid rgba(239,68,68,.15); }
.ie-label  { font-size: 9px; color: var(--muted); letter-spacing: 1.5px; margin-bottom: 6px; }
.ie-amount { font-size: 19px; font-weight: 700; font-family: var(--mono); transition: color .4s; }
.income  .ie-amount { color: var(--green); }
.expense .ie-amount { color: var(--red); }
.ie-bar  { height: 3px; background: var(--border); border-radius: 2px; margin-top: 8px; }
.ie-fill { height: 100%; border-radius: 2px; transition: width .9s ease; }
.income  .ie-fill { background: var(--green); }
.expense .ie-fill { background: var(--red); }

/* ── ACCIONES RÁPIDAS ────────────────────────────────────────── */
.actions-row { padding: 16px 24px 0; display: flex; gap: 10px; }
.action-btn {
  flex: 1; background: var(--card); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: 12px 4px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 7px;
  color: var(--mid); font-size: 10px; font-family: var(--font);
  transition: transform .15s, background .15s;
}
.action-btn:hover  { background: #0E1F35; }
.action-btn:active { transform: scale(.95); }
.action-icon {
  width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 700;
}
.action-icon.blue  { background: rgba(37,99,235,.14);  border: 1px solid rgba(37,99,235,.28);  color: var(--blue);  }
.action-icon.green { background: rgba(16,185,129,.14); border: 1px solid rgba(16,185,129,.28); color: var(--green); }
.action-icon.amber { background: rgba(245,158,11,.14); border: 1px solid rgba(245,158,11,.28); color: var(--amber); }
.action-icon.gray  { background: rgba(148,163,184,.1); border: 1px solid rgba(148,163,184,.15);color: var(--soft);  transition: color .3s; }

/* ── SECTION HEADERS ─────────────────────────────────────────── */
.section-header {
  display: flex; justify-content: space-between;
  align-items: center; margin-bottom: 14px;
}
.section-header h4 { font-size: 13px; font-weight: 600; color: var(--soft); }
.see-all    { font-size: 11px; color: var(--blue); cursor: pointer; }
.hint-label { font-size: 10px; color: var(--muted); }

/* ── HISTORIAL ───────────────────────────────────────────────── */
.history-section { padding: 20px 24px 0; }
.history-list { display: flex; flex-direction: column; gap: 8px; }
.history-item {
  background: var(--card); border: 1px solid var(--border);
  border-left: 3px solid transparent;
  border-radius: var(--r-md); padding: 12px 16px;
  display: flex; align-items: center; justify-content: space-between;
  animation: fadeIn .3s ease;
}
.item-left { display: flex; align-items: center; gap: 12px; }
.item-icon {
  width: 36px; height: 36px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center; font-size: 16px;
}
.item-details p    { font-size: 13px; font-weight: 600; color: var(--text); }
.item-details span { font-size: 10px; color: var(--muted); margin-top: 2px; display: block; }
.item-amount { font-size: 14px; font-weight: 700; font-family: var(--mono); }

/* Skeleton loader */
.skeleton-item {
  height: 62px; background: var(--card);
  border-radius: var(--r-md); border: 1px solid var(--border);
  animation: pulse 1.4s ease-in-out infinite;
}

/* Estado vacío */
.empty-state {
  text-align: center; padding: 32px 0;
  font-size: 13px; color: var(--muted);
}

/* ── PILLAR GRID (anillos SVG) ───────────────────────────────── */
.dashboard-section { padding: 20px 24px 108px; }
.pillar-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 10px; }

.pillar-card {
  background: var(--card); border: 1px solid transparent;
  border-radius: var(--r-lg); padding: 16px 8px;
  display: flex; flex-direction: column; align-items: center;
  cursor: pointer; text-align: center;
  transition: box-shadow .2s, transform .15s;
}
.pillar-card:hover  { transform: translateY(-2px); }
.pillar-card:active { transform: scale(.96); }
.pillar-short {
  font-size: 9px; font-weight: 700; color: var(--muted);
  letter-spacing: 1.5px; margin-bottom: 12px;
}
.pillar-ring-wrap {
  position: relative; width: 80px; height: 80px;
  display: flex; align-items: center; justify-content: center;
}
.pillar-pct   { font-size: 17px; font-weight: 700; font-family: var(--mono); position: relative; z-index: 1; }
.pillar-total { margin-top: 10px; font-size: 14px; font-weight: 700; font-family: var(--mono); }
.pillar-label { font-size: 10px; color: var(--muted); margin-top: 3px; }

/* ── BOTTOM NAV ──────────────────────────────────────────────── */
.bottom-nav {
  position: absolute; bottom: 0; width: 100%; height: 88px;
  background: rgba(3,13,30,.97); border-top: 1px solid var(--border);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  display: flex; align-items: center; justify-content: space-around;
  padding-bottom: 16px; z-index: 10;
}
.nav-item {
  background: none; border: none; color: var(--muted);
  display: flex; flex-direction: column; align-items: center;
  gap: 5px; cursor: pointer; width: 52px; padding-top: 4px;
  font-family: var(--font); transition: color .2s;
}
.nav-item span    { font-size: 9px; }
.nav-item.active  { color: var(--bright); }
.nav-item svg     { flex-shrink: 0; }
.mic-btn-wrap     { position: relative; }
.mic-main-btn {
  width: 52px; height: 52px; border-radius: 50%;
  background: linear-gradient(135deg, #1C3A6E, #2563EB);
  border: none; color: white; cursor: pointer;
  transform: translateY(-10px);
  box-shadow: 0 4px 20px rgba(37,99,235,.5);
  display: flex; align-items: center; justify-content: center;
  transition: transform .2s, box-shadow .2s;
}
.mic-main-btn:hover {
  transform: translateY(-13px);
  box-shadow: 0 8px 28px rgba(37,99,235,.6);
}

/* ── MODAL ───────────────────────────────────────────────────── */
.modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.92); backdrop-filter: blur(14px);
  display: flex; align-items: center; justify-content: center;
  padding: 0 20px; z-index: 100;
  opacity: 0; pointer-events: none;
  transition: opacity .25s;
}
.modal.open { opacity: 1; pointer-events: auto; }
.modal-content {
  width: 100%; background: var(--card);
  border-radius: var(--r-xl); padding: 24px 22px;
  border: 1px solid var(--border);
  box-shadow: 0 20px 60px rgba(0,0,0,.8);
  transform: scale(.94) translateY(10px);
  transition: transform .3s cubic-bezier(.34,1.56,.64,1);
}
.modal.open .modal-content { transform: scale(1) translateY(0); }
.modal-eyebrow {
  font-size: 10px; color: var(--muted);
  letter-spacing: 2.5px; font-weight: 700; margin-bottom: 6px;
}
.modal-content h3 { font-size: 20px; font-weight: 700; margin-bottom: 4px; }
.modal-instruction { font-size: 12px; color: var(--muted); margin-bottom: 20px; line-height: 1.65; }
.input-wrap {
  border: 1px solid #1C3050; border-radius: var(--r-md);
  background: var(--deep); overflow: hidden; margin-bottom: 12px;
  transition: border-color .2s;
}
.input-wrap:focus-within { border-color: rgba(37,99,235,.5); }
#aiInputField {
  width: 100%; background: transparent; border: none;
  color: var(--bright); font-size: 14px; padding: 14px 16px;
  resize: none; outline: none; font-family: var(--font); line-height: 1.6;
}
#aiInputField::placeholder { color: var(--muted); }
.ai-error {
  font-size: 12px; color: var(--red); margin-bottom: 12px;
  padding: 8px 12px;
  background: rgba(239,68,68,.1); border: 1px solid rgba(239,68,68,.2);
  border-radius: var(--r-sm);
}
.modal-actions { display: flex; gap: 10px; }
.modal-hint {
  margin-top: 12px; font-size: 10px;
  color: var(--muted); text-align: center;
}
.btn-cancel {
  flex: 1; padding: 13px; border-radius: var(--r-sm);
  background: #0E1F35; border: 1px solid var(--border);
  color: var(--mid); font-size: 13px; font-weight: 600;
  cursor: pointer; font-family: var(--font);
  transition: background .15s;
}
.btn-cancel:hover { background: #132135; }
.btn-confirm {
  flex: 2; padding: 13px; border-radius: var(--r-sm);
  background: linear-gradient(135deg, #1C3A6E, #2563EB);
  border: none; color: var(--bright);
  font-size: 13px; font-weight: 700; cursor: pointer;
  font-family: var(--font);
  display: flex; align-items: center; justify-content: center; gap: 8px;
  transition: opacity .15s;
}
.btn-confirm:disabled {
  opacity: .38; cursor: not-allowed;
  background: #0E1F35; color: var(--muted);
}

/* ── BOTTOM SHEET ────────────────────────────────────────────── */
.sheet-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.82); backdrop-filter: blur(8px);
  z-index: 90; display: flex; align-items: flex-end;
  opacity: 0; pointer-events: none;
  transition: opacity .3s;
}
.sheet-overlay.open { opacity: 1; pointer-events: auto; }
.sheet-body {
  width: 100%; background: var(--card);
  border-radius: 28px 28px 0 0;
  border: 1px solid var(--border); border-bottom: none;
  padding: 24px 24px 56px;
  max-height: 76vh; overflow-y: auto; scrollbar-width: none;
  transform: translateY(30px);
  transition: transform .35s cubic-bezier(.34,1.56,.64,1);
}
.sheet-body::-webkit-scrollbar  { display: none; }
.sheet-overlay.open .sheet-body { transform: translateY(0); }
.sheet-handle {
  width: 36px; height: 4px; background: #1C3050;
  border-radius: 2px; margin: 0 auto 20px;
}
.sheet-header {
  display: flex; justify-content: space-between;
  align-items: flex-start; margin-bottom: 20px;
}
.sheet-eyebrow { font-size: 10px; color: var(--muted); letter-spacing: 2px; margin-bottom: 4px; }
.sheet-title   { font-size: 22px; font-weight: 700; }
.sheet-subtitle { font-size: 12px; margin-top: 2px; }
.sheet-total-wrap  { text-align: right; }
.sheet-total-label { font-size: 10px; color: var(--muted); }
.sheet-total-value { font-size: 28px; font-weight: 700; font-family: var(--mono); }
.sheet-bar-wrap {
  background: var(--deep); border: 1px solid var(--border);
  border-radius: var(--r-sm); padding: 14px 16px; margin-bottom: 16px;
}
.sheet-bar-meta {
  display: flex; justify-content: space-between;
  font-size: 11px; color: var(--muted); margin-bottom: 8px;
}
.sheet-bar-track { height: 6px; background: var(--border); border-radius: 3px; }
.sheet-bar-fill  { height: 100%; border-radius: 3px; transition: width .8s ease; }
.sheet-stats {
  display: grid; grid-template-columns: repeat(3,1fr);
  gap: 8px; margin-bottom: 16px;
}
.stat-box {
  background: var(--deep); border: 1px solid var(--border);
  border-radius: var(--r-sm); padding: 12px 10px; text-align: center;
}
.stat-label { font-size: 9px; color: var(--muted); letter-spacing: 1px; margin-bottom: 6px; }
.stat-value { font-size: 16px; font-weight: 700; font-family: var(--mono); }
.sheet-items { display: flex; flex-direction: column; gap: 8px; }
.sheet-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 14px; background: var(--deep);
  border: 1px solid var(--border); border-radius: var(--r-sm);
}
.sheet-item-left   { display: flex; align-items: center; gap: 10px; }
.sheet-item-icon   { font-size: 18px; }
.sheet-item-name   { font-size: 13px; font-weight: 600; color: var(--text); }
.sheet-item-date   { font-size: 10px; color: var(--muted); }
.sheet-item-right  { text-align: right; }
.sheet-item-amount { font-size: 14px; font-weight: 700; font-family: var(--mono); }
.sheet-item-pct    { font-size: 9px; }
.sheet-empty { text-align: center; padding: 40px 0; color: var(--muted); font-size: 14px; }

/* ── TOAST ───────────────────────────────────────────────────── */
.app-toast {
  position: fixed; top: 24px; left: 50%; transform: translateX(-50%);
  background: var(--card); border-radius: var(--r-md);
  padding: 12px 20px; font-size: 13px; z-index: 200; white-space: nowrap;
  box-shadow: 0 8px 30px rgba(0,0,0,.6);
  animation: slideDown .3s ease;
}
.app-toast.success { border: 1px solid var(--green); color: var(--bright); }
.app-toast.error   { border: 1px solid var(--red);   color: var(--red); }

/* ── SPINNER ─────────────────────────────────────────────────── */
.spinner {
  display: inline-block; width: 13px; height: 13px;
  border: 2px solid rgba(59,130,246,.3);
  border-top-color: #3B82F6; border-radius: 50%;
  animation: spin .8s linear infinite;
}

/* ── ANIMACIONES ─────────────────────────────────────────────── */
@keyframes spin      { to { transform: rotate(360deg); } }
@keyframes fadeIn    { from { opacity:0; transform:translateY(4px); } to { opacity:1; transform:translateY(0); } }
@keyframes slideDown { from { opacity:0; transform:translateX(-50%) translateY(-8px); } to { opacity:1; transform:translateX(-50%) translateY(0); } }
@keyframes pulse     {
  0%,100% { background: var(--card); }
  50%      { background: #0E1C30;    }
}

/* ── RESPONSIVE MOBILE ───────────────────────────────────────── */
@media (max-width: 430px) {
  body { align-items: flex-start; }
  .phone-container {
    border-radius: 0;
    height: 100svh;
    max-width: 100%;
  }
  .app-toast {
    left: 16px; right: 16px;
    transform: none; white-space: normal;
  }
}
