/* ============================================================
   Amapola · Retención — Design System
   Tema claro, amigable, tipografía grande, para usuarios novatos
   ============================================================ */

:root {
  /* Superficies — paleta AdoptAI (adoptai.lat) */
  --bg: #F4F7FA;
  --surface: #FFFFFF;
  --surface-2: #F9FBFD;
  --ink: #0B1524;
  --ink-soft: #4A5B6E;
  --ink-faint: #64748B;
  --line: #E2EAF1;
  --line-strong: #CDDAE6;

  /* Marca — AdoptAI blue */
  --brand: #0D7EC0;
  --brand-deep: #01507E;
  --brand-soft: #E7F3FB;
  --brand-light: #65B4E2;
  --gold: #B8930A;
  --gold-soft: #FBF5D8;

  /* Estados / segmentos */
  --green: #1FA97A;
  --green-soft: #E3F7EF;
  --amber: #D9822B;
  --amber-soft: #FCF0E3;
  --red: #DE4558;
  --red-soft: #FCE9EC;
  --blue: #3B82D9;
  --blue-soft: #E8F1FC;
  --gray: #8E86A3;
  --gray-soft: #F1EFF6;
  --wa: #25D366;
  --wa-deep: #128C7E;

  --radius: 14px;
  --radius-lg: 20px;
  --shadow: 0 1px 3px rgba(11, 21, 36, .05), 0 8px 24px rgba(11, 21, 36, .07);
  --shadow-lg: 0 4px 12px rgba(11, 21, 36, .10), 0 24px 60px rgba(11, 21, 36, .16);
  --font: 'Outfit', system-ui, sans-serif;
  --font-display: 'Fraunces', Georgia, serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* ============ LAYOUT: sidebar + main ============ */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 248px; flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: 22px 14px;
  display: flex; flex-direction: column; gap: 6px;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 4px 10px 18px; }
.brand-logo {
  width: 40px; height: 40px; border-radius: 12px;
  background: linear-gradient(135deg, var(--brand), var(--brand-deep));
  color: #fff; font-family: var(--font-display); font-size: 22px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
}
.brand-name { font-weight: 700; font-size: 16px; letter-spacing: .02em; }
.brand-sub { font-size: 12px; color: var(--ink-faint); }

.nav { display: flex; flex-direction: column; gap: 3px; flex: 1; }
.nav-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .09em; color: var(--ink-faint); padding: 14px 12px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 11px 12px; border-radius: 11px;
  color: var(--ink-soft); text-decoration: none; font-weight: 500; font-size: 15px;
  transition: background .15s, color .15s;
}
.nav-item svg { width: 19px; height: 19px; flex-shrink: 0; }
.nav-item:hover { background: var(--surface-2); color: var(--ink); }
.nav-item.active { background: var(--brand-soft); color: var(--brand-deep); font-weight: 600; }
.nav-item .nav-count {
  margin-left: auto; background: var(--red); color: #fff;
  font-size: 11.5px; font-weight: 700; padding: 1px 8px; border-radius: 999px;
}
.sidebar-foot { border-top: 1px solid var(--line); padding-top: 14px; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 6px 10px; }
.user-avatar {
  width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
  background: var(--gold-soft); color: var(--gold);
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px;
}
.user-name { font-size: 13.5px; font-weight: 600; }
.user-role { font-size: 11.5px; color: var(--ink-faint); }

.main { flex: 1; min-width: 0; padding: 28px 34px 70px; max-width: 1240px; }

/* ============ ENCABEZADOS DE PÁGINA ============ */
.page-head { margin-bottom: 22px; }
.page-title { font-family: var(--font-display); font-size: 31px; font-weight: 600; letter-spacing: -.01em; }
.page-sub { color: var(--ink-soft); font-size: 15.5px; margin-top: 4px; max-width: 70ch; }

