/* ============================================================
   RUTA — Sistema de diseño (v2)
   Azul Profundo  #1C3C85   ·  Naranja Vibrante #ED6B40
   Tipografía: Montserrat
   ============================================================ */

:root {
  /* Brand */
  --azul: #1C3C85;
  --azul-700: #234aa0;
  --azul-600: #2d5cc4;
  --azul-100: #dbe2f4;
  --azul-50:  #eef1fb;
  --azul-25:  #f6f8fd;

  --naranja: #ED6B40;
  --naranja-600: #e25a2d;
  --naranja-100: #fde0d2;
  --naranja-50:  #fff4ee;

  --blanco: #FFFFFF;

  /* Neutrals */
  --ink:        #111634;
  --text:       #1c2138;
  --text-2:     #3a405a;
  --muted:      #6c7390;
  --muted-2:    #9aa0b8;
  --line:       #e8ebf4;
  --line-2:     #f0f2f8;
  --bg:         #f4f6fc;
  --surface:    #ffffff;
  --surface-2:  #f8fafd;

  /* Effects */
  --shadow-xs:  0 1px 2px rgba(28,60,133,.06);
  --shadow:     0 4px 14px rgba(28,60,133,.08);
  --shadow-lg:  0 18px 40px rgba(28,60,133,.14);
  --shadow-glow: 0 8px 22px rgba(237,107,64,.32);

  /* Radii */
  --r-xs: 8px;
  --r-sm: 12px;
  --r-md: 16px;
  --r-lg: 22px;
  --r-xl: 28px;

  /* Sizes */
  --phone-w: 412px;
  --phone-h: 892px;
  --bottom-nav-h: 78px;
  --header-h: 64px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0;
  font-family: 'Montserrat', system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  font-feature-settings: 'cv11', 'ss03';
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
img { max-width: 100%; display: block; }
input, select, textarea, button { font-family: inherit; }

/* ============================================================
   DESKTOP STAGE (visible only on wide screens)
   ============================================================ */
.stage {
  display: grid;
  grid-template-columns: minmax(280px, 340px) auto;
  gap: 32px;
  padding: 28px;
  min-height: 100vh;
  align-items: start;
  justify-content: center;
  background:
    radial-gradient(1100px 600px at 0% 0%, rgba(28,60,133,.06), transparent 60%),
    radial-gradient(900px 500px at 100% 100%, rgba(237,107,64,.06), transparent 60%),
    var(--bg);
}
.side-panel {
  position: sticky;
  top: 28px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 340px;
}
.side-brand {
  background: linear-gradient(160deg, var(--azul) 0%, var(--azul-700) 100%);
  color: white;
  padding: 26px 24px 28px;
  border-radius: var(--r-xl);
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
  text-align: center;
}
.side-brand::before {
  content: "";
  position: absolute; inset: -50% -20% auto auto;
  width: 220px; height: 220px;
  background: radial-gradient(closest-side, rgba(237,107,64,.35), transparent 70%);
  filter: blur(20px);
}
.side-brand img {
  width: 130px;
  position: relative;
  margin: 0 auto;
  display: block;
}
.side-brand .slogan {
  margin: 12px 0 0;
  font-style: italic; font-weight: 500;
  color: #c5d2ee; font-size: 13px;
  position: relative;
}
.side-card {
  background: white;
  padding: 18px 20px;
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-xs);
  border: 1px solid var(--line-2);
}
.side-card h3 { margin: 0 0 6px; color: var(--azul); font-size: 15px; font-weight: 800; }
.side-card h4 { margin: 0 0 12px; color: var(--azul); font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: 1.2px; }
.side-card p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.55; }
.side-card.mini { padding: 14px 18px; }
.palette { display: flex; gap: 8px; align-items: center; }
.swatch { width: 26px; height: 26px; border-radius: 8px; box-shadow: 0 2px 6px rgba(0,0,0,.08); }
.palette-info { font-size: 10px; color: var(--muted); margin-left: 4px; }

.quick-links { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; }
.quick-links a {
  font-size: 10.5px;
  padding: 8px 6px;
  border-radius: 8px;
  background: var(--azul-50);
  color: var(--azul);
  font-weight: 700;
  cursor: pointer;
  text-align: center;
  letter-spacing: .3px;
  transition: all .15s;
}
.quick-links a:hover { background: var(--azul); color: white; transform: translateY(-1px); }

.version { color: var(--muted); font-size: 11px; text-align: center; margin: 4px 0 0; }

/* ============================================================
   DEVICE FRAME (desktop only)
   ============================================================ */
