/* =====================================================
   LJPowerPay - Sistema de diseno
   Paleta Slate + Blue (estilo Stripe Dashboard), mobile-first.
   ===================================================== */

:root {
  --primary: #2563EB;
  --primary-hover: #1D4ED8;
  --primary-soft: #EFF6FF;
  --bg: #F8FAFC;
  --surface: #FFFFFF;
  --border: #E2E8F0;
  --border-input: #CBD5E1;
  --text: #0F172A;
  --text-2: #475569;
  --text-3: #94A3B8;
  --success: #059669;
  --success-soft: #ECFDF5;
  --danger: #DC2626;
  --danger-soft: #FEF2F2;
  --warning: #D97706;
  --warning-soft: #FFFBEB;
  --neutral-soft: #F1F5F9;
  --radius: 6px;
  --radius-lg: 8px;
  --nav-h: 64px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

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

body {
  font-family: 'Inter', -apple-system, 'Segoe UI', sans-serif;
  font-size: 14px;
  line-height: 20px;
  color: var(--text);
  background: var(--bg);
}

img { max-width: 100%; }
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }

h1 { font-size: 24px; font-weight: 600; line-height: 32px; letter-spacing: -0.02em; }
h2 { font-size: 18px; font-weight: 600; line-height: 28px; letter-spacing: -0.01em; }
h3 { font-size: 16px; font-weight: 600; line-height: 24px; }

