/* ============================================================
   PANAM Admin — Design tokens + layout
   Porta admin.css del prototipo a Blazor
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=Manrope:wght@400;500;600;700&family=Instrument+Serif:ital@0;1&display=swap');

:root {
  --aubergine: #3a0f48;
  --aubergine-deep: #2b0937;
  --purple: #5a1670;
  --magenta: #a428b6;
  --magenta-bright: #c23bd6;
  --gold: #c8a24c;
  --gold-light: #e7cf8f;
  --green: #3aa856;
  --blue: #2a6fdb;
  --orange: #d9741a;
  --red: #c4385a;
  --paper: #f6f2f8;
  --paper-2: #efe8f3;
  --white: #fff;
  --ink: #1d0b25;
  --muted: #6e5a78;
  --line: rgba(58,15,72,.12);
  --line-soft: rgba(58,15,72,.07);
  --sb: #2b0937;
  --shadow-sm: 0 2px 10px rgba(45,9,55,.06);
  --shadow: 0 18px 50px -18px rgba(45,9,55,.22);
  --ff-display: 'Space Grotesk', sans-serif;
  --ff-body: 'Manrope', sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; font-family: var(--ff-body); color: var(--ink); background: var(--paper); -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }

/* ── Shell ── */
.admin-shell {
  display: grid;
  grid-template-columns: 250px 1fr;
  min-height: 100vh;
}
.admin-main { display: flex; flex-direction: column; min-width: 0; }
.admin-content { padding: 28px 32px 60px; flex: 1; }

/* ── Sidebar ── */
.sb {
  background: var(--sb);
  color: #fff;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  transition: transform .3s;
  z-index: 90;
}

.sb-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 22px 22px 18px;
}

.logo-dots {
  display: grid;
  grid-template-columns: repeat(3, 7px);
  grid-template-rows: repeat(3, 7px);
  gap: 2.5px;
}
.logo-dots span { border-radius: 50%; }

.sb-wordmark {
  font-family: var(--ff-display);
  font-weight: 700;
  font-size: 1.4rem;
  color: #fff;
  letter-spacing: -.03em;
}

.sb-tag {
  font-family: var(--ff-display);
  font-weight: 600;
  font-size: .58rem;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--gold-light);
  background: rgba(231,207,143,.12);
  padding: .3em .5em;
  border-radius: 5px;
  margin-left: auto;
}

.sb-group { padding: 10px 14px; }
.sb-lbl {
  font-family: var(--ff-display);
  font-weight: 600;
  font-size: .64rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: rgba(255,255,255,.4);
  padding: 10px 10px 6px;
}

