/* ══════════════════════════════════════════════════════
   Create Blue Skies — Game Master Dashboard
   ══════════════════════════════════════════════════════ */

:root {
  --bg: #0a0e1a;
  --surface: #111827;
  --surface-2: #1a2234;
  --border: #1e293b;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --green: #10b981;
  --red: #f43f5e;
  --amber: #f59e0b;
  --p1: #f59e0b; --p2: #10b981; --p3: #8b5cf6;
  --p4: #f43f5e; --p5: #06b6d4; --p6: #ec4899; --p7: #6366f1;
  --nav-width: 200px;
  --nav-collapsed: 56px;
  --header-height: 52px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg); color: var(--text); line-height: 1.5;
  min-height: 100vh;
}

/* ── Global Header ── */
.global-header {
  position: fixed; top: 0; left: var(--nav-width); right: 0;
  height: var(--header-height); z-index: 900;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 1.5rem;
  background: linear-gradient(180deg, #0f172a 0%, var(--bg) 100%);
  border-bottom: 1px solid var(--border);
  transition: left 0.3s ease;
}
.nav-collapsed .global-header { left: var(--nav-collapsed); }

.global-header .brand { display: flex; align-items: center; gap: 0.75rem; }
.global-header h1 { font-size: 1.1rem; font-weight: 700; letter-spacing: -0.02em; white-space: nowrap; }
.global-header h1 .highlight { color: var(--accent); }
.gm-badge {
  font-size: 0.6rem; font-weight: 700; text-transform: uppercase;
  background: var(--accent); color: var(--bg); padding: 0.15rem 0.5rem;
  border-radius: 4px; letter-spacing: 0.08em;
}
.header-meta { display: flex; align-items: center; gap: 1rem; }
.header-meta .sync-text { color: var(--muted); font-size: 0.7rem; }
.btn-refresh {
  background: var(--surface); border: 1px solid var(--border); color: var(--muted);
  padding: 0.3rem 0.7rem; border-radius: 6px; font-size: 0.75rem;
  cursor: pointer; transition: all 0.2s;
}
.btn-refresh:hover { border-color: var(--accent); color: var(--accent); }

/* ── Left Navigation Sidebar ── */
.nav-sidebar {
  position: fixed; left: 0; top: 0; height: 100vh;
  width: var(--nav-width); z-index: 1000;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  transition: width 0.3s ease;
  overflow: hidden;
}
.nav-collapsed .nav-sidebar { width: var(--nav-collapsed); }

.nav-toggle {
  display: flex; align-items: center; justify-content: center;
  width: 100%; height: var(--header-height);
  background: none; border: none; border-bottom: 1px solid var(--border);
  color: var(--muted); font-size: 1.2rem; cursor: pointer;
  transition: color 0.2s;
}
.nav-toggle:hover { color: var(--accent); }

.nav-items { flex: 1; padding: 0.5rem 0; overflow-y: auto; }

.nav-item {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.6rem 1rem; cursor: pointer;
  color: var(--muted); text-decoration: none;
  transition: all 0.2s; border-left: 3px solid transparent;
  white-space: nowrap; overflow: hidden;
}
.nav-item:hover { background: rgba(56, 189, 248, 0.05); color: var(--text); }
.nav-item.active { border-left-color: var(--accent); color: var(--accent); background: rgba(56, 189, 248, 0.08); }
.nav-item .nav-icon { font-size: 1.1rem; min-width: 24px; text-align: center; }
.nav-item .nav-label { font-size: 0.8rem; font-weight: 500; }
.nav-collapsed .nav-item .nav-label { opacity: 0; }

.nav-divider { height: 1px; background: var(--border); margin: 0.5rem 0.75rem; }

/* ── Main Content Area ── */
.dashboard-content {
  margin-top: var(--header-height);
  margin-left: var(--nav-width);
  padding: 1.5rem;
  transition: margin-left 0.3s ease;
  max-width: 1600px;
}
.nav-collapsed .dashboard-content { margin-left: var(--nav-collapsed); }

/* ── Sections ── */
.dashboard-section { display: none; }
.dashboard-section.active { display: block; animation: fadeIn 0.25s ease; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1.5rem; flex-wrap: wrap; gap: 0.5rem;
}
.section-title { font-size: 1.3rem; font-weight: 700; }
.section-subtitle { color: var(--muted); font-size: 0.8rem; }

/* ── Widget Grid (Home) ── */
.widget-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
}

