/**
 * app.css — Sistema de diseño Tesla-inspired (versión legible)
 * Inspirado en tesla.com: fondo claro, sidebar oscuro #171A20,
 * tipografía Outfit, alto contraste, accents azul/rojo.
 */

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

/* ══════════════════════════════════════════
   TOKENS DE DISEÑO
   ══════════════════════════════════════════ */
:root {
  --font: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;

  /* Fondos */
  --bg-page:    #F2F2F0;   /* gris cálido, exacto de tesla.com */
  --bg-surface: #FFFFFF;
  --bg-inset:   #EAEAE7;   /* inputs, áreas hundidas */
  --bg-hover:   #E8E8E5;

  /* Sidebar */
  --sidebar-bg:     #171A20;   /* negro Tesla */
  --sidebar-border: rgba(255,255,255,.07);
  --sidebar-text:   rgba(255,255,255,.62);
  --sidebar-active: rgba(255,255,255,.96);
  --sidebar-hover:  rgba(255,255,255,.08);

  /* Texto — alto contraste */
  --text-1: #171A20;   /* casi negro — títulos */
  --text-2: #3E3F42;   /* gris oscuro — cuerpo */
  --text-3: #6B6D71;   /* gris medio — labels */
  --text-4: #9EA0A5;   /* gris claro — hints */

  /* Acentos */
  --blue:      #3665F3;
  --blue-lt:   #EBF0FE;
  --blue-d:    #2450D4;
  --red:       #E82127;   /* Tesla red */
  --red-lt:    #FDEAEA;
  --green:     #1A9E5C;
  --green-lt:  #E6F6EE;
  --amber:     #C07B00;
  --amber-lt:  #FFF4E0;

  /* Bordes */
  --border:      rgba(0,0,0,.10);
  --border-md:   rgba(0,0,0,.16);
  --border-focus: rgba(54,101,243,.45);

  /* Radios */
  --r-xs:  6px;
  --r-sm:  10px;
  --r-md:  14px;
  --r-lg:  18px;
  --r-xl:  24px;

  /* Sombras */
  --sh-sm:   0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --sh-md:   0 4px 16px rgba(0,0,0,.07), 0 1px 4px rgba(0,0,0,.05);
  --sh-lg:   0 12px 40px rgba(0,0,0,.11), 0 4px 12px rgba(0,0,0,.06);
  --sh-blue: 0 0 0 3px rgba(54,101,243,.15);

  /* Layout */
  --sidebar-w: 224px;

  /* Transiciones */
  --ease:   cubic-bezier(.25,.1,.25,1);
  --t-fast: 130ms;
  --t-mid:  220ms;
}

/* ══════════════════════════════════════════
   RESET
   ══════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  font-size: 14px;
  color: var(--text-2);
  background: var(--bg-page);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; color: var(--blue-d); }
img { max-width: 100%; display: block; }
button { font-family: var(--font); }

/* ══════════════════════════════════════════
   TIPOGRAFÍA
   ══════════════════════════════════════════ */
h1,h2,h3,h4,h5 {
  color: var(--text-1);
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -.02em;
  margin: 0 0 12px;
}
h1 { font-size: 28px; }
h2 { font-size: 22px; }
h3 { font-size: 18px; }
h4 { font-size: 15px; font-weight: 600; }
h5 { font-size: 13px; font-weight: 600; letter-spacing: .01em; text-transform: uppercase; color: var(--text-3); }

p { color: var(--text-2); margin: 0 0 14px; }

/* ══════════════════════════════════════════
   LAYOUT
   ══════════════════════════════════════════ */
.app {
  display: flex;
  min-height: 100vh;
}

.main {
  flex: 1;
  margin-left: var(--sidebar-w);
  padding: 36px 40px;
  max-width: 1280px;
  min-height: 100vh;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 28px;
  gap: 16px;
  flex-wrap: wrap;
}
.page-header h1 { margin: 0; }

