/*
 * Panel Multi-Landing — sistema de diseño "Torre de control de señales".
 * Un componente, un lugar: todo lo visual del panel admin vive acá.
 * Archivo estático (sin build step) para que el navegador lo cachee entre
 * las ~20 pantallas del panel en vez de re-descargarlo en cada request.
 */

:root {
  --bg:            #EFF2F0;
  --surface:       #FFFFFF;
  --surface-alt:   #E4E9E6;
  --borde:         #DDE3E0;
  --texto:         #0F1B1D;
  --texto-muted:   #5B6B68;

  --acento:        #F2A93B;
  --acento-ink:    #7A5200;
  --vivo:          #2F6F6B;
  --alerta:        #E4573D;
  --borrador:      #8B9490;

  --fuente-display: 'Space Grotesk', -apple-system, BlinkMacSystemFont, sans-serif;
  --fuente-body:    -apple-system, BlinkMacSystemFont, 'Segoe UI', Inter, sans-serif;
  --fuente-mono:    'JetBrains Mono', 'SF Mono', Consolas, monospace;

  --sidebar-ancho: 240px;
  --sidebar-ancho-colapsado: 64px;
  --radio: 10px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--fuente-body);
  background: var(--bg);
  color: var(--texto);
  font-size: 14px;
  line-height: 1.5;
}

a { color: inherit; }

h1, h2 {
  font-family: var(--fuente-display);
  font-weight: 700;
  letter-spacing: -.01em;
  margin: 0 0 6px;
}
h1 { font-size: 24px; }
h2 { font-size: 17px; }
h3, h4 {
  font-family: var(--fuente-display);
  font-weight: 600;
  margin: 0 0 10px;
  font-size: 15px;
}

code, .mono {
  font-family: var(--fuente-mono);
  font-size: 12.5px;
}

.muted { color: var(--texto-muted); font-size: 13px; }

/* ── Foco de teclado visible en todo elemento interactivo ────────────────── */
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible,
textarea:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--acento);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ── Shell: sidebar fijo + contenido ──────────────────────────────────────── */
.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-ancho);
  flex: 0 0 var(--sidebar-ancho);
  background: var(--surface);
  border-right: 1px solid var(--borde);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  transition: width .18s ease, flex-basis .18s ease;
}

.sidebar-marca {
  padding: 20px 18px;
  font-family: var(--fuente-display);
  font-weight: 700;
  font-size: 16px;
  border-bottom: 1px solid var(--borde);
  display: flex;
  align-items: center;
  gap: 8px;
}
.sidebar-marca .punto { color: var(--acento); flex: none; }