/* Banner de ayuda — explica la pantalla en lenguaje simple */
.help-banner {
  display: flex; gap: 13px; align-items: flex-start;
  background: var(--blue-soft); border: 1px solid #CBDFF6;
  border-radius: var(--radius); padding: 14px 18px; margin: 16px 0 22px;
  font-size: 14.5px; color: #2A5B94;
}
.help-banner strong { color: #1D4474; }
.help-banner .help-icon {
  width: 26px; height: 26px; border-radius: 50%; flex-shrink: 0;
  background: var(--blue); color: #fff; font-weight: 800; font-size: 15px;
  display: flex; align-items: center; justify-content: center;
}

/* ============ KPI CARDS ============ */
.kpi-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 26px; }
.kpi {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-lg); padding: 20px 22px;
  box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.kpi-label { font-size: 13.5px; font-weight: 600; color: var(--ink-soft); display: flex; align-items: center; gap: 7px; }
.kpi-value { font-family: var(--font-display); font-size: 40px; font-weight: 600; line-height: 1.15; margin-top: 6px; font-variant-numeric: tabular-nums; }
.kpi-note { font-size: 13px; color: var(--ink-faint); margin-top: 3px; }
.kpi-note.up { color: var(--green); font-weight: 600; }
.kpi-note.down { color: var(--red); font-weight: 600; }
.kpi.accent-violet { border-top: 4px solid var(--brand); }
.kpi.accent-gold   { border-top: 4px solid var(--gold); }
.kpi.accent-green  { border-top: 4px solid var(--green); }
.kpi.accent-red    { border-top: 4px solid var(--red); }

/* ============ CARDS GENÉRICAS ============ */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-lg); box-shadow: var(--shadow);
  padding: 24px; margin-bottom: 22px;
}
.card-title { font-size: 18px; font-weight: 700; display: flex; align-items: center; gap: 9px; }
.card-sub { font-size: 14px; color: var(--ink-soft); margin-top: 2px; }

/* ============ BADGES DE SEGMENTO ============ */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12.5px; font-weight: 700; letter-spacing: .015em;
  padding: 4px 11px; border-radius: 999px; white-space: nowrap;
}
.badge .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.vip      { background: var(--gold-soft);  color: var(--gold); }
.badge.activa   { background: var(--green-soft); color: var(--green); }
.badge.riesgo   { background: var(--amber-soft); color: var(--amber); }
.badge.dormida  { background: var(--red-soft);   color: var(--red); }
.badge.perdida  { background: var(--gray-soft);  color: var(--gray); }
.badge.nueva    { background: var(--blue-soft);  color: var(--blue); }
.badge.control  { background: var(--gray-soft);  color: var(--gray); }
.badge.enviado  { background: var(--blue-soft);  color: var(--blue); }
.badge.redimido { background: var(--green-soft); color: var(--green); }

/* ============ BOTONES ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--font); font-size: 15px; font-weight: 600;
  padding: 11px 20px; border-radius: 12px; border: none; cursor: pointer;
  transition: transform .12s, box-shadow .12s, background .15s;
  text-decoration: none;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn svg { width: 18px; height: 18px; }
.btn-primary { background: var(--brand); color: #fff; box-shadow: 0 3px 10px rgba(13, 126, 192, .35); }
.btn-primary:hover { background: var(--brand-deep); }
.btn-wa { background: var(--wa); color: #fff; box-shadow: 0 3px 10px rgba(37, 211, 102, .35); }
.btn-wa:hover { background: #1FB857; }
.btn-ghost { background: transparent; color: var(--ink-soft); border: 1.5px solid var(--line-strong); }
.btn-ghost:hover { border-color: var(--brand); color: var(--brand-deep); background: var(--brand-soft); }
.btn-sm { font-size: 13.5px; padding: 7px 14px; border-radius: 10px; }
.btn-lg { font-size: 16.5px; padding: 14px 26px; border-radius: 14px; }
.btn-danger { background: var(--red-soft); color: var(--red); }
.btn[disabled] { opacity: .45; cursor: not-allowed; transform: none !important; }

/* ============ FILTROS / TOOLBAR ============ */
.toolbar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.select, .input {
  font-family: var(--font); font-size: 14.5px; font-weight: 500; color: var(--ink);
  background: var(--surface); border: 1.5px solid var(--line-strong);
  border-radius: 11px; padding: 9px 14px; outline: none;
  transition: border-color .15s;
}
.select:focus, .input:focus { border-color: var(--brand); }
.search { position: relative; flex: 1; max-width: 320px; }
.search .input { width: 100%; padding-left: 38px; }
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 17px; height: 17px; color: var(--ink-faint); }

