/* Pantheon — pixel-medieval admin theme.
   Mirrors the frontend "Path of Kings" palette: dark purple-charcoal panels,
   bronze/gold borders, Press Start 2P for headings, square corners only. */

:root {
  --rpg-bg: #0d0a14;
  --rpg-panel: #16121f;
  --rpg-panel-light: #1f1930;
  --rpg-panel-lighter: #2a2140;
  --rpg-bronze: #8a6a2f;
  --rpg-gold: #e6b93f;
  --rpg-gold-dim: #b8963a;
  --rpg-text: #d8cfc0;
  --rpg-text-dim: #8f8578;
  --rpg-red: #b03a2e;
  --rpg-green: #5d8a4a;
}

* {
  box-sizing: border-box;
  border-radius: 0 !important; /* everything square */
}

body {
  margin: 0;
  background: var(--rpg-bg);
  color: var(--rpg-text);
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 16px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.pixel-font {
  font-family: 'Press Start 2P', monospace;
}

/* ---------- Header / nav ---------- */

.pantheon-header {
  background: var(--rpg-panel);
  border-bottom: 3px solid var(--rpg-bronze);
  padding: 14px 24px 0;
}

.header-inner {
  display: flex;
  align-items: baseline;
  gap: 16px;
}

.header-title {
  margin: 0;
  font-size: 20px;
  color: var(--rpg-gold);
  text-shadow: 2px 2px 0 #000;
  letter-spacing: 2px;
}

.header-subtitle {
  font-size: 9px;
  color: var(--rpg-text-dim);
}

.pantheon-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 14px;
}

.nav-link {
  font-size: 9px;
  color: var(--rpg-text);
  text-decoration: none;
  padding: 10px 14px;
  border: 3px solid transparent;
  border-bottom: none;
}

.nav-link:hover,
.nav-link.is-active {
  color: var(--rpg-gold);
  background: var(--rpg-panel-light);
  border-color: var(--rpg-bronze);
  border-bottom: none;
}

.nav-logout {
  margin-left: auto;
  color: var(--rpg-red);
}

.nav-logout:hover {
  color: #fff;
  background: var(--rpg-red);
}

/* ---------- Layout ---------- */

.pantheon-main {
  flex: 1;
  padding: 24px;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
}

.pantheon-footer {
  padding: 14px 24px;
  font-size: 8px;
  color: var(--rpg-text-dim);
  border-top: 3px solid var(--rpg-bronze);
  background: var(--rpg-panel);
  text-align: center;
}

.pantheon-version-stamp {
  position: fixed;
  left: 16px;
  bottom: 12px;
  z-index: 20;
  margin: 0;
  font-size: 8px;
  color: var(--rpg-gold-dim);
  text-shadow: 1px 1px 0 #000;
  pointer-events: none;
  letter-spacing: 1px;
}

.page-title {
  font-size: 14px;
  color: var(--rpg-gold);
  margin: 0 0 8px;
}

.page-subtitle {
  color: var(--rpg-text-dim);
  margin: 0 0 20px;
}

/* ---------- Panels (3px border, chamfered corners) ---------- */

.pixel-panel {
  background: var(--rpg-panel);
  border: 3px solid var(--rpg-bronze);
  padding: 16px;
  box-shadow: inset 0 0 0 2px #000, 6px 6px 0 rgba(0, 0, 0, 0.5);
  clip-path: polygon(
    12px 0, 100% 0, 100% calc(100% - 12px),
    calc(100% - 12px) 100%, 0 100%, 0 12px
  );
}

/* ---------- Buttons / inputs ---------- */

.pixel-btn {
  background: var(--rpg-bronze);
  color: #fff;
  border: 3px solid var(--rpg-gold-dim);
  padding: 12px 18px;
  font-size: 10px;
  cursor: pointer;
  text-shadow: 1px 1px 0 #000;
  box-shadow: inset -3px -3px 0 rgba(0, 0, 0, 0.35), inset 3px 3px 0 rgba(255, 255, 255, 0.12);
}

.pixel-btn:hover {
  background: var(--rpg-gold-dim);
}

.pixel-btn:active {
  box-shadow: inset 3px 3px 0 rgba(0, 0, 0, 0.35);
}