.widget-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 1.25rem;
  transition: border-color 0.2s, transform 0.15s;
  position: relative; overflow: hidden;
}
.widget-card.clickable { cursor: pointer; }
.widget-card.clickable:hover { border-color: var(--accent); transform: translateY(-2px); }
.widget-card .widget-accent {
  position: absolute; top: 0; left: 0; right: 0; height: 3px;
}
.widget-title {
  font-size: 0.75rem; color: var(--muted); text-transform: uppercase;
  letter-spacing: 0.06em; margin-bottom: 0.75rem; font-weight: 600;
}
.widget-value { font-size: 2rem; font-weight: 800; line-height: 1.1; margin-bottom: 0.35rem; }
.widget-detail { font-size: 0.8rem; color: var(--muted); }
.widget-footer { margin-top: 0.75rem; font-size: 0.7rem; color: var(--muted); }

/* ── Delta Badges ── */
.delta { font-size: 0.8rem; padding: 0.15rem 0.5rem; border-radius: 999px; font-weight: 600; display: inline-block; }
.delta.up { background: rgba(16,185,129,0.15); color: #10b981; }
.delta.down { background: rgba(244,63,94,0.15); color: #f43f5e; }
.delta.flat { background: rgba(148,163,184,0.15); color: #94a3b8; }

/* ── Status Indicators ── */
.status-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.status-dot.active { background: var(--green); box-shadow: 0 0 6px rgba(16,185,129,0.5); }
.status-dot.dormant { background: var(--muted); }
.status-dot.warning { background: var(--amber); box-shadow: 0 0 6px rgba(245,158,11,0.5); }

/* ── Cards (reusable) ── */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 1.25rem; margin-bottom: 1rem;
}
.card h3 { font-size: 0.95rem; color: var(--muted); margin-bottom: 0.75rem; }
.card canvas { max-height: 300px; }

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

/* ── Data Tables ── */
.data-table { width: 100%; border-collapse: collapse; font-size: 0.8rem; }
.data-table th {
  text-align: left; padding: 0.5rem 0.75rem; color: var(--muted);
  border-bottom: 1px solid var(--border); font-weight: 600; font-size: 0.7rem;
  text-transform: uppercase; letter-spacing: 0.05em;
}
.data-table td { padding: 0.5rem 0.75rem; border-bottom: 1px solid rgba(30,41,59,0.4); }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: rgba(56,189,248,0.03); }

/* ── Progress Bars ── */
.progress-bar { background: var(--surface-2); border-radius: 6px; height: 8px; overflow: hidden; }
.progress-bar .fill { height: 100%; border-radius: 6px; transition: width 0.5s ease; }

.progress-bar-lg { height: 24px; border-radius: 8px; position: relative; }
.progress-bar-lg .fill { border-radius: 8px; }
.progress-bar-lg .label {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  font-size: 0.7rem; font-weight: 700; color: var(--text);
}

/* ── Power Gauge (Aether vs Nox) ── */
.power-gauge { display: flex; flex-direction: column; gap: 0.5rem; }
.power-row { display: flex; align-items: center; gap: 0.75rem; }
.power-row .power-label { font-size: 0.8rem; font-weight: 600; min-width: 60px; }
.power-row .power-bar { flex: 1; height: 20px; background: var(--surface-2); border-radius: 10px; overflow: hidden; }
.power-row .power-fill { height: 100%; border-radius: 10px; transition: width 0.6s ease; }
.power-row .power-value { font-size: 0.85rem; font-weight: 700; min-width: 40px; text-align: right; }

/* ── Character Cards ── */
.character-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 1rem; text-align: center;
  transition: border-color 0.2s; cursor: pointer;
}
.character-card:hover { border-color: var(--accent); }
.character-card.selected { border-color: var(--accent); background: rgba(56,189,248,0.05); }
.character-avatar {
  width: 56px; height: 56px; border-radius: 50%; margin: 0 auto 0.5rem;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem; border: 2px solid var(--border);
}
.character-card .char-name { font-weight: 700; font-size: 0.9rem; }
.character-card .char-role { color: var(--muted); font-size: 0.7rem; margin-bottom: 0.5rem; }
.character-card .char-stats { font-size: 0.75rem; color: var(--muted); }