.mono, .amount { font-variant-numeric: tabular-nums; }
.text-2 { color: var(--text-2); }
.text-3 { color: var(--text-3); font-size: 12px; line-height: 16px; }
.mt-1 { margin-top: 4px; } .mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; } .mt-6 { margin-top: 24px; } .mt-8 { margin-top: 32px; }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 44px; padding: 0 20px; border-radius: var(--radius);
  font-family: inherit; font-size: 15px; font-weight: 500;
  border: 1px solid transparent; cursor: pointer; white-space: nowrap;
  transition: background-color 150ms ease, border-color 150ms ease, color 150ms ease;
  text-decoration: none;
}
.btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); color: #fff; }
.btn-secondary { background: var(--surface); color: #334155; border-color: var(--border-input); }
.btn-secondary:hover { background: var(--bg); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #B91C1C; color: #fff; }
.btn-ghost { background: transparent; color: var(--text-2); height: 36px; padding: 0 12px; font-size: 14px; }
.btn-ghost:hover { background: var(--neutral-soft); color: var(--text); }
.btn-block { width: 100%; }
.btn-lg { height: 52px; font-size: 16px; font-weight: 600; }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #047857; color: #fff; }

@media (min-width: 1024px) {
  .btn { height: 36px; font-size: 14px; padding: 0 16px; }
  .btn-lg { height: 44px; font-size: 15px; }
}

/* ---------- Formularios ---------- */
.field { margin-bottom: 16px; }
.field label {
  display: block; font-size: 13px; font-weight: 500; color: #334155; margin-bottom: 6px;
}
.field .req { color: var(--danger); }
.input, select.input, textarea.input {
  width: 100%; height: 44px; border-radius: var(--radius);
  border: 1px solid var(--border-input); background: var(--surface);
  padding: 0 12px; font-family: inherit; font-size: 15px; color: var(--text);
}
textarea.input { height: auto; padding: 10px 12px; resize: vertical; }
.input::placeholder { color: var(--text-3); }
.input:hover { border-color: var(--border-input); }
.input:focus { border-color: var(--primary); outline: none; box-shadow: 0 0 0 3px rgba(37, 99, 235, .15); }
.input.error { border-color: var(--danger); }
.field .hint { font-size: 12px; color: var(--text-3); margin-top: 4px; }
.field .error-msg { font-size: 12px; color: var(--danger); margin-top: 4px; }
.form-narrow { max-width: 640px; }

@media (min-width: 1024px) {
  .input, select.input { height: 36px; font-size: 14px; }
}

.checkbox-row { display: flex; align-items: flex-start; gap: 10px; }
.checkbox-row input[type="checkbox"] { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--primary); flex-shrink: 0; }

/* Toggle switch */
.switch { position: relative; display: inline-block; width: 44px; height: 24px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
  position: absolute; inset: 0; background: var(--border-input); border-radius: 9999px;
  transition: background-color 150ms ease; cursor: pointer;
}
.switch .slider::before {
  content: ""; position: absolute; height: 18px; width: 18px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%; transition: transform 150ms ease;
}
.switch input:checked + .slider { background: var(--primary); }
.switch input:checked + .slider::before { transform: translateX(20px); }
.switch input:focus-visible + .slider { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 24px;
}
.card-sm { padding: 16px; }

/* KPI */
.kpi-grid { display: grid; grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 480px) { .kpi-grid { grid-template-columns: repeat(3, 1fr); } }
.kpi-label { font-size: 13px; font-weight: 500; color: #64748B; }
.kpi-value { margin-top: 8px; font-size: 28px; font-weight: 600; line-height: 36px; font-variant-numeric: tabular-nums; }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; border-radius: 9999px;
  padding: 2px 8px; font-size: 12px; font-weight: 500; line-height: 16px;
}
.badge-success { background: var(--success-soft); color: #047857; }
.badge-danger { background: var(--danger-soft); color: #B91C1C; }
.badge-warning { background: var(--warning-soft); color: #B45309; }
.badge-neutral { background: var(--neutral-soft); color: var(--text-2); }
.badge-info { background: var(--primary-soft); color: var(--primary-hover); }

/* ---------- Listas / tablas ---------- */
.list { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.list-item {
  display: flex; align-items: center; gap: 12px; padding: 14px 16px;
  border-bottom: 1px solid var(--neutral-soft); color: inherit; text-decoration: none;
}
.list-item:last-child { border-bottom: none; }
a.list-item:hover, button.list-item:hover { background: var(--bg); color: inherit; }
.list-item .grow { flex: 1; min-width: 0; }
.list-item .title { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item .meta { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.list-item .amount { font-weight: 600; font-variant-numeric: tabular-nums; }

.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th {
  text-align: left; padding: 10px 16px; background: var(--bg);
  font-size: 12px; font-weight: 500; text-transform: uppercase; letter-spacing: .05em; color: #64748B;
  border-bottom: 1px solid var(--border);
}
table.data td { padding: 10px 16px; border-bottom: 1px solid var(--neutral-soft); }
table.data tr:last-child td { border-bottom: none; }
table.data td.right, table.data th.right { text-align: right; }

/* ---------- Estados vacios ---------- */
.empty {
  text-align: center; padding: 48px 24px;
}
.empty .empty-icon { color: var(--text-3); margin-bottom: 12px; }
.empty p { color: var(--text-2); margin-bottom: 8px; }
.empty .actions { display: flex; gap: 12px; justify-content: center; margin-top: 16px; flex-wrap: wrap; }

/* ---------- Flash ---------- */
.flash { border-radius: var(--radius); padding: 12px 16px; margin-bottom: 16px; font-size: 14px; }
.flash-success { background: var(--success-soft); color: #047857; border: 1px solid #A7F3D0; }
.flash-error { background: var(--danger-soft); color: #B91C1C; border: 1px solid #FECACA; }

/* ---------- Layout app ---------- */
.app-shell { min-height: 100vh; }
.app-main {
  padding: 16px 16px calc(var(--nav-h) + 24px);
  max-width: 1280px; margin: 0 auto;
}
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }

/* Franja de trial */
.trial-bar {
  background: var(--warning-soft); color: #92400E; border-bottom: 1px solid #FDE68A;
  padding: 8px 16px; font-size: 13px; display: flex; align-items: center; gap: 12px;
  justify-content: center; flex-wrap: wrap; text-align: center;
}
.trial-bar a { color: #92400E; font-weight: 600; text-decoration: underline; }

/* Topbar movil */
.topbar {
  height: 56px; background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; padding: 0 16px;
  position: sticky; top: 0; z-index: 40;
}
.topbar .brand { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 600; color: var(--text); }
.topbar .brand img { height: 28px; width: auto; }

/* Bottom nav movil */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
  height: var(--nav-h); background: var(--surface); border-top: 1px solid var(--border);
  display: grid; grid-template-columns: repeat(5, 1fr);
  padding-bottom: env(safe-area-inset-bottom);
}
.bottom-nav a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: 11px; font-weight: 500; color: var(--text-2); text-decoration: none;
}
.bottom-nav a.active { color: var(--primary); }
.bottom-nav a svg { width: 22px; height: 22px; }
.bottom-nav a.nav-charge span.icon-wrap {
  display: flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; border-radius: 50%; background: var(--primary); color: #fff;
  margin-top: -18px; border: 4px solid var(--bg);
}
.bottom-nav a.nav-charge svg { width: 20px; height: 20px; }

/* Sidebar desktop */
.sidebar { display: none; }

@media (min-width: 1024px) {
  .bottom-nav { display: none; }
  .topbar { display: none; }
  .app-shell { display: flex; }
  .sidebar {
    display: flex; flex-direction: column; width: 240px; flex-shrink: 0;
    background: var(--surface); border-right: 1px solid var(--border);
    position: sticky; top: 0; height: 100vh;
  }
  .sidebar .brand {
    height: 56px; display: flex; align-items: center; gap: 8px; padding: 0 16px;
    border-bottom: 1px solid var(--border); font-size: 15px; font-weight: 600; color: var(--text);
  }
  .sidebar .brand img { height: 28px; width: auto; }
  .sidebar nav { flex: 1; overflow-y: auto; padding: 8px; }
  .sidebar nav a {
    display: flex; align-items: center; gap: 12px; border-radius: var(--radius);
    padding: 8px 12px; font-size: 14px; font-weight: 500; color: var(--text-2);
    text-decoration: none; margin-bottom: 2px;
  }
  .sidebar nav a svg { width: 16px; height: 16px; }
  .sidebar nav a:hover { background: var(--bg); color: var(--text); }
  .sidebar nav a.active { background: var(--primary-soft); color: var(--primary-hover); }
  .sidebar nav .nav-group {
    font-size: 11px; font-weight: 500; text-transform: uppercase; letter-spacing: .05em;
    color: var(--text-3); padding: 0 12px; margin: 24px 0 6px;
  }
  .sidebar .sidebar-foot { border-top: 1px solid var(--border); padding: 12px; }
  .app-main { flex: 1; padding: 32px; }
}

/* ---------- Pantalla Cobrar ---------- */
.service-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (min-width: 768px) { .service-grid { grid-template-columns: repeat(3, 1fr); } }
.service-tile {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 16px; text-align: left; cursor: pointer; font-family: inherit;
  transition: border-color 150ms ease, background-color 150ms ease;
}
.service-tile:hover { border-color: var(--border-input); }
.service-tile.selected { border-color: var(--primary); background: var(--primary-soft); }
.service-tile .name { font-size: 14px; font-weight: 500; color: var(--text); }
.service-tile .price { font-size: 18px; font-weight: 600; margin-top: 4px; font-variant-numeric: tabular-nums; }
.service-tile .qty-badge {
  float: right; background: var(--primary); color: #fff; border-radius: 9999px;
  min-width: 22px; height: 22px; display: none; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600; padding: 0 6px;
}
.service-tile.selected .qty-badge { display: inline-flex; }

.charge-summary-bar {
  position: fixed; left: 0; right: 0; bottom: var(--nav-h); z-index: 45;
  background: var(--surface); border-top: 1px solid var(--border); padding: 12px 16px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
}
@media (min-width: 1024px) {
  .charge-summary-bar { position: static; border: 1px solid var(--border); border-radius: var(--radius-lg); margin-top: 24px; }
}

/* QR */
.qr-box { display: flex; justify-content: center; padding: 16px; }
.qr-box svg { width: min(75vw, 320px); height: auto; }

/* Share buttons */
.share-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 480px) { .share-grid { grid-template-columns: repeat(3, 1fr); } }

/* ---------- Agenda / calendario ---------- */
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-dow { text-align: center; font-size: 11px; font-weight: 500; text-transform: uppercase; color: var(--text-3); padding: 6px 0; }
.cal-day {
  min-height: 52px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); padding: 4px 6px; font-size: 12px; color: var(--text-2);
  text-decoration: none; display: block;
}
.cal-day.other { opacity: .35; }
.cal-day.today { border-color: var(--primary); }
.cal-day .dot {
  display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--primary); margin-top: 4px;
}
.cal-day .count { display: block; font-size: 11px; color: var(--primary); font-weight: 600; margin-top: 2px; }

/* ---------- Grafica SVG ---------- */
.chart-wrap { overflow-x: auto; }

/* ---------- Pagina publica de pago ---------- */
.pay-page {
  min-height: 100vh; display: flex; flex-direction: column; align-items: center;
  padding: 24px 16px; background: var(--bg);
}
.pay-card { width: 100%; max-width: 420px; }

/* ---------- Landing ---------- */
.land-header {
  background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 40;
}
.land-header .inner {
  max-width: 1080px; margin: 0 auto; height: 64px; padding: 0 20px;
  display: flex; align-items: center; justify-content: space-between;
}
.land-header .brand { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 16px; color: var(--text); }
.land-header .brand img { height: 30px; width: auto; }
.land-section { max-width: 1080px; margin: 0 auto; padding: 56px 20px; }
.hero { text-align: center; padding: 72px 20px 56px; }
.hero h1 { font-size: 34px; line-height: 42px; letter-spacing: -0.02em; }
@media (min-width: 768px) { .hero h1 { font-size: 44px; line-height: 52px; } }
.hero p.sub { font-size: 17px; color: var(--text-2); margin-top: 16px; max-width: 560px; margin-left: auto; margin-right: auto; }
.hero .cta { display: flex; gap: 12px; justify-content: center; margin-top: 28px; flex-wrap: wrap; }
.steps-grid, .features-grid { display: grid; grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 768px) {
  .steps-grid { grid-template-columns: repeat(3, 1fr); }
  .features-grid { grid-template-columns: repeat(3, 1fr); }
}
.step-num {
  width: 32px; height: 32px; border-radius: 50%; background: var(--primary-soft); color: var(--primary-hover);
  display: flex; align-items: center; justify-content: center; font-weight: 600; margin-bottom: 12px;
}
.price-card { max-width: 400px; margin: 0 auto; text-align: center; }
.price-big { font-size: 40px; font-weight: 600; letter-spacing: -0.02em; }
.price-big small { font-size: 16px; font-weight: 400; color: var(--text-2); }
.check-list { list-style: none; margin-top: 16px; text-align: left; }
.check-list li { padding: 6px 0 6px 28px; position: relative; color: var(--text-2); }
.check-list li::before { content: "✓"; position: absolute; left: 4px; color: var(--success); font-weight: 700; }
.faq-item { border-bottom: 1px solid var(--border); padding: 4px 0; }
.faq-item summary { cursor: pointer; font-weight: 500; padding: 12px 0; list-style: none; }
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item p { color: var(--text-2); padding-bottom: 14px; }
.land-footer { border-top: 1px solid var(--border); padding: 32px 20px; text-align: center; color: var(--text-3); font-size: 13px; }

/* ---------- Auth ---------- */
.auth-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 400px; }
.auth-brand { display: flex; justify-content: center; margin-bottom: 24px; }
.auth-brand img { height: 40px; width: auto; }

/* ---------- Modal simple ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .5); z-index: 100;
  display: none; align-items: flex-end; justify-content: center;
}
@media (min-width: 640px) { .modal-overlay { align-items: center; } }
.modal-overlay.open { display: flex; }
.modal {
  background: var(--surface); border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  width: 100%; max-width: 480px; max-height: 90vh; overflow-y: auto;
  box-shadow: 0 20px 25px -5px rgb(0 0 0 / .1), 0 8px 10px -6px rgb(0 0 0 / .1);
}
@media (min-width: 640px) { .modal { border-radius: var(--radius-lg); } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 24px; border-bottom: 1px solid var(--border); }
.modal-body { padding: 24px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 12px; padding: 16px 24px; border-top: 1px solid var(--border); }

.hidden { display: none !important; }
.text-center { text-align: center; }
.row { display: flex; align-items: center; gap: 12px; }
.row .grow { flex: 1; }
.divider { border: none; border-top: 1px solid var(--border); margin: 24px 0; }