.sb-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border-radius: 10px;
  color: rgba(255,255,255,.78);
  font-family: var(--ff-display);
  font-weight: 500;
  font-size: .9rem;
  transition: .2s;
  width: 100%;
  text-align: left;
  position: relative;
}
.sb-item svg { width: 18px; height: 18px; flex-shrink: 0; opacity: .85; }
.sb-item:hover { background: rgba(255,255,255,.08); color: #fff; }
.sb-item.active, .sb-item:global(.active) {
  background: var(--magenta);
  color: #fff;
  box-shadow: 0 8px 20px -8px rgba(164,40,182,.7);
}

.sb-foot {
  margin-top: auto;
  padding: 16px 18px;
  border-top: 1px solid rgba(255,255,255,.1);
}
.sb-foot a {
  display: flex;
  align-items: center;
  gap: 9px;
  color: rgba(255,255,255,.7);
  font-size: .85rem;
  font-weight: 500;
  font-family: var(--ff-display);
}
.sb-foot a:hover { color: #fff; }
.sb-foot svg { width: 16px; height: 16px; }

.sb-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 89;
}

/* ── Topbar ── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line-soft);
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 14px 28px;
}

.tb-search {
  flex: 1;
  max-width: 420px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--paper-2);
  border-radius: 999px;
  padding: .65em 1.1em;
}
.tb-search input {
  border: none;
  background: transparent;
  outline: none;
  font-family: var(--ff-body);
  font-size: .92rem;
  width: 100%;
  color: var(--ink);
}

.tb-toggle {
  display: none;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  color: var(--ink);
}
.tb-toggle svg { width: 20px; height: 20px; }

.tb-right { margin-left: auto; display: flex; align-items: center; gap: 14px; }

.tb-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--muted);
  transition: .2s;
  position: relative;
}
.tb-icon:hover { background: var(--paper-2); color: var(--magenta); }

.tb-user { display: flex; align-items: center; gap: 10px; padding-left: 14px; border-left: 1px solid var(--line-soft); }
.tb-av {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--magenta), var(--purple));
  color: #fff;
  display: grid;
  place-items: center;
  font-family: var(--ff-display);
  font-weight: 700;
  font-size: .92rem;
}
.tb-nm {
  font-family: var(--ff-display);
  font-weight: 600;
  font-size: .88rem;
  line-height: 1.1;
}
.tb-nm small { display: block; color: var(--muted); font-weight: 500; font-size: .74rem; }

/* ── Page header ── */
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.page-crumb {
  font-family: var(--ff-display);
  font-weight: 600;
  font-size: .74rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--magenta);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.page-crumb a { color: var(--magenta); }
.page-head h1 {
  font-family: var(--ff-display);
  font-weight: 700;
  font-size: 1.8rem;
  letter-spacing: -.02em;
  color: var(--aubergine);
}
.page-head p { color: var(--muted); font-size: .95rem; margin-top: 3px; }

/* ── Stat cards ── */
.stats-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: #fff;
  border: 1px solid var(--line-soft);
  border-radius: 16px;
  padding: 20px;
  box-shadow: var(--shadow-sm);
}
.stat-card-top { display: flex; align-items: center; justify-content: space-between; }
.stat-ic { width: 42px; height: 42px; border-radius: 11px; display: grid; place-items: center; }
.stat-ic svg { width: 21px; height: 21px; }
.stat-delta {
  font-family: var(--ff-display);
  font-weight: 600;
  font-size: .78rem;
  padding: .25em .6em;
  border-radius: 999px;
}
.stat-delta-up { background: rgba(58,168,86,.12); color: var(--green); }
.stat-delta-flat { background: var(--paper-2); color: var(--muted); }
.stat-num { font-family: var(--ff-display); font-weight: 700; font-size: 2rem; letter-spacing: -.02em; color: var(--ink); margin-top: 16px; line-height: 1; }
.stat-lbl { color: var(--muted); font-size: .88rem; margin-top: 4px; }

/* ── Panel cards ── */
.panel {
  background: #fff;
  border: 1px solid var(--line-soft);
  border-radius: 16px;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line-soft);
}
.panel-head h3 { font-family: var(--ff-display); font-weight: 700; font-size: 1.05rem; }
.panel-head a { font-family: var(--ff-display); font-weight: 600; font-size: .84rem; color: var(--magenta); }
.panel-body { padding: 8px 22px 18px; }