/* Chips de filtro rápido (segmentos) */
.seg-chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.seg-chip {
  font-size: 14px; font-weight: 600; padding: 8px 16px; border-radius: 999px;
  border: 1.5px solid var(--line-strong); background: var(--surface); color: var(--ink-soft);
  cursor: pointer; transition: all .15s;
}
.seg-chip:hover { border-color: var(--brand); color: var(--brand-deep); }
.seg-chip.active { background: var(--brand); border-color: var(--brand); color: #fff; box-shadow: 0 3px 10px rgba(13,126,192,.3); }
.seg-chip .n { font-weight: 800; margin-left: 5px; opacity: .75; }

/* ============ TABLA DE CLIENTAS ============ */
.table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow); overflow: hidden; }
table.tbl { width: 100%; border-collapse: collapse; }
.tbl thead th {
  text-align: left; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em;
  color: var(--ink-faint); padding: 13px 18px; background: var(--surface-2);
  border-bottom: 1px solid var(--line);
}
.tbl tbody td { padding: 15px 18px; border-bottom: 1px solid var(--line); vertical-align: middle; font-size: 15px; }
.tbl tbody tr { transition: background .12s; cursor: pointer; }
.tbl tbody tr:hover { background: var(--brand-soft); }
.tbl tbody tr:last-child td { border-bottom: none; }
.tbl .num { font-variant-numeric: tabular-nums; font-weight: 600; }
.cliente-cell { display: flex; align-items: center; gap: 12px; }
.cliente-avatar {
  width: 38px; height: 38px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px; color: #fff;
}
.cliente-nombre { font-weight: 600; font-size: 15px; }
.cliente-meta { font-size: 12.5px; color: var(--ink-faint); margin-top: 1px; }

/* Mini-barra de dormancia */
.ratio-bar { width: 90px; height: 7px; background: var(--gray-soft); border-radius: 99px; overflow: hidden; }
.ratio-fill { height: 100%; border-radius: 99px; }
.ratio-txt { font-size: 12.5px; color: var(--ink-faint); margin-top: 4px; }

/* ============ DRAWER (panel lateral clienta) ============ */
.drawer-overlay {
  position: fixed; inset: 0; background: rgba(28, 20, 40, .42);
  opacity: 0; pointer-events: none; transition: opacity .22s; z-index: 50;
}
.drawer-overlay.open { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; right: 0; height: 100vh; width: 460px; max-width: 94vw;
  background: var(--surface); box-shadow: var(--shadow-lg); z-index: 51;
  transform: translateX(105%); transition: transform .26s cubic-bezier(.3,.8,.3,1);
  display: flex; flex-direction: column; overflow-y: auto;
}
.drawer.open { transform: translateX(0); }
.drawer-head { padding: 24px 26px 18px; border-bottom: 1px solid var(--line); position: relative; }
.drawer-close {
  position: absolute; top: 18px; right: 18px;
  width: 34px; height: 34px; border-radius: 50%; border: none; cursor: pointer;
  background: var(--gray-soft); color: var(--ink-soft); font-size: 17px; font-weight: 600;
}
.drawer-close:hover { background: var(--red-soft); color: var(--red); }
.drawer-body { padding: 22px 26px; flex: 1; }
.drawer-section { margin-bottom: 22px; }
.drawer-section h4 { font-size: 12.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-faint); margin-bottom: 10px; }