input[type="text"],
input[type="password"],
input[type="search"],
select,
textarea {
  width: 100%;
  background: var(--rpg-bg);
  color: var(--rpg-text);
  border: 3px solid var(--rpg-bronze);
  padding: 10px 12px;
  font-family: inherit;
  font-size: 15px;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--rpg-gold);
}

/* ---------- Flash messages ---------- */

.flash {
  margin: 16px auto 0;
  max-width: 1152px;
  padding: 12px 16px;
  border: 3px solid var(--rpg-bronze);
  background: var(--rpg-panel-light);
}

.flash-info { border-color: var(--rpg-bronze); }
.flash-success { border-color: var(--rpg-green); }
.flash-error { border-color: var(--rpg-red); color: #f0b8b2; }

/* ---------- Dashboard cards ---------- */

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.stat-card .stat-label {
  font-size: 9px;
  color: var(--rpg-text-dim);
  margin: 0 0 12px;
}

.stat-value {
  font-size: 34px;
  color: var(--rpg-gold);
  margin: 0;
  font-family: 'Press Start 2P', monospace;
}

.stat-hint {
  margin: 10px 0 0;
  font-size: 12px;
  color: var(--rpg-text-dim);
}

.range-switch {
  display: flex;
  gap: 8px;
  margin: 0 0 20px;
}

.range-link {
  font-size: 9px;
  color: var(--rpg-text-dim);
  text-decoration: none;
  padding: 8px 12px;
  border: 3px solid var(--rpg-panel-lighter);
}

.range-link:hover,
.range-link.is-active {
  color: var(--rpg-gold);
  border-color: var(--rpg-bronze);
}

body:has(.home-dashboard) .pantheon-main {
  max-width: 1360px;
}

.home-hero {
  display: grid;
  grid-template-columns: minmax(280px, 1.7fr) repeat(2, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.credit-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.credit-card .stat-label {
  margin: 0;
}

.credit-status {
  font-size: 8px;
  letter-spacing: 1px;
  padding: 6px 8px;
  border: 2px solid currentColor;
  white-space: nowrap;
}

.credit-card.tone-ok {
  border-color: var(--rpg-green);
}

.credit-card.tone-ok .credit-status {
  color: var(--rpg-green);
}

.credit-card.tone-warn {
  border-color: var(--rpg-gold);
}

.credit-card.tone-warn .credit-status,
.credit-card.tone-warn .credit-remaining {
  color: var(--rpg-gold);
}

.credit-card.tone-danger {
  border-color: var(--rpg-red);
}

.credit-card.tone-danger .credit-status,
.credit-card.tone-danger .credit-remaining {
  color: #f0b8b2;
}

.credit-card.tone-unknown .credit-status {
  color: var(--rpg-text-dim);
}

.credit-remaining {
  margin-top: 14px;
  font-size: 28px;
  line-height: 1.25;
  word-break: break-word;
}

.credit-meter {
  margin-top: 14px;
  height: 10px;
  background: var(--rpg-panel-lighter);
  border: 2px solid #000;
}

.credit-meter span {
  display: block;
  height: 100%;
  background: var(--rpg-gold);
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.35);
}

.credit-card.tone-danger .credit-meter span {
  background: var(--rpg-red);
}

.credit-card.tone-ok .credit-meter span {
  background: var(--rpg-green);
}

.credit-meter-caption,
.credit-runway,
.credit-error {
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--rpg-text-dim);
}

.credit-runway span {
  display: block;
  margin-top: 2px;
}

.credit-error {
  color: #f0b8b2;
}

.credit-chips {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 16px 0 0;
}

.credit-chips dt {
  font-family: 'Press Start 2P', monospace;
  font-size: 7px;
  color: var(--rpg-text-dim);
  margin: 0 0 6px;
}

.credit-chips dd {
  margin: 0;
  color: var(--rpg-gold);
  font-size: 15px;
}

.home-kpis {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.stat-card-compact .stat-value {
  font-size: 22px;
}

.chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 16px;
}

.chart-grid-bi {
  grid-template-columns: 1fr 1fr;
}

.chart-span-2 {
  grid-column: 1 / -1;
}

.chart-panel {
  min-height: 0;
  overflow: visible;
  clip-path: none;
}

.chart-title {
  font-size: 9px;
  color: var(--rpg-text-dim);
  margin: 0 0 6px;
}

.chart-caption {
  margin: 0 0 8px;
  font-size: 13px;
  color: var(--rpg-text-dim);
  font-style: italic;
}

.plotly-slot {
  width: 100%;
  height: 280px;
}

.plotly-slot-hero {
  height: 320px;
}

.plotly-slot .js-plotly-plot,
.plotly-slot .plot-container {
  width: 100% !important;
}

@media (max-width: 960px) {
  .home-hero,
  .chart-grid-bi {
    grid-template-columns: 1fr;
  }

  .chart-span-2 {
    grid-column: auto;
  }

  .credit-chips {
    grid-template-columns: 1fr;
  }
}

.feed-panel .stat-label {
  font-size: 9px;
  color: var(--rpg-text-dim);
  margin: 0 0 12px;
}

.feed-list {
  margin: 0;
  padding-left: 18px;
  line-height: 1.7;
}

.feed-empty {
  color: var(--rpg-text-dim);
  font-style: italic;
}

/* ---------- Login ---------- */

.login-body {
  background: var(--rpg-bg) url('/static/scenes/dungeon.webp') center / cover no-repeat fixed;
  align-items: center;
  justify-content: center;
}

.login-panel {
  width: 380px;
  max-width: calc(100vw - 32px);
  background: rgba(22, 18, 31, 0.94);
}

.login-title {
  font-size: 18px;
  color: var(--rpg-gold);
  text-shadow: 2px 2px 0 #000;
  text-align: center;
  margin: 0 0 8px;
}

.login-subtitle {
  text-align: center;
  color: var(--rpg-text-dim);
  font-style: italic;
  margin: 0 0 20px;
}


.login-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.login-form label {
  font-size: 9px;
  color: var(--rpg-gold-dim);
}

.login-btn {
  margin-top: 8px;
}

.login-panel .flash {
  margin: 0 0 16px;
  max-width: none;
}

/* ---------- Tables (shared by admin screens) ---------- */

.pixel-table {
  width: 100%;
  border-collapse: collapse;
}

.pixel-table th {
  font-family: 'Press Start 2P', monospace;
  font-size: 9px;
  color: var(--rpg-gold-dim);
  text-align: left;
  padding: 10px 12px;
  border-bottom: 3px solid var(--rpg-bronze);
}

.pixel-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--rpg-panel-lighter);
}