/* ── Timeline ── */
.timeline {
  position: relative; padding: 1rem 0;
  display: flex; align-items: center; gap: 0;
}
.timeline-segment {
  flex: 1; height: 6px; border-radius: 3px; position: relative;
}
.timeline-segment.completed { background: var(--accent); }
.timeline-segment.current { background: linear-gradient(90deg, var(--accent), var(--border)); }
.timeline-segment.locked { background: var(--surface-2); }
.timeline-marker {
  position: absolute; top: -6px; width: 18px; height: 18px;
  border-radius: 50%; border: 2px solid var(--accent); background: var(--bg);
}
.timeline-label {
  position: absolute; top: 14px; font-size: 0.65rem; color: var(--muted);
  white-space: nowrap; transform: translateX(-30%);
}

/* ── Seasonal Grid ── */
.season-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.5rem; }
.season-cell {
  padding: 0.5rem; border-radius: 8px; text-align: center; font-size: 0.7rem;
  border: 1px solid var(--border);
}
.season-cell.completed { background: rgba(16,185,129,0.1); border-color: var(--green); color: var(--green); }
.season-cell.current { background: rgba(56,189,248,0.1); border-color: var(--accent); color: var(--accent); }
.season-cell.locked { background: var(--surface); color: var(--muted); }
.season-cell .season-name { font-weight: 600; }
.season-cell .season-arc { font-size: 0.6rem; color: var(--muted); margin-top: 0.15rem; }

/* ── Funnel ── */
.funnel { display: flex; flex-direction: column; gap: 0.5rem; }
.funnel-step {
  display: flex; align-items: center; gap: 1rem;
  padding: 0.75rem 1rem; border-radius: 8px;
  background: var(--surface-2);
}
.funnel-step .step-label { flex: 1; font-size: 0.85rem; font-weight: 500; }
.funnel-step .step-value { font-size: 1.1rem; font-weight: 700; }
.funnel-step .step-bar { flex: 2; }

/* ── GPI Section (preserved from original) ── */
.gpi-top-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.6rem 0; margin-bottom: 0.5rem;
  flex-wrap: wrap; gap: 0.5rem;
}
.gpi-top-bar .brand { display: flex; align-items: center; gap: 0.75rem; }
.gpi-top-bar h2 { font-size: 1.2rem; font-weight: 700; letter-spacing: -0.02em; }
.gpi-top-bar h2 span { color: var(--accent); }
.gpi-top-bar .gpi-inline { display: flex; align-items: center; gap: 0.5rem; }
.gpi-top-bar .gpi-num { font-size: 1.8rem; font-weight: 800; color: var(--accent); }
.gpi-top-bar .meta { color: var(--muted); font-size: 0.7rem; text-align: right; }

.pillar-strip {
  display: flex; justify-content: center; gap: 0.5rem; padding: 0.5rem 0;
  flex-wrap: wrap;
}
.pillar-chip {
  display: flex; align-items: center; gap: 0.35rem;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 0.3rem 0.6rem; font-size: 0.75rem;
  transition: border-color 0.2s; cursor: default;
}
.pillar-chip:hover { border-color: var(--accent); }
.pillar-chip .dot { width: 8px; height: 8px; border-radius: 50%; }
.pillar-chip .chip-name { color: var(--muted); }
.pillar-chip .chip-score { font-weight: 700; }

.pillar-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 0.5rem; }

