/* ============================================================
   Loopcast — sistema de diseño
   Claro · minimalista · acento índigo · luz de tally para "al aire"
   ============================================================ */

:root {
  --bg:          #F7F8FA;
  --surface:     #FFFFFF;
  --surface-2:   #FBFBFD;
  --ink:         #1A1D29;
  --ink-muted:   #6B7180;
  --ink-faint:   #9AA0AD;
  --border:      #E7E9EF;
  --border-strong:#D5D9E2;

  --accent:      #4F46E5;
  --accent-hover:#4338CA;
  --accent-soft: #EEF0FE;

  --live:        #E5484D;   /* tally — SOLO para al aire */
  --ready:       #2FA36B;
  --warn:        #C99A2E;
  --stopped:     #9AA0AD;

  --radius:      10px;
  --radius-sm:   7px;
  --shadow-sm:   0 1px 2px rgba(20,25,45,.05);
  --shadow-md:   0 4px 16px rgba(20,25,45,.07);

  --font-display: 'Space Grotesk', system-ui, sans-serif;
  --font-body:    system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-mono:    ui-monospace, 'SF Mono', 'JetBrains Mono', Menlo, monospace;

  --sidebar-w: 244px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
h1, h2, h3 { font-family: var(--font-display); font-weight: 600; letter-spacing: -.02em; margin: 0; }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* ---------- shell ---------- */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 22px 22px 20px;
  font-family: var(--font-display);
  font-weight: 600; font-size: 19px; letter-spacing: -.02em;
}
.brand .loop { width: 22px; height: 22px; color: var(--accent); flex: 0 0 auto; }
.brand .dot { color: var(--live); }

.nav { padding: 6px 12px; display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 12px; border-radius: var(--radius-sm);
  color: var(--ink-muted); font-weight: 500; font-size: 14.5px;
  transition: background .12s, color .12s;
}
.nav a svg { width: 18px; height: 18px; flex: 0 0 auto; opacity: .85; }
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav a.active { background: var(--accent-soft); color: var(--accent); }
.nav a.active svg { opacity: 1; }

.sidebar-foot { margin-top: auto; padding: 14px; border-top: 1px solid var(--border); }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 6px 8px; }
.user-chip .avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--accent); color: #fff;
  display: grid; place-items: center; font-weight: 600; font-size: 14px;
  font-family: var(--font-display);
}
.user-chip .who { line-height: 1.2; }
.user-chip .who b { font-size: 14px; font-weight: 600; }
.user-chip .who span { font-size: 12px; color: var(--ink-faint); }
.logout { margin-left: auto; color: var(--ink-faint); padding: 6px; border-radius: 6px; }
.logout:hover { color: var(--live); background: var(--surface-2); }

/* ---------- main ---------- */
.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 32px; border-bottom: 1px solid var(--border);
  background: rgba(247,248,250,.8); backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 5;
}
.topbar h1 { font-size: 21px; }
.content { padding: 32px; max-width: 1180px; width: 100%; }

/* ---------- stat cards ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 32px; }
.stat {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px 22px; box-shadow: var(--shadow-sm);
}
.stat-num { font-family: var(--font-display); font-size: 34px; font-weight: 600; letter-spacing: -.03em;
  font-variant-numeric: tabular-nums; display: flex; align-items: center; gap: 10px; }
.stat-label { color: var(--ink-muted); font-size: 13px; margin-top: 2px;
  text-transform: uppercase; letter-spacing: .06em; font-weight: 500; }

/* ---------- tally light (la firma) ---------- */
.tally {
  width: 11px; height: 11px; border-radius: 50%;
  background: var(--live); flex: 0 0 auto;
  box-shadow: 0 0 0 0 rgba(229,72,77,.5);
  animation: tally-pulse 2s infinite;
}
.tally.sm { width: 8px; height: 8px; }
@keyframes tally-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(229,72,77,.45); }
  70%  { box-shadow: 0 0 0 7px rgba(229,72,77,0); }
  100% { box-shadow: 0 0 0 0 rgba(229,72,77,0); }
}

/* ---------- status pills ---------- */
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600;
  padding: 3px 10px; border-radius: 999px; }
