/* assets/panel.css — Tema oscuro profesional del panel IPTV.
   Sin frameworks. Tokens de diseño + layout sidebar + tablas y formularios legibles. */

:root {
  /* Superficies */
  --bg:            #0d1117;
  --bg-elev:       #141b24;
  --bg-elev-2:     #1b242f;
  --line:          #263240;
  --line-soft:     #1d2733;

  /* Texto */
  --text:          #e6edf3;
  --text-dim:      #9fb0c0;
  --text-mute:     #6b7d8f;

  /* Acento (azul frío) + estados */
  --accent:        #4c8dff;
  --accent-strong: #2f6fe0;
  --accent-soft:   rgba(76, 141, 255, 0.14);
  --ok:            #34c98a;
  --ok-soft:       rgba(52, 201, 138, 0.15);
  --warn:          #e6a33c;
  --warn-soft:     rgba(230, 163, 60, 0.15);
  --danger:        #f0556b;
  --danger-soft:   rgba(240, 85, 107, 0.15);

  /* Tipografía y ritmo */
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, "Helvetica Neue", Arial, sans-serif;
  --mono: "JetBrains Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --radius:   12px;
  --radius-s: 8px;
  --space:    20px;

  --shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.muted { color: var(--text-mute); }
.dim   { color: var(--text-dim); }

/* ============================ Layout ============================ */

.app {
  display: grid;
  grid-template-columns: 248px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--bg-elev);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 22px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 22px;
  border-bottom: 1px solid var(--line-soft);
  margin-bottom: 18px;
}
.brand-mark {
  font-weight: 800;
  letter-spacing: 0.5px;
  background: linear-gradient(135deg, var(--accent), #7aa9ff);
  color: #06101f;
  padding: 5px 9px;
  border-radius: var(--radius-s);
  font-size: 14px;
}
.brand-name { font-weight: 600; color: var(--text); }

.nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }

.nav-link {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border-radius: var(--radius-s);
  color: var(--text-dim);
  font-weight: 500;
  transition: background 0.14s ease, color 0.14s ease;
}
.nav-link:hover { background: var(--bg-elev-2); color: var(--text); text-decoration: none; }
.nav-link.active {
  background: var(--accent-soft);
  color: #cfe0ff;
  box-shadow: inset 2px 0 0 var(--accent);
}
.nav-ico { width: 18px; text-align: center; opacity: 0.85; }

.sidebar-foot {
  border-top: 1px solid var(--line-soft);
  padding-top: 14px;
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.who { color: var(--text-mute); font-size: 13px; padding: 0 12px; }
.nav-link.logout { color: var(--text-dim); }
.nav-link.logout:hover { color: var(--danger); }

.content { display: flex; flex-direction: column; min-width: 0; }

.topbar {
  padding: 24px 32px 0;
}
.page-title { font-size: 22px; font-weight: 700; margin: 0; letter-spacing: -0.2px; }

.page { padding: 22px 32px 40px; flex: 1; }

.appfoot {
  padding: 16px 32px;
  border-top: 1px solid var(--line-soft);
  font-size: 13px;
}

/* ============================ Cards / grid ============================ */

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 16px;
  margin-bottom: 26px;
}

.card {
  background: var(--bg-elev);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 18px 20px;
}
.stat .stat-label { font-size: 13px; color: var(--text-mute); text-transform: uppercase; letter-spacing: 0.6px; }
.stat .stat-value { font-size: 32px; font-weight: 700; margin-top: 6px; letter-spacing: -0.5px; }
.stat.ok      .stat-value { color: var(--ok); }
.stat.warn    .stat-value { color: var(--warn); }
.stat.danger  .stat-value { color: var(--danger); }
.stat.accent  .stat-value { color: var(--accent); }

.panel {
  background: var(--bg-elev);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 22px;
}
.panel > h2 {
  margin: 0 0 16px;
  font-size: 16px;
  font-weight: 650;
  letter-spacing: -0.1px;
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.panel-head h2 { margin: 0; }

/* ============================ Tablas ============================ */

.table-wrap { overflow-x: auto; border-radius: var(--radius-s); }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
thead th {
  text-align: left;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-mute);
  font-weight: 600;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
}
tbody tr:hover { background: rgba(255, 255, 255, 0.02); }
tbody tr:last-child td { border-bottom: none; }
td.mono, .mono { font-family: var(--mono); font-size: 13px; }
td.nowrap { white-space: nowrap; }

.empty {
  text-align: center;
  color: var(--text-mute);
  padding: 36px 0;
}