/* Stats en grilla dentro del drawer */
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat {
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px 14px;
}
.stat .s-label { font-size: 12px; color: var(--ink-faint); font-weight: 600; }
.stat .s-value { font-size: 19px; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 2px; }
.stat .s-value.big { font-family: var(--font-display); font-size: 23px; }

/* ============ MENSAJE WHATSAPP (preview burbuja) ============ */
.wa-preview {
  background: #E5DDD5;
  background-image: radial-gradient(circle at 20% 30%, rgba(255,255,255,.35) 0%, transparent 50%);
  border-radius: 14px; padding: 18px 16px;
}
.wa-bubble {
  background: #DCF8C6; border-radius: 10px; padding: 12px 14px;
  font-size: 14.5px; line-height: 1.5; color: #1f2c24;
  box-shadow: 0 1px 1px rgba(0,0,0,.12); max-width: 95%;
  position: relative; white-space: pre-line;
}
.wa-bubble .wa-time { display: block; text-align: right; font-size: 11px; color: #7a8a7e; margin-top: 5px; }
.wa-bubble .code { font-weight: 800; color: var(--wa-deep); letter-spacing: .03em; }

/* Pasos numerados (flujo para novatos) */
.steps { display: flex; flex-direction: column; gap: 10px; margin: 14px 0; }
.step { display: flex; gap: 12px; align-items: flex-start; font-size: 14.5px; color: var(--ink-soft); }
.step .step-n {
  width: 26px; height: 26px; border-radius: 50%; flex-shrink: 0;
  background: var(--brand-soft); color: var(--brand-deep); font-weight: 800; font-size: 13.5px;
  display: flex; align-items: center; justify-content: center;
}
.step.done .step-n { background: var(--green-soft); color: var(--green); }

/* ============ MODAL (simulación WhatsApp / confirmaciones) ============ */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(28, 20, 40, .55); z-index: 60;
  display: none; align-items: center; justify-content: center; padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  width: 430px; max-width: 96vw; max-height: 92vh; overflow-y: auto;
  animation: modalIn .22s cubic-bezier(.3,.8,.3,1);
}
@keyframes modalIn { from { transform: translateY(14px) scale(.98); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-head { padding: 20px 24px 14px; font-size: 18px; font-weight: 700; }
.modal-body { padding: 0 24px 20px; }
.modal-foot { padding: 16px 24px 22px; display: flex; gap: 10px; justify-content: flex-end; border-top: 1px solid var(--line); }

/* Chat WhatsApp simulado completo */
.wa-chat { border-radius: 14px; overflow: hidden; border: 1px solid var(--line); }
.wa-chat-head {
  background: var(--wa-deep); color: #fff; padding: 12px 16px;
  display: flex; align-items: center; gap: 11px; font-weight: 600; font-size: 15px;
}
.wa-chat-head .wa-avatar {
  width: 34px; height: 34px; border-radius: 50%; background: rgba(255,255,255,.25);
  display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 700;
}
.wa-chat-head small { display: block; font-size: 11.5px; font-weight: 400; opacity: .85; }
.wa-chat-body { background: #E5DDD5; padding: 16px 14px; min-height: 120px; }

/* ============ FUNNEL DE CAMPAÑA ============ */
.funnel { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0; align-items: stretch; }
.funnel-step { padding: 16px 18px; position: relative; }
.funnel-step:not(:last-child)::after {
  content: '→'; position: absolute; right: -8px; top: 50%; transform: translateY(-50%);
  color: var(--ink-faint); font-size: 19px; font-weight: 700; z-index: 2;
}
.funnel-step .f-label { font-size: 12.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-faint); }
.funnel-step .f-value { font-family: var(--font-display); font-size: 31px; font-weight: 600; margin-top: 4px; font-variant-numeric: tabular-nums; }
.funnel-step .f-sub { font-size: 13px; color: var(--ink-soft); }
.funnel-step .f-sub.good { color: var(--green); font-weight: 700; }

/* Barra de progreso genérica */
.progress { height: 9px; background: var(--gray-soft); border-radius: 99px; overflow: hidden; }
.progress .p-fill { height: 100%; border-radius: 99px; background: var(--brand); transition: width .8s cubic-bezier(.3,.8,.3,1); }

/* ============ ALERTAS ============ */
.alert {
  display: flex; gap: 12px; align-items: flex-start;
  border-radius: var(--radius); padding: 14px 17px; font-size: 14.5px; margin-bottom: 10px;
}
.alert.warn { background: var(--amber-soft); color: #8A5215; border: 1px solid #F0D9B8; }
.alert.danger { background: var(--red-soft); color: #9A2F3E; border: 1px solid #F2C7CE; }
.alert.ok { background: var(--green-soft); color: #156A4D; border: 1px solid #BBE8D6; }

/* ============ TELÉFONO (mockup app clienta) ============ */
.phone {
  width: 100%; max-width: 360px; background: #0E0B14; border-radius: 44px; padding: 13px;
  box-shadow: var(--shadow-lg), inset 0 0 0 2px #2a2438; margin: 0 auto;
}
.phone-screen { background: var(--bg); border-radius: 33px; overflow: hidden; min-height: 690px; display: flex; flex-direction: column; }
.phone-notch { height: 28px; background: #0E0B14; border-radius: 0 0 18px 18px; width: 150px; margin: 0 auto; }
.phone-head {
  background: linear-gradient(135deg, var(--brand), var(--brand-deep)); color: #fff;
  padding: 18px 20px 20px; font-weight: 600;
}
.phone-body { flex: 1; padding: 18px; }

/* Slots de reserva */
.slot-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; }
.slot {
  text-align: center; padding: 11px 6px; border-radius: 11px; font-weight: 600; font-size: 14.5px;
  border: 1.5px solid var(--line-strong); background: var(--surface); cursor: pointer; transition: all .14s;
}
.slot:hover { border-color: var(--brand); }
.slot.selected { background: var(--brand); border-color: var(--brand); color: #fff; }
.slot.full { opacity: .35; cursor: not-allowed; text-decoration: line-through; }

/* ============ UTILIDADES ============ */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.row { display: flex; align-items: center; gap: 12px; }
.row.between { justify-content: space-between; }
.muted { color: var(--ink-faint); }
.small { font-size: 13px; }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; } .mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; }
.tc { text-align: center; }
.money { font-variant-numeric: tabular-nums; }
.money.pos { color: var(--green); font-weight: 700; }
.money.neg { color: var(--red); font-weight: 700; }

/* Tag "demo" flotante */
.demo-tag {
  position: fixed; bottom: 18px; right: 18px; z-index: 90;
  background: var(--ink); color: #fff; font-size: 12.5px; font-weight: 600;
  padding: 8px 15px; border-radius: 999px; box-shadow: var(--shadow-lg); opacity: .92;
}

/* Animación entrada */
.fade-up { opacity: 0; transform: translateY(14px); transition: opacity .5s, transform .5s; }
.fade-up.in { opacity: 1; transform: none; }

/* ============ RESPONSIVE ============ */
@media (max-width: 1080px) {
  .kpi-row { grid-template-columns: 1fr 1fr; }
  .grid-3 { grid-template-columns: 1fr; }
  .funnel { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 860px) {
  .app { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; flex-direction: row; align-items: center; overflow-x: auto; padding: 12px 16px; }
  .nav { flex-direction: row; }
  .nav-label, .sidebar-foot { display: none; }
  .main { padding: 20px 16px 60px; }
  .grid-2 { grid-template-columns: 1fr; }
  .kpi-row { grid-template-columns: 1fr; }
  .drawer { width: 100vw; }
}