.pill .dot { width: 7px; height: 7px; border-radius: 50%; }
.pill.live    { color: var(--live);   background: #FDECEC; }
.pill.ready   { color: var(--ready);  background: #E7F5EE; }
.pill.warn    { color: var(--warn);   background: #FBF3E0; }
.pill.stopped { color: var(--ink-muted); background: var(--surface-2); }
.pill.live .dot { background: var(--live); } .pill.ready .dot { background: var(--ready); }
.pill.warn .dot { background: var(--warn); } .pill.stopped .dot { background: var(--stopped); }

/* ---------- card / empty ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 24px; box-shadow: var(--shadow-sm); }
.card h2 { font-size: 17px; margin-bottom: 4px; }
.card .sub { color: var(--ink-muted); font-size: 14px; }

.empty { background: var(--surface); border: 1px dashed var(--border-strong); border-radius: var(--radius);
  padding: 48px 32px; text-align: center; }
.empty h2 { font-size: 20px; margin-bottom: 8px; }
.empty p { color: var(--ink-muted); max-width: 440px; margin: 0 auto; }
.empty .badge { display: inline-block; margin-bottom: 16px; font-size: 12px; font-weight: 600;
  letter-spacing: .06em; text-transform: uppercase; color: var(--accent);
  background: var(--accent-soft); padding: 4px 12px; border-radius: 999px; }

/* ---------- buttons / inputs ---------- */
.btn { font-family: var(--font-body); font-size: 14.5px; font-weight: 600;
  padding: 10px 18px; border-radius: var(--radius-sm); border: 1px solid transparent;
  cursor: pointer; transition: background .12s, border-color .12s; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-block { width: 100%; }

.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-muted); margin-bottom: 6px; }
.input {
  width: 100%; font-family: var(--font-body); font-size: 15px;
  padding: 11px 13px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink); transition: border-color .12s, box-shadow .12s;
}
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: 100%; max-width: 380px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-md); padding: 34px; }
.login-brand { display: flex; align-items: center; gap: 10px; justify-content: center;
  font-family: var(--font-display); font-weight: 600; font-size: 24px; letter-spacing: -.02em; margin-bottom: 6px; }
.login-brand .loop { width: 26px; height: 26px; color: var(--accent); }
.login-tag { text-align: center; color: var(--ink-muted); font-size: 14px; margin-bottom: 26px; }
.login-error { background: #FDECEC; color: var(--live); font-size: 14px; font-weight: 500;
  padding: 10px 14px; border-radius: var(--radius-sm); margin-bottom: 18px; }

/* ---------- focus & motion ---------- */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { .tally { animation: none; } }

/* ---------- responsive ---------- */
@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; align-items: center;
    border-right: none; border-bottom: 1px solid var(--border); }
  .nav { flex-direction: row; overflow-x: auto; padding: 8px; }
  .nav a span.label { display: none; }
  .sidebar-foot { border-top: none; border-left: 1px solid var(--border); margin: 0; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .content { padding: 20px; }
}


/* ============================================================
   Perfiles — lista en tarjetas, formulario y preview de logo
   ============================================================ */

/* encabezado de página */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.page-head .sub { color: var(--ink-muted); font-size: 14px; max-width: 620px; }

/* badges / pills */
.badge-default { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  color: var(--accent); background: var(--accent-soft); padding: 2px 8px; border-radius: 999px; }

/* lista de perfiles como tarjetas-fila */
.plist { display: flex; flex-direction: column; gap: 10px; }
.prow { display: flex; align-items: center; gap: 18px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 15px 18px; box-shadow: var(--shadow-sm);
  transition: border-color .12s, box-shadow .12s, transform .12s; }
.prow:hover { border-color: var(--border-strong); box-shadow: var(--shadow-md); }
.res-tile { width: 62px; height: 46px; border-radius: 9px; background: var(--accent-soft); color: var(--accent);
  display: grid; place-items: center; font-family: var(--font-display); font-weight: 600; font-size: 14px; flex: 0 0 auto; }