.sidebar-colapsar {
  margin-left: auto;
  background: none;
  border: 1px solid var(--borde);
  border-radius: 6px;
  width: 22px;
  height: 22px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--texto-muted);
  font-size: 13px;
  line-height: 1;
  padding: 0;
  transition: transform .18s ease;
}
.sidebar-colapsar:hover { background: var(--surface-alt); color: var(--texto); }

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 14px 10px;
}
.sidebar-nav .grupo-titulo {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--texto-muted);
  padding: 6px 10px;
  font-weight: 700;
}
.sidebar-nav a.proyecto-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 10px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--texto);
  font-size: 13.5px;
  font-weight: 600;
}
.sidebar-nav a.proyecto-item:hover { background: var(--surface-alt); }
.sidebar-nav a.proyecto-item .nombre {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sidebar-nav a.proyecto-item .conteo {
  font-family: var(--fuente-mono);
  font-size: 11px;
  color: var(--texto-muted);
}
.sidebar-nav .vacio { padding: 8px 10px; font-size: 12.5px; color: var(--texto-muted); }

/* ── Resumen: leads de hoy / publicadas / generando, entre proyectos y el pie ── */
.sidebar-resumen {
  border-top: 1px solid var(--borde);
  padding: 12px 10px;
  flex: none;
}
.sidebar-resumen .resumen-fila {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  color: var(--texto-muted);
  padding: 4px 10px;
}
.sidebar-resumen .resumen-fila .mono { color: var(--texto); font-weight: 700; }

.sidebar-pie {
  border-top: 1px solid var(--borde);
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.sidebar-pie a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  color: var(--texto);
}
.sidebar-pie a:hover { background: var(--surface-alt); }
.sidebar-pie .usuario { padding: 4px 10px 8px; font-size: 11.5px; color: var(--texto-muted); }
.sidebar-pie .pie-icono {
  font-family: var(--fuente-mono);
  font-size: 10px;
  font-weight: 700;
  color: var(--texto-muted);
  flex: none;
  width: 20px;
}

.sidebar-toggle {
  display: none;
  position: fixed;
  top: 14px;
  left: 14px;
  z-index: 40;
  background: var(--surface);
  border: 1px solid var(--borde);
  border-radius: 8px;
  width: 38px;
  height: 38px;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.sidebar-toggle span, .sidebar-toggle span::before, .sidebar-toggle span::after {
  content: ''; display: block; width: 18px; height: 2px; background: var(--texto); border-radius: 2px;
  position: relative;
}
.sidebar-toggle span::before { position: absolute; top: -6px; }
.sidebar-toggle span::after { position: absolute; top: 6px; }

.contenido { flex: 1; min-width: 0; }
main.wrap { max-width: 1200px; margin: 0 auto; padding: 28px 30px; }

/* ── Tarjetas, tablas, formularios ─────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--borde);
  border-radius: var(--radio);
  padding: 20px 22px;
  margin-bottom: 18px;
}

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--borde); font-size: 13.5px; }
th { color: var(--texto-muted); font-weight: 700; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; }
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-alt); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: 8px;
  padding: 9px 16px;
  font-weight: 700;
  font-size: 13.5px;
  cursor: pointer;
  border: 1px solid transparent;
  background: var(--acento);
  color: var(--acento-ink);
  text-decoration: none;
  font-family: var(--fuente-body);
}
.btn:hover { filter: brightness(0.95); }
.btn.secundario, .btn.btn-secundario {
  background: var(--surface);
  color: var(--texto);
  border-color: var(--borde);
}
.btn.peligro, .btn.btn-peligro {
  background: transparent;
  color: var(--alerta);
  border-color: var(--alerta);
}
.btn-primary { background: var(--acento); color: var(--acento-ink); }

input[type=text], input[type=email], input[type=number], input[type=password],
input[type=url], input[type=date], input[type=file], select, textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--borde);
  border-radius: 8px;
  font-size: 13.5px;
  font-family: inherit;
  margin-bottom: 12px;
  background: var(--surface);
  color: var(--texto);
}
label { font-size: 12.5px; font-weight: 700; color: var(--texto); display: block; margin-bottom: 4px; }

.fila { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 18px; flex-wrap: wrap; }
.acciones { display: flex; gap: 8px; flex-wrap: wrap; }

.msg { padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; font-size: 13.5px; }
.msg.ok { background: #E3F0EE; color: var(--vivo); }
.msg.error { background: #FBE4DF; color: var(--alerta); }
.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; font-size: 13.5px; }
.flash-ok { background: #E3F0EE; color: var(--vivo); }
.flash-error { background: #FBE4DF; color: var(--alerta); }

.tabs { display: flex; gap: 6px; border-bottom: 2px solid var(--borde); margin-bottom: 18px; flex-wrap: wrap; }
.tabs a { padding: 10px 16px; text-decoration: none; color: var(--texto-muted); font-weight: 700; font-size: 13.5px; border-bottom: 2px solid transparent; margin-bottom: -2px; }
.tabs a.activo { color: var(--texto); border-color: var(--acento); }

/* ── LED de estado — elemento de firma ────────────────────────────────────── */
.led-linea { display: inline-flex; align-items: center; gap: 7px; }
.led {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex: none;
}
.led-acento   { background: var(--acento);   box-shadow: 0 0 0 4px rgba(242,169,59,.18); }
.led-vivo     { background: var(--vivo);     box-shadow: 0 0 0 4px rgba(47,111,107,.18); }
.led-borrador { background: var(--borrador); box-shadow: 0 0 0 4px rgba(139,148,144,.18); }
.led-alerta   { background: var(--alerta);   box-shadow: 0 0 0 4px rgba(228,87,61,.18); }

.led-pulso { animation: led-pulso 1.6s ease-in-out infinite; }
@keyframes led-pulso {
  0%, 100% { opacity: 1; }
  50% { opacity: .45; }
}
@media (prefers-reduced-motion: reduce) {
  .led-pulso { animation: none; }
  .sidebar, .sidebar-colapsar { transition: none; }
}

.codigo-landing { color: var(--texto-muted); margin-left: 6px; }

/* ── Tarjetas "conector" (integraciones tipo tracking) ────────────────────── */
.conector-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.conector-header h2 { margin: 0; }
.conector-icono {
  width: 38px; height: 38px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--fuente-mono); font-weight: 700; font-size: 11px;
  color: #fff; flex-shrink: 0; letter-spacing: .3px;
  background: var(--vivo);
}
.conector-ayuda { font-size: 12px; margin-top: -6px; }

/* ── Editor de landing: grid sidebar + preview ────────────────────────────── */
.editor-grid { display: grid; grid-template-columns: minmax(300px, 360px) minmax(0, 1fr); gap: 18px; align-items: start; }
.editor-sidebar { grid-column: 1; grid-row: 1; position: sticky; top: 18px; max-height: calc(100vh - 90px); overflow: auto; }
.editor-preview { grid-column: 2; grid-row: 1; min-width: 0; padding: 0; overflow: hidden; }
.preview-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px; border-bottom: 1px solid var(--borde); background: var(--surface-alt); }
.preview-toolbar strong { font-size: 13px; }
.device-switch { display: flex; gap: 4px; background: var(--surface-alt); padding: 3px; border-radius: 8px; }
.device-btn { appearance: none; border: 0; background: transparent; color: var(--texto-muted); padding: 7px 11px; border-radius: 6px; font-weight: 700; font-size: 12px; cursor: pointer; }
.device-btn.active { background: var(--surface); color: var(--texto); box-shadow: 0 1px 4px rgba(0,0,0,.12); }
.preview-stage { min-height: 680px; background: var(--surface-alt); padding: 16px; display: flex; justify-content: center; align-items: flex-start; overflow: auto; }
.preview-device { width: 100%; max-width: 100%; transition: width .18s ease, max-width .18s ease; }
.preview-device.desktop { width: 100%; max-width: 100%; }
.preview-device.mobile { width: 390px; max-width: 100%; }
.preview-device.mobile .visor-frame { height: 760px; border-radius: 18px; box-shadow: 0 10px 30px rgba(0,0,0,.18); }
.visor-frame { display: block; width: 100%; height: 680px; border: 1px solid var(--borde); border-radius: 8px; background: var(--surface); }