.grid-2 { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 16px; }
.grid-2 > * { min-width: 0; }
.grid-2 input, .grid-2 select { width: 100%; box-sizing: border-box; }
.grid-3 { display: grid; grid-template-columns: repeat(3,1fr); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4,1fr); gap: 16px; }
.flex   { display: flex; }
.col    { flex-direction: column; }
.ac     { align-items: center; }
.jb     { justify-content: space-between; }
.f1     { flex: 1; }
.gap-2  { gap: 8px; }
.gap-3  { gap: 12px; }
.gap-4  { gap: 16px; }

/* ══════════════════════════════════════════
   SIDEBAR — negro Tesla
   ══════════════════════════════════════════ */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  position: fixed;
  top: 0; left: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  z-index: 200;
  overflow-y: auto;
}

.sidebar-logo {
  padding: 24px 20px 20px;
  border-bottom: 1px solid var(--sidebar-border);
}
.logo-lockup {
  display: flex;
  align-items: center;
  gap: 10px;
}
.logo-icon {
  width: 34px; height: 34px;
  background: var(--blue);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.logo-icon svg { width: 19px; height: 19px; fill: #fff; }
.logo-text .logo-name {
  font-size: 15px; font-weight: 600;
  color: #fff; letter-spacing: -.01em;
}
.logo-text .logo-role {
  font-size: 10.5px; color: rgba(255,255,255,.38);
  letter-spacing: .05em; text-transform: uppercase;
}

.nav-section { padding: 18px 0 4px; }
.nav-section-label {
  padding: 0 20px 6px;
  font-size: 9.5px; font-weight: 700;
  letter-spacing: .09em; text-transform: uppercase;
  color: rgba(255,255,255,.28);
}

.nav-list { list-style: none; }
.nav-list a {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 20px;
  color: var(--sidebar-text);
  font-size: 13.5px;
  font-weight: 400;
  transition: color var(--t-fast), background var(--t-fast);
  text-decoration: none;
  position: relative;
  cursor: pointer;
}
.nav-list a:hover {
  background: var(--sidebar-hover);
  color: #fff;
  text-decoration: none;
}
.nav-list a.active {
  color: var(--sidebar-active);
  background: rgba(255,255,255,.07);
  font-weight: 500;
}
.nav-list a.active::before {
  content: '';
  position: absolute;
  left: 0; top: 5px; bottom: 5px;
  width: 2px; background: var(--blue);
  border-radius: 0 2px 2px 0;
}
.nav-icon {
  width: 16px; height: 16px; flex-shrink: 0;
  opacity: .5;
  transition: opacity var(--t-fast);
}
.nav-list a:hover .nav-icon,
.nav-list a.active .nav-icon { opacity: 1; }

.nav-badge {
  margin-left: auto;
  background: var(--blue);
  color: #fff;
  font-size: 10px; font-weight: 600;
  padding: 1px 6px; border-radius: 10px;
}

.sidebar-footer {
  margin-top: auto;
  padding: 14px 18px;
  border-top: 1px solid var(--sidebar-border);
}
.user-row {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 8px; border-radius: var(--r-sm);
  cursor: pointer;
  transition: background var(--t-fast);
}
.user-row:hover { background: var(--sidebar-hover); }
.user-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--blue);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600; color: #fff;
  flex-shrink: 0;
}
.user-name  { font-size: 13px; font-weight: 500; color: #fff; }
.user-role  { font-size: 11px; color: rgba(255,255,255,.38); }
.user-caret { margin-left: auto; color: rgba(255,255,255,.3); font-size: 14px; }

/* Status dots */
.dot {
  width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0;
  display: inline-block;
}
.dot-green { background: #22C55E; box-shadow: 0 0 0 2px rgba(34,197,94,.2); }
.dot-red   { background: var(--red); }
.dot-amber { background: #F59E0B; }
.dot-blue  { background: var(--blue); }

/* ══════════════════════════════════════════
   CARDS
   ══════════════════════════════════════════ */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 20px 22px;
  box-shadow: var(--sh-sm);
}

.card-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.card-title {
  font-size: 13px; font-weight: 700;
  letter-spacing: .04em; text-transform: uppercase;
  color: var(--text-3); margin: 0;
}

/* ══════════════════════════════════════════
   MÉTRICAS
   ══════════════════════════════════════════ */
.metric {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 22px 24px;
  box-shadow: var(--sh-sm);
  transition: box-shadow var(--t-mid), transform var(--t-mid);
}
.metric:hover { box-shadow: var(--sh-md); transform: translateY(-1px); }

.metric-label {
  font-size: 11px; font-weight: 700;
  letter-spacing: .06em; text-transform: uppercase;
  color: var(--text-4); margin-bottom: 10px;
}
.metric-value {
  font-size: 36px; font-weight: 700;
  letter-spacing: -.03em; color: var(--text-1); line-height: 1;
}
.metric-sub { font-size: 12px; color: var(--text-4); margin-top: 8px; }
.metric-up   { color: var(--green); font-weight: 500; }
.metric-down { color: var(--red);   font-weight: 500; }

/* ══════════════════════════════════════════
   BOTONES
   ══════════════════════════════════════════ */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 7px; padding: 9px 18px;
  border-radius: var(--r-sm);
  font-family: var(--font); font-size: 13.5px; font-weight: 500;
  border: 1px solid transparent; cursor: pointer;
  transition: all var(--t-fast) var(--ease);
  white-space: nowrap; letter-spacing: -.01em;
  text-decoration: none; line-height: 1.4;
}
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn:active:not(:disabled) { transform: scale(.97); }

.btn-primary {
  background: var(--blue); color: #fff;
  box-shadow: 0 1px 0 rgba(0,0,0,.12);
}
.btn-primary:hover:not(:disabled) {
  background: var(--blue-d); color: #fff; text-decoration: none;
  box-shadow: 0 2px 8px rgba(54,101,243,.35);
}

.btn-secondary {
  background: var(--bg-surface); color: var(--text-1);
  border-color: var(--border-md);
}
.btn-secondary:hover:not(:disabled) {
  background: var(--bg-hover); text-decoration: none;
}

.btn-danger {
  background: var(--red-lt); color: var(--red);
  border-color: rgba(232,33,39,.2);
}
.btn-danger:hover:not(:disabled) { background: #FADADB; }

.btn-ghost {
  background: transparent; color: var(--text-2);
  border-color: var(--border);
}
.btn-ghost:hover:not(:disabled) { background: var(--bg-hover); }

.btn-sm  { padding: 6px 12px; font-size: 12px; border-radius: var(--r-xs); }
.btn-lg  { padding: 12px 28px; font-size: 15px; border-radius: var(--r-md); }
.btn-full{ width: 100%; }
.btn-icon{ padding: 8px; border-radius: var(--r-xs); }

/* ══════════════════════════════════════════
   INPUTS
   ══════════════════════════════════════════ */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block; font-size: 12.5px; font-weight: 600;
  color: var(--text-2); margin-bottom: 6px;
}

.input,
input[type="text"],  input[type="email"],
input[type="password"], input[type="tel"],
input[type="number"], input[type="date"],
input[type="search"], textarea, select {
  width: 100%;
  padding: 9px 13px;
  background: var(--bg-surface);
  border: 1.5px solid var(--border-md);
  border-radius: var(--r-xs);
  font-family: var(--font); font-size: 14px;
  color: var(--text-1);
  outline: none;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
  -webkit-appearance: none;
}
input::placeholder, textarea::placeholder { color: var(--text-4); }
input:hover, textarea:hover, select:hover { border-color: var(--border-md); }
input:focus, textarea:focus, select:focus {
  border-color: var(--blue);
  box-shadow: var(--sh-blue);
}

textarea { resize: vertical; min-height: 90px; }
select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%236B6D71' d='M6 8L0 0h12z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; }

