/* ════════════════════════════════════════════════════════════
   TechPackr · Admin dashboard
   Layout tipo wp-admin: topbar fijo + sidebar persistente + main.
   Mantiene los tokens de color de la app (var(--accent), --surface, etc.).
   ════════════════════════════════════════════════════════════ */

:root {
  --bg:        #0d0f1a;
  --surface:   #11131f;
  --surface2:  #181a28;
  --surface3:  #1f2230;
  --border:    #2a2d3c;
  --text:      #e8e8ed;
  --text2:     #b4b6c4;
  --text3:     #7a7d8d;
  --accent:    #6c63ff;
  --accent2:   #00c49a;
  --danger:    #e63946;
  --warning:   #f4a261;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}
a { color: inherit; text-decoration: none; }

/* ── Gate ── */
.admin-gate {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
  z-index: 9999;
}
.admin-gate-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px 36px;
  text-align: center;
  max-width: 420px;
}
.admin-gate-title { font-size: 16px; font-weight: 700; margin-bottom: 6px; }
.admin-gate-sub   { font-size: 13px; color: var(--text3); }
.admin-link       { color: var(--accent); font-size: 13px; }
.admin-link:hover { text-decoration: underline; }

/* ── Layout ── */
.admin-app { display: flex; flex-direction: column; min-height: 100vh; }

/* Topbar */
.admin-topbar {
  height: 54px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 18px;
  position: sticky; top: 0; z-index: 100;
}
.admin-topbar-left, .admin-topbar-right { display: flex; align-items: center; gap: 12px; }
.admin-brand { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.admin-brand-mark {
  width: 30px; height: 30px;
  display: inline-flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff; font-weight: 800; font-size: 13px;
  border-radius: 7px;
}
.admin-brand-name { font-weight: 700; }
.admin-brand-tag {
  font-size: 10px;
  background: var(--accent);
  color: #fff;
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: 4px;
  font-weight: 700;
  letter-spacing: .04em;
}
.admin-who { font-size: 12px; color: var(--text3); }

/* Body = sidebar + main */
.admin-body { display: flex; flex: 1; min-height: 0; }

/* Sidebar */
.admin-sidebar {
  width: 220px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 14px 0;
  overflow-y: auto;
  flex-shrink: 0;
}
.admin-side-group {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text3);
  padding: 12px 16px 6px;
  font-weight: 700;
}
.admin-side-link {
  display: block;
  padding: 8px 16px;
  font-size: 13px;
  color: var(--text2);
  border-left: 3px solid transparent;
  cursor: pointer;
  transition: .15s;
}
.admin-side-link:hover {
  background: var(--surface2);
  color: var(--text);
}
.admin-side-link.is-active {
  background: var(--surface2);
  color: var(--accent);
  border-left-color: var(--accent);
  font-weight: 600;
}

/* Main */
.admin-main {
  flex: 1;
  padding: 24px 28px;
  overflow-y: auto;
  background: var(--bg);
}
.admin-section { max-width: 1280px; }
.admin-section[hidden] { display: none; }

.admin-section-head { margin-bottom: 20px; }
.admin-section-head h1 { font-size: 22px; margin: 0 0 4px; font-weight: 700; }
.admin-section-head p  { margin: 0; color: var(--text3); font-size: 13px; }

/* Card */
.admin-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 18px;
}
.admin-card-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text3);
  font-weight: 700;
  margin-bottom: 10px;
}

/* KPIs */
.admin-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}
.admin-kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
}
.admin-kpi-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text3);
  font-weight: 600;
  margin-bottom: 6px;
}
.admin-kpi-value {
  font-size: 22px;
  font-weight: 800;
  color: var(--text);
}

/* Bar chart simple (roles) */
.admin-bar { display: flex; gap: 2px; height: 28px; border-radius: 6px; overflow: hidden; background: var(--surface2); }
.admin-bar-seg {
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: #fff;
  min-width: 40px;
}
.admin-bar-empty { padding: 6px 10px; color: var(--text3); font-size: 12px; }

/* Toolbar */
.admin-toolbar {
  display: flex; gap: 8px; margin-bottom: 14px;
  flex-wrap: wrap;
  align-items: center;
}
.admin-input {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text);
  font-size: 13px;
  padding: 7px 10px;
  outline: none;
  font-family: inherit;
}
.admin-input:focus { border-color: var(--accent); }

/* Botones */
.admin-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 600;
  padding: 7px 14px;
  cursor: pointer;
  font-family: inherit;
}
.admin-btn:hover { opacity: .9; }
.admin-btn-ghost {
  background: transparent;
  color: var(--text2);
  border: 1px solid var(--border);
}
.admin-btn-ghost:hover { background: var(--surface2); color: var(--text); }
.admin-btn-sm { padding: 4px 10px; font-size: 11px; }
.admin-btn-danger { background: var(--danger); }

/* Tablas */
.admin-table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.admin-table th, .admin-table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
.admin-table th {
  background: var(--surface2);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text3);
  font-weight: 700;
}
.admin-table tr:last-child td { border-bottom: none; }
.admin-table tr:hover td { background: var(--surface2); }
.admin-table .row-inactive td { opacity: .5; }

/* Pills */
.admin-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}

/* Secciones embebidas vía iframe (reutilizan el modal admin) */
.admin-section-embed { display: flex; flex-direction: column; height: calc(100vh - 54px - 48px); }
.admin-section-embed[hidden] { display: none; }
.admin-iframe-wrap {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  position: relative;
  min-height: 500px;
}
.admin-iframe-wrap iframe {
  width: 100%;
  height: 100%;
  border: none;
  background: transparent;
  display: block;
}
.admin-iframe-wrap .admin-iframe-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text3);
  font-size: 13px;
  pointer-events: none;
}

/* Empty */
.admin-empty {
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: 10px;
  padding: 32px 20px;
  color: var(--text3);
  text-align: center;
  font-size: 13px;
}

/* Toast */
.admin-toast {
  position: fixed;
  bottom: 20px; left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--surface3);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: .2s;
  z-index: 9999;
  box-shadow: 0 8px 24px rgba(0,0,0,.4);
}
.admin-toast.is-show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (max-width: 720px) {
  .admin-body { flex-direction: column; }
  .admin-sidebar { width: 100%; border-right: none; border-bottom: 1px solid var(--border); }
}