.prow .pmain { min-width: 0; }
.pname { font-weight: 600; font-size: 15.5px; display: flex; align-items: center; gap: 9px; }
.pdim { font-family: var(--font-mono); font-size: 12.5px; color: var(--ink-faint); margin-top: 2px; }
.pspecs { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.chip { font-family: var(--font-mono); font-size: 12.5px; color: var(--ink-muted); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 7px; padding: 5px 10px; white-space: nowrap; }
.pactions { display: flex; gap: 8px; flex: 0 0 auto; padding-left: 8px; }

/* botones extra */
.btn-ghost { background: transparent; border: 1px solid var(--border-strong); color: var(--ink); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { background: transparent; border: 1px solid transparent; color: var(--live); }
.btn-danger:hover { background: #FDECEC; }
.btn-sm { padding: 7px 13px; font-size: 13px; }

/* formulario — más compacto */
.form-sections { display: grid; gap: 16px; max-width: 780px; }
.fieldset { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px 22px; box-shadow: var(--shadow-sm); }
.fieldset h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .07em; color: var(--accent);
  margin-bottom: 3px; font-family: var(--font-body); font-weight: 700; }
.fieldset .hint { color: var(--ink-faint); font-size: 12.5px; margin-bottom: 16px; line-height: 1.45; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.field { margin-bottom: 12px; }
.field:last-child { margin-bottom: 0; }
.field label { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink-muted); margin-bottom: 5px; }
.input { width: 100%; font-family: var(--font-body); font-size: 14.5px; padding: 9px 12px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--ink);
  transition: border-color .12s, box-shadow .12s; }
.input.mono { font-family: var(--font-mono); }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
select.input { appearance: none; -webkit-appearance: none; cursor: pointer; padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236B7180' stroke-width='2.5'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; }

/* toggle */
.toggle-row { display: flex; align-items: center; gap: 12px; font-size: 14px; }
.toggle { position: relative; display: inline-block; width: 42px; height: 24px; flex: 0 0 auto; }
.toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle .track { position: absolute; inset: 0; background: var(--border-strong); border-radius: 999px; transition: background .15s; }
.toggle .track::before { content: ''; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.25); }
.toggle input:checked + .track { background: var(--accent); }
.toggle input:checked + .track::before { transform: translateX(18px); }

/* preview del logo */
.logo-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; align-items: start; }
.logo-preview { position: relative; width: 100%; aspect-ratio: 16/9; border-radius: 9px; overflow: hidden;
  background: linear-gradient(130deg, #232741 0%, #3c355f 55%, #5c4a63 100%); border: 1px solid var(--border-strong); }
.logo-preview::after { content: 'PREVIEW'; position: absolute; bottom: 8px; left: 10px; font-family: var(--font-mono);
  font-size: 9.5px; letter-spacing: .12em; color: rgba(255,255,255,.4); }
.logo-preview .wm { position: absolute; max-width: 40%; max-height: 40%; }
.logo-preview .wm.placeholder { display: grid; place-items: center; background: rgba(255,255,255,.92);
  color: #2b2f45; font-family: var(--font-display); font-weight: 600; font-size: 11px; padding: 7px 14px; border-radius: 5px; }
.logo-preview .wm-img { display: block; max-width: 100%; max-height: 100%; }
.logo-preview .res-tag { position: absolute; top: 8px; right: 10px; font-family: var(--font-mono); font-size: 10px;
  color: rgba(255,255,255,.6); background: rgba(0,0,0,.28); padding: 2px 7px; border-radius: 4px; }
.file-input input[type=file] { font-size: 12.5px; color: var(--ink-muted); width: 100%; }

.form-actions { display: flex; gap: 12px; justify-content: flex-end; max-width: 780px; margin-top: 6px; }
.form-error { background: #FDECEC; color: var(--live); font-size: 14px; font-weight: 500;
  padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 18px; max-width: 780px; }
.back-link { color: var(--accent); font-size: 14px; font-weight: 500; display: inline-flex; align-items: center; gap: 5px; margin-bottom: 18px; }

@media (max-width: 720px) { .grid-2, .grid-3, .logo-layout { grid-template-columns: 1fr; }
  .pspecs { display: none; } }