.form-hint  { font-size: 11.5px; color: var(--text-4); margin-top: 5px; }
.form-error { font-size: 11.5px; color: var(--red); margin-top: 5px; font-weight: 500; }

/* Input con icono */
.input-wrap { position: relative; }
.input-wrap .i-icon {
  position: absolute; left: 12px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-4); font-size: 15px; pointer-events: none;
}
.input-wrap input { padding-left: 38px; }

/* Toggle */
.toggle-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.toggle-row:last-child { border-bottom: none; }
.toggle-info { flex: 1; }
.toggle-info .ti-label { font-size: 13.5px; font-weight: 500; color: var(--text-1); }
.toggle-info .ti-desc  { font-size: 12px; color: var(--text-4); margin-top: 2px; }

.toggle {
  position: relative; width: 44px; height: 26px; flex-shrink: 0;
}
.toggle input { display: none; }
.toggle-track {
  position: absolute; inset: 0;
  background: #D1D5DB;
  border-radius: 13px; cursor: pointer;
  transition: background var(--t-mid);
}
.toggle input:checked + .toggle-track { background: var(--blue); }
.toggle-track::after {
  content: ''; position: absolute;
  top: 3px; left: 3px;
  width: 20px; height: 20px;
  background: #fff; border-radius: 50%;
  box-shadow: 0 1px 4px rgba(0,0,0,.25);
  transition: transform var(--t-mid) var(--ease);
}
.toggle input:checked + .toggle-track::after { transform: translateX(18px); }