.pixel-table tr:hover td {
  background: var(--rpg-panel-light);
}

/* Estandarte: readable Pantheon workspace, following new-design/Pantheon Admin. */
.pixel-font { font-family: 'Pixelify Sans', sans-serif; letter-spacing: 0; }
body:not(.login-body) {
  font-family: 'Literata', Georgia, serif;
  background: #0f0c15;
  color: #e0d8c8;
  padding-left: 248px;
}
body:not(.login-body) .pantheon-header {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 30;
  width: 248px;
  overflow-y: auto;
  padding: 22px 12px;
  background: #16121f;
  border: 0;
  border-right: 1px solid #2e2440;
}
.header-inner { display: flex; flex-direction: column; align-items: flex-start; gap: 5px; padding: 0 8px; }
.header-title { font-family: 'Press Start 2P', monospace; font-size: 13px; letter-spacing: .02em; text-shadow: none; }
.header-subtitle { font: 13px 'Pixelify Sans', sans-serif; color: #8f8578; }
.pantheon-search { display: flex; align-items: center; margin: 24px 4px 0; border: 1px solid #2e2440; background: #0f0c15; }
.pantheon-search input { min-width: 0; width: 100%; padding: 8px; border: 0; background: transparent; color: #e0d8c8; font: 12px 'JetBrains Mono', monospace; }
.pantheon-search button { border: 0; background: transparent; color: #e6b93f; cursor: pointer; font-size: 20px; padding: 0 8px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.pantheon-nav { display: flex; flex-direction: column; flex-wrap: nowrap; gap: 1px; margin-top: 18px; }
.nav-group { margin: 16px 10px 5px; color: #756c60; font: 12px 'Pixelify Sans', sans-serif; letter-spacing: .12em; text-transform: uppercase; }
.nav-link { border: 0; border-left: 2px solid transparent; padding: 7px 10px; color: #b3a998; font: 13px 'JetBrains Mono', monospace; }
.nav-link:hover, .nav-link.is-active { border: 0; border-left: 2px solid #e6b93f; background: #1f1930; color: #e6b93f; }
.nav-logout { margin: 18px 0 0; color: #f0a79c; }
.nav-danger { color: #f0a79c; }
body:not(.login-body) .pantheon-main { max-width: none; padding: 28px clamp(18px, 3vw, 40px) 60px; margin: 0; }
.pantheon-footer { display: none; }
.pantheon-version-stamp { left: 16px; bottom: 12px; font: 11px 'JetBrains Mono', monospace; color: #756c60; max-width: 216px; }
.page-title { font: 600 clamp(26px, 3vw, 34px) 'Pixelify Sans', sans-serif; color: #f1e9da; margin-bottom: 4px; }
.page-subtitle { font-size: 15px; line-height: 1.55; margin-bottom: 22px; }
.pixel-panel { border: 1px solid #2e2440; box-shadow: none; clip-path: none; background: #16121f; }
.pixel-btn { border: 1px solid #8a6a2f; box-shadow: none; background: #1f1930; color: #e6b93f; font: 500 14px 'Pixelify Sans', sans-serif; text-shadow: none; min-height: 38px; padding: 8px 13px; }
.pixel-btn:hover { background: #e6b93f; color: #0d0a14; }
.pixel-table { font-family: 'JetBrains Mono', monospace; font-size: 12px; }
.pixel-table th { font-family: 'Pixelify Sans', sans-serif; font-size: 14px; }
.pixel-table th { border-bottom: 1px solid #2e2440; color: #9d9384; }
.pixel-table td { border-color: #221c2e; }
.dashboard > .card-grid { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; }
.dashboard .stat-card .stat-label { font: 14px 'Pixelify Sans', sans-serif; color: #9d9384; margin-bottom: 10px; }
.dashboard .stat-value { font: 26px 'JetBrains Mono', monospace; color: #f1e9da; }
.filter-form input, .filter-form select { border: 1px solid #3a2d17; background: #16121f; color: #e0d8c8; font: 13px 'JetBrains Mono', monospace; }
.social-queue-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.social-queue-heading h3 { margin: 0; }
.social-discard { border-color: #b03a2e; color: #f0a79c; }
.social-row-actions { white-space: nowrap; }
.social-row-actions form { display: inline; margin-left: 12px; }
.social-discard-link { border: 0; background: transparent; color: #f0a79c; cursor: pointer; padding: 6px 0; font: inherit; text-decoration: underline; }
.social-discard-link:hover { color: #fff; }
.social .pixel-panel h3.pixel-font { font-size: 18px !important; color: #f1e9da !important; }
.social form label.pixel-font { font-size: 13px !important; }
@media (max-width: 850px) {
  body:not(.login-body) { padding-left: 0; }
  body:not(.login-body) .pantheon-header { position: relative; inset: auto; width: 100%; padding: 12px 16px 0; overflow: visible; border: 0; border-bottom: 1px solid #2e2440; }
  .header-inner { flex-direction: row; align-items: center; gap: 12px; padding: 0; }
  .pantheon-nav { flex-direction: row; overflow-x: auto; margin-top: 10px; padding-bottom: 4px; }
  .pantheon-search { margin: 10px 0 0; }
  .nav-group { display: none; }
  .nav-link, .nav-link:hover, .nav-link.is-active { flex: 0 0 auto; border-left: 0; border-bottom: 2px solid transparent; }
  .nav-link:hover, .nav-link.is-active { border-bottom-color: #e6b93f; }
  .nav-logout { margin: 0; }
  .pantheon-version-stamp { display: none; }
  body:not(.login-body) .pantheon-main { padding: 20px 16px 48px; }
  .pixel-table { display: block; overflow-x: auto; }
  .social > div[style*="grid-template-columns"] { grid-template-columns: 1fr !important; }
}