.device {
  width: var(--phone-w);
  height: var(--phone-h);
  background: #0d1020;
  border-radius: 56px;
  padding: 16px;
  box-shadow:
    0 30px 80px rgba(28, 60, 133, .25),
    0 6px 24px rgba(0,0,0,.18),
    inset 0 0 0 2px rgba(255,255,255,.06);
  position: relative;
  flex-shrink: 0;
}
.device-notch {
  position: absolute;
  top: 22px; left: 50%;
  transform: translateX(-50%);
  width: 124px; height: 30px;
  background: #000;
  border-radius: 22px;
  z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 12px;
  pointer-events: none;
}
.device-notch .speaker { width: 46px; height: 5px; background: #1a1a1a; border-radius: 4px; }
.device-notch .cam { width: 10px; height: 10px; background: #1e2235; border-radius: 50%; }
.device-home {
  position: absolute;
  bottom: 10px; left: 50%;
  transform: translateX(-50%);
  width: 130px; height: 5px;
  background: rgba(255,255,255,.35);
  border-radius: 3px;
  z-index: 60;
  pointer-events: none;
}
.screen {
  width: 100%; height: 100%;
  background: white;
  border-radius: 40px;
  overflow: hidden;
  position: relative;
}

/* Mobile: kill stage, show screen full size */
@media (max-width: 900px) {
  .stage {
    grid-template-columns: 1fr;
    padding: 0;
    gap: 0;
    background: var(--bg);
  }
  .side-panel { display: none; }
  .device {
    width: 100vw; height: 100vh;
    border-radius: 0;
    padding: 0;
    box-shadow: none;
    background: white;
  }
  .device-notch, .device-home { display: none; }
  .screen { border-radius: 0; }
}

/* ============================================================
   SCREEN TRANSITIONS
   ============================================================ */
/* Smooth screen transitions — `.screen` background is updated by render()
   ahead of time so that fading content doesn't reveal a white flash. */
@keyframes screenEnter {
  from { opacity: 0; transform: translateY(10px) scale(.995); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes screenEnterFade {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes screenSlideLeft {
  from { opacity: 0; transform: translateX(28px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes screenSlideRight {
  from { opacity: 0; transform: translateX(-28px); }
  to { opacity: 1; transform: translateX(0); }
}
.screen > .app,
.screen > .welcome,
.screen > .splash {
  animation: screenEnter .34s cubic-bezier(.2,.8,.3,1);
  will-change: opacity, transform;
}
.screen.nav-back > .app,
.screen.nav-back > .welcome {
  animation: screenSlideRight .34s cubic-bezier(.2,.8,.3,1);
}
.screen.nav-forward > .app,
.screen.nav-forward > .welcome {
  animation: screenSlideLeft .34s cubic-bezier(.2,.8,.3,1);
}
.screen > .splash {
  animation: screenEnterFade .4s ease-out;
}
/* Background is set dynamically by render() — see _applyScreenBg(). */
.screen { background: var(--surface-2); transition: background-color .12s ease; }

/* Stagger animation for list items */
.app-body .list > *,
.app-body .tile-grid > *,
.app-body .carousel > * {
  animation: screenEnter .35s cubic-bezier(.2,.8,.3,1) backwards;
}
.app-body .list > *:nth-child(1) { animation-delay: .04s; }
.app-body .list > *:nth-child(2) { animation-delay: .08s; }
.app-body .list > *:nth-child(3) { animation-delay: .12s; }
.app-body .list > *:nth-child(4) { animation-delay: .16s; }
.app-body .list > *:nth-child(5) { animation-delay: .20s; }
.app-body .list > *:nth-child(6) { animation-delay: .24s; }
.app-body .list > *:nth-child(n+7) { animation-delay: .28s; }
.app-body .tile-grid > *:nth-child(1) { animation-delay: .02s; }
.app-body .tile-grid > *:nth-child(2) { animation-delay: .04s; }
.app-body .tile-grid > *:nth-child(3) { animation-delay: .06s; }
.app-body .tile-grid > *:nth-child(4) { animation-delay: .08s; }
.app-body .tile-grid > *:nth-child(5) { animation-delay: .10s; }
.app-body .tile-grid > *:nth-child(6) { animation-delay: .12s; }
.app-body .tile-grid > *:nth-child(7) { animation-delay: .14s; }
.app-body .tile-grid > *:nth-child(8) { animation-delay: .16s; }
.app-body .tile-grid > *:nth-child(9) { animation-delay: .18s; }

/* Button press feedback */
button:not(:disabled):active,
.btn:not(:disabled):active {
  transform: scale(.97);
  transition: transform .08s;
}

/* Smooth interactions */
.list-card, .business-card, .tile, .plan-card,
.profile-row, .quick-action, .biz-action,
.tab, .pill, .icon-btn, .hamb, .fab {
  transition: transform .15s ease, box-shadow .15s ease, background-color .15s ease, border-color .15s ease, color .15s ease;
}

/* Bottom nav button active scale */
.bottom-nav button { transition: color .2s; }

/* Respect reduce-motion */
@media (prefers-reduced-motion: reduce) {
  .screen > .app, .screen > .welcome, .screen > .splash,
  .app-body .list > *, .app-body .tile-grid > *, .app-body .carousel > * {
    animation: none;
  }
}

/* ============================================================
   APP SHELL inside .screen
   ============================================================ */
.app {
  width: 100%; height: 100%;
  display: flex; flex-direction: column;
  background: var(--surface-2);
  position: relative;
  overflow: hidden;
  /* Leave room for the device-level status bar (which sits as overlay chrome). */
  padding-top: 44px;
}
@media (max-width: 900px) {
  /* On real mobile, the OS status bar handles the spacing — use safe-area. */
  .app { padding-top: env(safe-area-inset-top, 0px); }
}

/* Device-level status bar — lives inside .device (NOT per-screen) so it
   never duplicates on real mobile. Color is toggled via .light by JS. */
.device-status-bar {
  position: absolute;
  top: 28px;
  left: 30px;
  right: 30px;
  height: 22px;
  z-index: 55;
  display: flex; align-items: center; justify-content: space-between;
  font-size: 13px; font-weight: 700;
  color: var(--ink);
  pointer-events: none;
  transition: color .25s ease;
}
.device-status-bar .time { padding-left: 14px; }
.device-status-bar .right { display: flex; gap: 5px; align-items: center; padding-right: 14px; }
.device-status-bar .right .battery {
  width: 22px; height: 11px; border: 1.4px solid currentColor; border-radius: 3px;
  position: relative; padding: 1px;
}
.device-status-bar .right .battery::after { content:""; position:absolute; right:-3px; top:3px; width:2px; height:5px; background: currentColor; border-radius:0 2px 2px 0; }
.device-status-bar .right .battery::before { content:""; display:block; width:80%; height:100%; background: currentColor; border-radius: 1px; }
.device-status-bar.light { color: white; }

/* When the viewport is too small to render the phone mockup frame, the OS
   already shows its own status bar — hide the simulated one to avoid the
   duplicate. (Must come after the default .device-status-bar block so the
   cascade actually applies on mobile.) */
@media (max-width: 900px) {
  .device-status-bar { display: none; }
}

/* Legacy per-screen .status-bar fallback (kept for any view that still emits it). */
.status-bar { display: none; }

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 18px 12px;
  background: white;
  flex-shrink: 0;
  z-index: 5;
  border-bottom: 1px solid var(--line-2);
}
.app-header .brand-area { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.app-header .avatar-ring {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--naranja), #ffaa7a);
  display: grid; place-items: center;
  color: white; font-weight: 800; font-size: 14px;
  box-shadow: var(--shadow-glow);
  border: 2px solid white;
  overflow: hidden;
}
.app-header .avatar-ring.photo { padding: 0; }
.app-header .avatar-ring img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
.app-header .name-area .greet { font-size: 10px; color: var(--muted); font-weight: 600; line-height: 1; }
.app-header .name-area .name { font-size: 13px; color: var(--azul); font-weight: 800; line-height: 1.2; }
.app-header .logo {
  height: 28px;
  position: absolute; left: 50%; transform: translateX(-50%);
}
.hamb {
  background: var(--azul-50);
  border: 0;
  width: 40px; height: 40px;
  border-radius: 12px;
  display: grid; place-items: center;
  color: var(--azul);
  font-size: 14px;
  font-weight: 800;
  transition: background .15s;
}
.hamb:hover { background: var(--azul-100); }
.hamb .ic { display: flex; flex-direction: column; gap: 3px; }
.hamb .ic span { width: 16px; height: 2px; background: currentColor; border-radius: 2px; }

.back-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 18px 12px;
  flex-shrink: 0;
  background: white;
  border-bottom: 1px solid var(--line-2);
  z-index: 5;
}
.back-bar .back {
  background: var(--azul-50);
  color: var(--azul);
  border: 0;
  width: 40px; height: 40px;
  border-radius: 12px;
  font-size: 18px;
  display: grid; place-items: center;
}
.back-bar .back:hover { background: var(--azul-100); }
.back-bar h1 { margin: 0; font-size: 16px; font-weight: 800; color: var(--azul); flex: 1; }
.back-bar .right-actions { display: flex; gap: 6px; }

.app-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px 18px calc(var(--bottom-nav-h) + 30px);
  scroll-behavior: smooth;
  background: var(--surface-2);
}
.app-body.no-bottom-nav { padding-bottom: 30px; }
.app-body.auth { padding: 0; background: white; }
.app-body::-webkit-scrollbar { width: 0; height: 0; }
.app-body::-webkit-scrollbar-thumb { background: transparent; }