/* ══════════════════════════════════════════
   BADGES
   ══════════════════════════════════════════ */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px; border-radius: 20px;
  font-size: 11.5px; font-weight: 600;
  white-space: nowrap;
}
.badge-blue   { background: var(--blue-lt); color: var(--blue-d); }
.badge-green  { background: var(--green-lt); color: #0F6E3E; }
.badge-red    { background: var(--red-lt); color: #B91C1C; }
.badge-amber  { background: var(--amber-lt); color: #92400E; }
.badge-gray   { background: var(--bg-inset); color: var(--text-3); }
.badge-purple { background: #F3EFFE; color: #6B21A8; }

.badge-bronce { background: #FEF3C7; color: #92400E; }
.badge-plata  { background: #F3F4F6; color: #374151; }
.badge-oro    { background: var(--amber-lt); color: #92400E; }
.badge-vip    { background: #F3EFFE; color: #6B21A8; }

/* ══════════════════════════════════════════
   TABLAS
   ══════════════════════════════════════════ */
.table-wrap { overflow-x: auto; border-radius: var(--r-md); border: 1px solid var(--border); }

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }

thead th {
  text-align: left;
  padding: 11px 16px;
  font-size: 10.5px; font-weight: 700;
  letter-spacing: .06em; text-transform: uppercase;
  color: var(--text-4);
  background: var(--bg-page);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-1);
  background: var(--bg-surface);
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #FAFAF8; }

/* ══════════════════════════════════════════
   MODALES
   ══════════════════════════════════════════ */
.overlay {
  position: fixed; inset: 0;
  background: rgba(23,26,32,.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; padding: 20px;
  animation: fade-in var(--t-mid) var(--ease);
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: 28px;
  width: 100%; max-width: 480px;
  max-height: 90vh; overflow-y: auto;
  box-shadow: var(--sh-lg);
  animation: modal-up var(--t-mid) var(--ease);
}
@keyframes modal-up {
  from { transform: translateY(10px) scale(.98); opacity: 0; }
  to   { transform: translateY(0) scale(1); opacity: 1; }
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 22px;
}
.modal-header h3 { margin: 0; font-size: 18px; }
.modal-close {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--bg-inset); border: 1px solid var(--border);
  color: var(--text-3); font-size: 16px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--t-fast);
}
.modal-close:hover { background: var(--bg-hover); color: var(--text-1); }
.modal-footer {
  display: flex; gap: 10px; justify-content: flex-end;
  margin-top: 22px; padding-top: 18px;
  border-top: 1px solid var(--border);
}

/* ══════════════════════════════════════════
   CUPONES — PWA cliente
   ══════════════════════════════════════════ */
.cupon {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 16px 18px;
  display: flex; align-items: center; gap: 14px;
  box-shadow: var(--sh-sm);
  transition: box-shadow var(--t-mid), transform var(--t-mid);
  cursor: pointer;
}
.cupon:hover { box-shadow: var(--sh-md); transform: translateY(-1px); }
.cupon.bloqueado { opacity: .55; cursor: default; }

.cupon-disc {
  width: 62px; height: 62px;
  background: var(--blue-lt); border: 1.5px solid rgba(54,101,243,.15);
  border-radius: var(--r-sm);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; flex-shrink: 0;
}
.cupon-disc .pct { font-size: 22px; font-weight: 700; color: var(--blue); line-height: 1; }
.cupon-disc .off { font-size: 10px; color: var(--blue); font-weight: 500; opacity: .7; }
.cupon-nombre { font-size: 14px; font-weight: 500; color: var(--text-1); }
.cupon-vence  { font-size: 12px; color: var(--text-4); margin-top: 3px; }
.cupon-lock   { font-size: 20px; margin-left: auto; color: var(--text-4); }

/* ══════════════════════════════════════════
   ESTADOS VACÍOS
   ══════════════════════════════════════════ */
.empty {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 64px 24px; text-align: center; color: var(--text-4);
}
.empty-icon { font-size: 44px; margin-bottom: 16px; opacity: .4; }
.empty h4   { font-size: 15px; color: var(--text-2); margin-bottom: 6px; font-weight: 500; }
.empty p    { font-size: 13px; max-width: 280px; }

/* Skeleton */
.skel {
  background: linear-gradient(90deg, var(--bg-inset) 25%, var(--bg-hover) 50%, var(--bg-inset) 75%);
  background-size: 200% 100%;
  animation: skel 1.6s ease-in-out infinite;
  border-radius: var(--r-xs);
}
@keyframes skel { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ══════════════════════════════════════════
   ANIMACIONES DE ENTRADA
   ══════════════════════════════════════════ */
@keyframes slide-up {
  from { transform: translateY(14px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}
.a1 { animation: slide-up .32s var(--ease) both; }
.a2 { animation: slide-up .32s var(--ease) .06s both; }
.a3 { animation: slide-up .32s var(--ease) .12s both; }
.a4 { animation: slide-up .32s var(--ease) .18s both; }
.a5 { animation: slide-up .32s var(--ease) .24s both; }

/* ══════════════════════════════════════════
   UTILIDADES
   ══════════════════════════════════════════ */
.hidden  { display: none !important; }
hr, .divider { border: none; border-top: 1px solid var(--border); margin: 16px 0; }
.t1 { color: var(--text-1); } .t2 { color: var(--text-2); }
.t3 { color: var(--text-3); } .t4 { color: var(--text-4); }
.fw5 { font-weight: 500; } .fw6 { font-weight: 600; }
.mt4 { margin-top: 16px; } .mt6 { margin-top: 24px; }
.mb4 { margin-bottom: 16px; } .mb6 { margin-bottom: 24px; }
.p4  { padding: 16px; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tc { text-align: center; } .tr { text-align: right; }

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #D1D5DB; border-radius: 4px; }

/* ══════════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════════ */
@media (max-width: 900px) {
  :root { --sidebar-w: 0px; }
  .sidebar {
    transform: translateX(-224px);
    transition: transform var(--t-mid) var(--ease);
    width: 224px;
  }
  .sidebar.open { transform: translateX(0); box-shadow: var(--sh-lg); }
  /* Padding-top mayor + padding-left con espacio para el boton hamburguesa */
  .main { margin-left: 0; padding: 64px 18px 20px; }
  /* El page-header tiene un padding-left extra para no chocar con el hamburger */
  .page-header { padding-left: 0; min-height: 36px; }
  .page-header h1 { font-size: 20px; padding-left: 4px; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .modal { border-radius: var(--r-xl) var(--r-xl) 0 0; max-width: 100%; }
  .overlay { align-items: flex-end; padding: 0; }
}