/* ── Badges heredados (aún usados en algún estado sin LED) ────────────────── */
.badge { display: inline-block; padding: 3px 9px; border-radius: 20px; font-size: 11px; font-weight: 700; text-transform: uppercase; }
.badge.borrador { background: var(--surface-alt); color: var(--borrador); }
.badge.generado { background: #FBEEDC; color: var(--acento-ink); }
.badge.publicada { background: #E3F0EE; color: var(--vivo); }

/* ── Pantalla de auth (login / recuperar / restablecer) — sin sidebar ────── */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.auth-card { width: 100%; max-width: 380px; }
.auth-marca { font-family: var(--fuente-display); font-weight: 700; font-size: 18px; text-align: center; margin-bottom: 18px; }

/* ── Sidebar colapsable (icon rail) — solo desktop ────────────────────────── */
@media (min-width: 769px) {
  body.sidebar-colapsado .sidebar {
    width: var(--sidebar-ancho-colapsado);
    flex-basis: var(--sidebar-ancho-colapsado);
  }
  body.sidebar-colapsado .sidebar-marca { padding-left: 8px; padding-right: 8px; }
  body.sidebar-colapsado .sidebar-marca .texto,
  body.sidebar-colapsado .sidebar-nav .grupo-titulo,
  body.sidebar-colapsado .sidebar-nav .vacio,
  body.sidebar-colapsado .sidebar-nav a.proyecto-item .nombre,
  body.sidebar-colapsado .sidebar-nav a.proyecto-item .conteo,
  body.sidebar-colapsado .sidebar-resumen,
  body.sidebar-colapsado .sidebar-pie a .texto {
    display: none;
  }
  body.sidebar-colapsado .sidebar-colapsar { transform: rotate(180deg); }

  /* main.wrap tiene max-width + margin:0 auto (se centra). Sin esto, al liberar
     ancho el bloque de contenido solo se recentra en el espacio nuevo en vez de
     usarlo — se ve como un hueco parejo a los dos lados en vez de más ancho real. */
  body.sidebar-colapsado main.wrap { max-width: 1600px; }
}

/* ── Responsive: sidebar colapsa en mobile ────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar-toggle { display: flex; }
  .sidebar-colapsar { display: none; }
  .sidebar {
    position: fixed;
    z-index: 30;
    left: 0; top: 0;
    transform: translateX(-100%);
    transition: transform .2s ease;
    box-shadow: 0 0 0 rgba(0,0,0,0);
  }
  .shell.sidebar-abierto .sidebar { transform: translateX(0); box-shadow: 0 0 40px rgba(0,0,0,.25); }
  .shell.sidebar-abierto::after {
    content: ''; position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 20;
  }
  main.wrap { padding: 70px 16px 20px; }
  .editor-grid { grid-template-columns: 1fr; }
  .editor-sidebar, .editor-preview { grid-column: 1; }
  .editor-sidebar { position: static; max-height: none; grid-row: 2; }
  .editor-preview { grid-row: 1; }
  .preview-stage { min-height: 560px; padding: 10px; }
  .visor-frame { height: 600px; }
  .fila { grid-template-columns: 1fr; }
}