/* ── Tabs ── */
.admin-tabs { display: flex; gap: 6px; margin-bottom: 16px; flex-wrap: wrap; }
.admin-tab {
  font-family: var(--ff-display);
  font-weight: 600;
  font-size: .86rem;
  color: var(--muted);
  padding: .55em 1em;
  border-radius: 999px;
  transition: .2s;
  cursor: pointer;
  border: none;
  background: none;
}
.admin-tab:hover { color: var(--magenta); }
.admin-tab.active { background: var(--magenta); color: #fff; }
.admin-tab .tab-count { margin-left: .4em; opacity: .7; font-size: .8em; }

/* ── Table ── */
.table-wrap {
  background: #fff;
  border: 1px solid var(--line-soft);
  border-radius: 16px;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.admin-table { width: 100%; border-collapse: collapse; }
.admin-table thead th {
  font-family: var(--ff-display);
  font-weight: 600;
  font-size: .72rem;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: left;
  padding: 14px 16px;
  background: var(--paper);
  border-bottom: 1px solid var(--line-soft);
}
.admin-table tbody td { padding: 12px 16px; border-bottom: 1px solid var(--line-soft); font-size: .9rem; vertical-align: middle; }
.admin-table tbody tr:last-child td { border-bottom: none; }
.admin-table tbody tr:hover td { background: var(--paper); }

.prog-cell { display: flex; align-items: center; gap: 12px; }
.prog-thumb { width: 52px; height: 40px; border-radius: 8px; background-size: cover; background-position: center; flex-shrink: 0; }
.prog-cell b { font-family: var(--ff-display); font-weight: 600; font-size: .94rem; display: block; color: var(--ink); }
.prog-cell span { color: var(--muted); font-size: .8rem; }

/* Tags */
.tg { font-family: var(--ff-display); font-weight: 600; font-size: .74rem; padding: .32em .7em; border-radius: 999px; display: inline-flex; align-items: center; gap: .4em; }
.tg .d { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.tg-aereo { background: rgba(164,40,182,.1); color: var(--magenta); }
.tg-terr { background: rgba(58,168,86,.1); color: var(--green); }
.tg-api { background: rgba(42,111,219,.1); color: var(--blue); }
.tg-manual { background: rgba(164,40,182,.1); color: var(--magenta); }
.tg-pub { background: rgba(58,168,86,.12); color: var(--green); }
.tg-draft { background: var(--paper-2); color: var(--muted); }

.price-cell { font-family: var(--ff-display); font-weight: 700; color: var(--orange); font-size: .94rem; }
.price-cell small { display: block; color: var(--gold); font-weight: 600; font-size: .74rem; }

.table-foot { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; color: var(--muted); font-size: .85rem; }

/* Row actions */
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.row-btn { width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; color: var(--muted); transition: .2s; cursor: pointer; }
.row-btn:hover { background: var(--paper-2); color: var(--magenta); }
.row-btn-del:hover { color: var(--red) !important; background: rgba(196,56,90,.1) !important; }
.row-btn svg { width: 16px; height: 16px; }

/* Star */
.star-btn { color: var(--line); transition: .2s; cursor: pointer; }
.star-btn.starred { color: var(--gold); }
.star-btn:hover { transform: scale(1.15); }
.star-btn svg { width: 19px; height: 19px; }

/* ── Form ── */
.form-grid { display: grid; grid-template-columns: 1fr 320px; gap: 18px; align-items: start; }
.form-col { display: flex; flex-direction: column; gap: 16px; }
.fcard { background: #fff; border: 1px solid var(--line-soft); border-radius: 16px; box-shadow: var(--shadow-sm); padding: 24px; }
.fcard h3 { font-family: var(--ff-display); font-weight: 700; font-size: 1.05rem; margin-bottom: 4px; }
.fcard .fhint, .fhint { color: var(--muted); font-size: .85rem; margin-bottom: 18px; }

/* Filas y campos del formulario */
.frow { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field.full { grid-column: 1 / -1; }
.field label {
  font-family: var(--ff-display);
  font-weight: 600;
  font-size: .76rem;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--muted);
}
.field input,
.field select,
.field textarea {
  font-family: var(--ff-body);
  font-size: .94rem;
  color: var(--ink);
  border: 1.5px solid var(--line);
  border-radius: 10px;
  padding: .7em .9em;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
  background: #fff;
  width: 100%;
}
.field textarea { resize: vertical; min-height: 90px; }
.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--magenta);
  box-shadow: 0 0 0 3px rgba(164,40,182,.12);
}
.field select {
  appearance: none;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='13' height='13' viewBox='0 0 24 24' fill='none' stroke='%23a428b6' stroke-width='2.5'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .8em center;
  padding-right: 2em;
}
/* Número: quitar spinner en algunos browsers */
.field input[type=number] { appearance: textfield; }
.field input[type=number]::-webkit-inner-spin-button { opacity: 1; }

/* Segmented (tipo) */
.seg { display: flex; gap: 6px; background: var(--paper-2); padding: 5px; border-radius: 12px; width: fit-content; }
.seg-btn { font-family: var(--ff-display); font-weight: 600; font-size: .88rem; color: var(--muted); padding: .55em 1.1em; border-radius: 9px; display: flex; align-items: center; gap: .5em; transition: .2s; cursor: pointer; }
.seg-btn svg { width: 16px; height: 16px; }
.seg-btn.active { background: #fff; color: var(--magenta); box-shadow: var(--shadow-sm); }

/* Toggle switch */
.toggle-row { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--line-soft); }
.toggle-row:last-of-type { border-bottom: none; }
.toggle-row b { font-family: var(--ff-display); font-weight: 600; font-size: .9rem; display: block; }
.toggle-row span { color: var(--muted); font-size: .78rem; }
.sw { width: 44px; height: 25px; border-radius: 999px; background: var(--line); position: relative; transition: .25s; flex-shrink: 0; cursor: pointer; }
.sw::after { content:""; position: absolute; top: 3px; left: 3px; width: 19px; height: 19px; border-radius: 50%; background: #fff; transition: .25s; box-shadow: 0 1px 4px rgba(0,0,0,.2); }
.sw.on { background: var(--magenta); }
.sw.on::after { transform: translateX(19px); }

/* Uploads */
.upload-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 10px; }
.upload-slot { aspect-ratio: 1; border: 1.6px dashed var(--line); border-radius: 12px; display: grid; place-items: center; color: var(--muted); cursor: pointer; transition: .2s; background: var(--paper); position: relative; overflow: hidden; }
.upload-slot:hover { border-color: var(--magenta); color: var(--magenta); }
.upload-slot svg { width: 22px; height: 22px; }
.upload-slot.filled { border-style: solid; border-color: transparent; }
.upload-slot .up-img { position: absolute; inset: 0; background-size: cover; background-position: center; }

/* Salidas table */
.sal-table { border: 1px solid var(--line-soft); border-radius: 12px; overflow: hidden; }
.sal-row { display: grid; grid-template-columns: 1.1fr 1fr .8fr 1fr auto; gap: 10px; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--line-soft); }
.sal-row:last-child { border-bottom: none; }
.sal-head { background: var(--paper); font-family: var(--ff-display); font-weight: 600; font-size: .7rem; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.sal-row input { border: 1px solid var(--line); border-radius: 8px; padding: .5em .6em; font-size: .85rem; font-family: var(--ff-body); outline: none; width: 100%; }
.sal-row input:focus { border-color: var(--magenta); }

/* Quick actions */
.quick-actions { display: flex; flex-direction: column; gap: 8px; padding: 16px 22px 20px; }
.quick-link { display: flex; align-items: center; gap: 11px; padding: 12px 14px; border-radius: 11px; background: var(--paper); font-family: var(--ff-display); font-weight: 600; font-size: .9rem; transition: .2s; cursor: pointer; }
.quick-link:hover { background: var(--paper-2); transform: translateX(3px); }
.quick-link .ql-ic { width: 32px; height: 32px; border-radius: 9px; background: rgba(164,40,182,.1); color: var(--magenta); display: grid; place-items: center; }
.quick-link .ql-ic svg { width: 16px; height: 16px; }
.quick-link svg.arr { width: 15px; height: 15px; margin-left: auto; color: var(--muted); }

/* API Sync card */
.sync-card { padding: 20px 22px; }
.sync-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line-soft); }
.sync-row:last-child { border-bottom: none; }
.sync-ic { width: 38px; height: 38px; border-radius: 10px; background: rgba(42,111,219,.1); color: var(--blue); display: grid; place-items: center; flex-shrink: 0; }
.sync-ic svg { width: 19px; height: 19px; }
.sync-row b { font-family: var(--ff-display); font-weight: 600; font-size: .92rem; display: block; }
.sync-row span { color: var(--muted); font-size: .8rem; }
.sync-status { margin-left: auto; font-family: var(--ff-display); font-weight: 600; font-size: .76rem; padding: .35em .7em; border-radius: 999px; display: inline-flex; align-items: center; gap: .4em; }
.sync-ok { background: rgba(58,168,86,.12); color: var(--green); }
.sync-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* Placeholder */
.module-placeholder { background: #fff; border: 1px solid var(--line-soft); border-radius: 16px; box-shadow: var(--shadow-sm); padding: 60px 30px; text-align: center; }
.module-placeholder .ph-ic { width: 64px; height: 64px; border-radius: 18px; background: var(--paper-2); color: var(--magenta); display: grid; place-items: center; margin: 0 auto 18px; }
.module-placeholder .ph-ic svg { width: 30px; height: 30px; }
.module-placeholder h2 { font-family: var(--ff-display); font-weight: 700; font-size: 1.4rem; color: var(--aubergine); margin-bottom: 6px; }
.module-placeholder p { color: var(--muted); max-width: 42ch; margin: 0 auto; }

/* ── Responsive ── */
@media (max-width: 1080px) {
  .stats-grid { grid-template-columns: repeat(2,1fr); }
  .form-grid { grid-template-columns: 1fr; }
}

@media (max-width: 820px) {
  .admin-shell { grid-template-columns: 1fr; }
  .sb { position: fixed; left: 0; top: 0; bottom: 0; width: 250px; transform: translateX(-100%); transition: transform .3s; }
  .sb.sb-open { transform: none; }
  .tb-toggle { display: grid; }
}

@media (max-width: 560px) {
  .stats-grid { grid-template-columns: 1fr; }
  .admin-content { padding: 16px 16px 40px; }
}