.metric-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.3rem 0; font-size: 0.8rem; border-bottom: 1px solid rgba(30,41,59,0.4);
}
.metric-row:last-child { border-bottom: none; }
.metric-name { color: var(--muted); flex: 1; }
.metric-value { font-weight: 600; min-width: 4.5rem; text-align: right; }
.metric-delta { min-width: 3.5rem; text-align: right; font-size: 0.75rem; font-weight: 500; }
.metric-delta.up { color: #10b981; }
.metric-delta.down { color: #f43f5e; }
.metric-delta.neutral { color: #94a3b8; }

.chart-section { margin: 1.5rem 0; }
.chart-container {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 1.25rem; margin-bottom: 1rem;
}
.chart-container h3 { font-size: 0.95rem; color: var(--muted); margin-bottom: 0.75rem; }
.chart-container canvas { max-height: 300px; }

.pillar-charts-section { margin: 1.5rem 0; }
.pillar-charts-section > h2 { font-size: 1.3rem; font-weight: 700; margin-bottom: 1rem; }

.pillar-chart-pair {
  display: grid; grid-template-columns: 220px 1fr 220px; gap: 1rem;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 1.25rem; margin-bottom: 1rem;
  align-items: start;
}
.pillar-chart-pair .pie-side { display: flex; flex-direction: column; align-items: center; }
.pillar-chart-pair .pie-side canvas { max-width: 200px; max-height: 200px; }
.pillar-chart-pair .line-side canvas { max-height: 220px; }
.pillar-chart-pair .data-side { font-size: 0.8rem; }
.pillar-chart-pair .data-side .pillar-label {
  font-weight: 700; font-size: 0.85rem; margin-bottom: 0.5rem;
  display: flex; align-items: center; gap: 0.4rem;
}
.pillar-chart-pair h3 { font-size: 0.85rem; color: var(--muted); margin-bottom: 0.5rem; text-align: center; }

.gpi-footer { text-align: center; padding: 2rem 0; color: var(--muted); font-size: 0.75rem; border-top: 1px solid var(--border); }

/* ── Loading / Error ── */
.loading { text-align: center; padding: 4rem; color: var(--muted); font-size: 1.1rem; }
.error { text-align: center; padding: 2rem; color: var(--red); }

/* ── Broadcasts & Approvals ── */
.tab-btn {
  background: var(--surface); border: 1px solid var(--border); color: var(--muted);
  padding: 0.4rem 0.8rem; border-radius: 6px; cursor: pointer; font-size: 0.75rem;
  transition: all 0.2s;
}
.tab-btn:hover { border-color: var(--accent); color: var(--text); }
.tab-btn.active { background: var(--accent); color: #0a0e1a; border-color: var(--accent); font-weight: 600; }

.filter-btn {
  background: var(--surface-2); border: 1px solid var(--border); color: var(--muted);
  padding: 0.3rem 0.6rem; border-radius: 4px; cursor: pointer; font-size: 0.7rem;
  transition: all 0.2s;
}
.filter-btn:hover { border-color: var(--accent); color: var(--text); }
.filter-btn.active { background: var(--surface); border-color: var(--accent); color: var(--accent); }

.broadcast-tab { display: none; }
.broadcast-tab.active { display: block; }

.approval-card { transition: opacity 0.3s, border-color 0.3s; }

.msg-type-badge {
  display: inline-block; padding: 0.1rem 0.4rem; border-radius: 4px;
  font-size: 0.65rem; font-weight: 600; text-transform: uppercase;
}
.msg-type-badge.post { background: #38bdf820; color: #38bdf8; }
.msg-type-badge.ad { background: #f59e0b20; color: #f59e0b; }
.msg-type-badge.sms { background: #10b98120; color: #10b981; }
.msg-type-badge.phone { background: #ec489920; color: #ec4899; }
.msg-type-badge.email { background: #8b5cf620; color: #8b5cf6; }

.approve-btn, .reject-btn, .edit-btn {
  padding: 0.25rem 0.6rem; border-radius: 4px; cursor: pointer;
  font-size: 0.7rem; font-weight: 500; border: 1px solid; transition: all 0.2s;
}
.approve-btn { background: #10b98120; color: #10b981; border-color: #10b98140; }
.approve-btn:hover { background: #10b98140; }
.approve-btn:disabled { opacity: 0.5; cursor: default; }
.reject-btn { background: #f43f5e20; color: #f43f5e; border-color: #f43f5e40; }
.reject-btn:hover { background: #f43f5e40; }
.reject-btn:disabled { opacity: 0.5; cursor: default; }
.edit-btn { background: var(--surface-2); color: var(--muted); border-color: var(--border); }
.edit-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ── Page Section Tabs ── */
.page-tab { display: none; }
.page-tab.active { display: block; }

/* ── Story Slot Cards ── */
.story-slot-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 1rem 1.25rem; margin-bottom: 0.75rem;
  transition: border-color 0.2s;
}
.story-slot-card:hover { border-color: var(--accent); }

/* ── Ticker List ── */
.ticker-list { display: flex; flex-direction: column; gap: 0.5rem; }
.ticker-list-item {
  display: flex; align-items: center; gap: 0.5rem;
}

/* ── Nav Link List ── */
.nav-link-list { display: flex; flex-direction: column; gap: 0.5rem; }
.nav-link-list-item {
  display: flex; align-items: center; gap: 0.5rem;
}

/* ── Pipeline Status ── */
.pipeline-status { font-size: 0.85rem; }

/* ── Trigger Button ── */
.trigger-btn {
  background: var(--accent); color: #0a0e1a; border: none;
  padding: 0.6rem 1.5rem; border-radius: 8px; font-size: 0.9rem;
  font-weight: 700; cursor: pointer; transition: all 0.2s;
  letter-spacing: 0.02em;
}
.trigger-btn:hover { background: #60ccfa; transform: translateY(-1px); }
.trigger-btn:active { transform: translateY(0); }
.trigger-btn:disabled { opacity: 0.5; cursor: default; transform: none; }

/* ── Content Tabs ── */
.content-tab { display: none; }
.content-tab.active { display: block; }

/* ── Edit Modal ── */
.edit-modal {
  position: fixed; inset: 0; z-index: 2000;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.7); backdrop-filter: blur(4px);
}
.edit-modal-content {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; width: 90%; max-width: 800px; max-height: 90vh;
  display: flex; flex-direction: column; overflow: hidden;
}
.edit-modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 1rem 1.5rem; border-bottom: 1px solid var(--border);
}
.edit-modal-header h3 { font-size: 1.1rem; font-weight: 700; }
.edit-modal-footer {
  display: flex; justify-content: flex-end; gap: 0.5rem;
  padding: 1rem 1.5rem; border-top: 1px solid var(--border);
}
#editModalBody {
  flex: 1; overflow-y: auto; padding: 1.5rem;
}

/* ── Edit Form ── */
.edit-form { display: flex; flex-direction: column; gap: 0.75rem; }
.form-row { display: flex; flex-direction: column; gap: 0.25rem; }
.form-row label {
  font-size: 0.7rem; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.05em;
}
.form-row input[type="text"],
.form-row input[type="number"],
.form-row input[type="datetime-local"],
.form-row select,
.form-row textarea {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 6px; padding: 0.5rem 0.75rem; color: var(--text);
  font-size: 0.85rem; font-family: inherit; transition: border-color 0.2s;
  width: 100%;
}
.form-row input:focus,
.form-row select:focus,
.form-row textarea:focus {
  outline: none; border-color: var(--accent);
}
.form-row textarea { resize: vertical; line-height: 1.5; }
.form-row-half {
  display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem;
}

/* ── Responsive ── */
@media (max-width: 1024px) {
  .pillar-chart-pair { grid-template-columns: 200px 1fr; }
  .pillar-chart-pair .data-side { grid-column: 1 / -1; }
}

@media (max-width: 768px) {
  .global-header { left: 0; padding: 0 1rem; }
  .global-header h1 { font-size: 0.95rem; }

  .nav-sidebar {
    top: auto; bottom: 0; left: 0; right: 0;
    width: 100% !important; height: 56px;
    flex-direction: row; border-right: none;
    border-top: 1px solid var(--border);
  }
  .nav-toggle { display: none; }
  .nav-items {
    display: flex; flex-direction: row; padding: 0;
    overflow-x: auto; gap: 0;
  }
  .nav-item {
    flex-direction: column; gap: 0.15rem;
    padding: 0.4rem 0.6rem; border-left: none;
    border-top: 2px solid transparent; font-size: 0.65rem;
    min-width: 56px; justify-content: center;
  }
  .nav-item.active { border-left-color: transparent; border-top-color: var(--accent); }
  .nav-item .nav-label { font-size: 0.55rem; opacity: 1 !important; }
  .nav-item .nav-icon { font-size: 1rem; }
  .nav-divider { display: none; }

  .dashboard-content { margin-left: 0; margin-bottom: 56px; padding: 1rem; }

  .pillar-chart-pair { grid-template-columns: 1fr; }
  .pillar-chart-pair .pie-side canvas { max-width: 180px; max-height: 180px; }

  .widget-grid { grid-template-columns: 1fr; }
  .card-grid { grid-template-columns: 1fr; }

  /* Content & Page section mobile */
  .form-row-half { grid-template-columns: 1fr; }
  .edit-modal-content { width: 95%; max-width: 100%; margin: 1rem; max-height: 90vh; }
  .section-header { flex-direction: column; gap: 0.5rem; }
  .section-header .btn { font-size: 0.75rem; padding: 0.4rem 0.8rem; }

  /* Tab bar scrollable on mobile */
  .content-tabs, .page-tabs {
    display: flex; overflow-x: auto; gap: 0;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .content-tabs::-webkit-scrollbar, .page-tabs::-webkit-scrollbar { display: none; }

  /* Story slot cards stack */
  .story-slot-card { padding: 0.75rem; }
  .story-slot-card .slot-actions { flex-wrap: wrap; gap: 0.4rem; }

  /* Ticker/nav lists full width */
  .ticker-list input, .nav-link-list input { width: 100%; }

  /* Pipeline trigger button */
  .trigger-btn { width: 100%; padding: 1rem; font-size: 1rem; }
}