/* ============================ Badges ============================ */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  line-height: 1.6;
}
.badge.ok      { background: var(--ok-soft);     color: var(--ok); }
.badge.warn    { background: var(--warn-soft);   color: var(--warn); }
.badge.danger  { background: var(--danger-soft); color: var(--danger); }
.badge.neutral { background: var(--bg-elev-2);   color: var(--text-dim); }
.badge.accent  { background: var(--accent-soft); color: #aecdff; }

/* ============================ Botones ============================ */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font: inherit;
  font-weight: 600;
  font-size: 14px;
  padding: 9px 16px;
  border-radius: var(--radius-s);
  border: 1px solid var(--line);
  background: var(--bg-elev-2);
  color: var(--text);
  cursor: pointer;
  transition: background 0.14s ease, border-color 0.14s ease, transform 0.05s ease;
  text-decoration: none;
}
.btn:hover { background: #222e3b; text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent-strong);
  color: #06101f;
}
.btn-primary:hover { background: var(--accent-strong); color: #fff; }
.btn-danger {
  background: transparent;
  border-color: var(--danger);
  color: var(--danger);
}
.btn-danger:hover { background: var(--danger-soft); }
.btn-ghost { background: transparent; }
.btn-ghost:hover { background: var(--bg-elev-2); }
.btn-sm { padding: 6px 11px; font-size: 13px; }

.btn:focus-visible,
.nav-link:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.actions-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* ============================ Formularios ============================ */

label { display: block; font-size: 13px; color: var(--text-dim); margin-bottom: 6px; font-weight: 500; }

input[type="text"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="url"],
input[type="search"],
select,
textarea {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  padding: 9px 12px;
  transition: border-color 0.14s ease, box-shadow 0.14s ease;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  outline: none;
}
textarea { resize: vertical; min-height: 76px; }
select { appearance: none; cursor: pointer; }

.field { margin-bottom: 16px; }
.field:last-child { margin-bottom: 0; }

.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }

.check {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 14px;
  color: var(--text);
  cursor: pointer;
  margin-bottom: 0;
}
.check input { width: auto; }

.hint { font-size: 12px; color: var(--text-mute); margin-top: 5px; }

.searchbar {
  display: flex;
  gap: 10px;
  margin-bottom: 18px;
  max-width: 520px;
}
.searchbar input { flex: 1; }

/* ============================ Alertas ============================ */

.alert {
  padding: 12px 16px;
  border-radius: var(--radius-s);
  margin-bottom: 18px;
  font-size: 14px;
  border: 1px solid transparent;
}
.alert.ok      { background: var(--ok-soft);     border-color: rgba(52,201,138,0.3);  color: #7ee0b6; }
.alert.error   { background: var(--danger-soft); border-color: rgba(240,85,107,0.3);  color: #ff9aaa; }
.alert.info    { background: var(--accent-soft); border-color: rgba(76,141,255,0.3);  color: #aecdff; }

/* ============================ Login ============================ */

.login-page, .install-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(900px 500px at 20% -10%, rgba(76,141,255,0.12), transparent),
    var(--bg);
  padding: 24px;
}
.login-card, .install-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 34px 30px;
  box-shadow: var(--shadow);
}
.install-card { max-width: 560px; }
.login-card h1, .install-card h1 {
  margin: 0 0 4px;
  font-size: 22px;
  letter-spacing: -0.3px;
}
.login-sub { color: var(--text-mute); font-size: 14px; margin-bottom: 26px; }
.login-card .btn { width: 100%; justify-content: center; }
.login-brand {
  display: inline-block;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent), #7aa9ff);
  color: #06101f;
  padding: 6px 10px;
  border-radius: var(--radius-s);
  margin-bottom: 18px;
}

.install-log { list-style: none; padding: 0; margin: 18px 0; }
.install-log li {
  padding: 7px 0;
  border-bottom: 1px solid var(--line-soft);
  font-size: 14px;
  color: var(--text-dim);
}
.install-log li.spacer { border: none; padding: 4px 0; }
.install-actions { margin-top: 22px; }

/* ============================ Sub-CRUD playlists ============================ */

.pl-table td input,
.pl-table td select { padding: 7px 9px; font-size: 13px; }
.pl-table .pl-remove { white-space: nowrap; }
.pl-table .pl-dns { width: 100%; margin-bottom: 6px; }
.pl-table .pl-creds { display: flex; gap: 6px; }
.pl-table .pl-creds input { flex: 1; min-width: 0; }
.pl-table .pl-m3u input { width: 100%; }

.section-divider {
  border: none;
  border-top: 1px solid var(--line);
  margin: 26px 0;
}

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

/* ============================ Responsive ============================ */

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    height: auto;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
  }
  .brand { border: none; margin: 0; padding: 4px 8px; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .sidebar-foot { border: none; margin: 0; padding: 0; flex-direction: row; align-items: center; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}
