/** Platform Admin — admin-only styles
 *  Aligns color palette with the User CP nautical theme.
 */

/* ── Design Token Overrides — match User CP warm nautical palette ── */
:root {
  --accent: #f59e0b;
  --accent-hover: #fbbf24;
  --accent-glow: rgba(245, 158, 11, 0.4);
  --text-primary: #ebd69b;
  --text-secondary: #a89060;
  --text-muted: #8a7550;
  --bg-card: rgba(20, 30, 45, 0.85);
  --bg-secondary: #131d2e;
  --bg-hover: rgba(212, 185, 106, 0.08);
  --bg-active: rgba(212, 185, 106, 0.15);
  --border: rgba(212, 185, 106, 0.2);
  --border-focus: rgba(245, 158, 11, 0.6);
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #0ea5e9;
  --purple: #8b5cf6;
}

/* ── Sidebar — dark nautical style ── */
.sidebar {
  background: rgba(8, 12, 20, 0.75);
  border-right: 1px solid rgba(212, 185, 106, 0.2);
  backdrop-filter: blur(24px);
}

.sidebar-header {
  border-bottom: 1px solid rgba(212, 185, 106, 0.2);
}

.sidebar-title {
  color: #ebd69b;
  font-family: 'Georgia', serif;
  font-size: 16px;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.nav-item {
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  color: #a89060;
}

.nav-item:hover {
  background: rgba(212, 185, 106, 0.08);
  color: #ebd69b;
  transform: translateX(4px);
}

.nav-item.active {
  background: linear-gradient(90deg, rgba(212, 185, 106, 0.18) 0%, transparent 100%);
  border-left: 3px solid #d4b96a;
  color: #ebd69b;
  font-weight: 800;
}

.sidebar-section {
  color: #8a7550;
}

.sidebar-footer {
  border-top: 1px solid rgba(212, 185, 106, 0.15);
}

/* ── Main app background — deep navy with subtle diagonals ── */
.main-app {
  background-color: #040d21;
  background-image:
    radial-gradient(circle at 20% 30%, rgba(212, 185, 106, 0.06) 0%, transparent 50%),
    radial-gradient(circle at 80% 80%, rgba(245, 158, 11, 0.05) 0%, transparent 50%),
    url('data:image/svg+xml;utf8,<svg width="40" height="40" xmlns="http://www.w3.org/2000/svg"><g stroke="rgba(212,185,106,0.03)" stroke-width="1"><path d="M0 40 L40 0 M-10 10 L10 -10 M30 50 L50 30"/></g><circle cx="20" cy="20" r="1" fill="rgba(212,185,106,0.1)"/></svg>');
  background-size: cover, cover, 60px 60px;
  background-attachment: fixed;
}

/* ── Page container — warm nautical ── */
.page {
  max-width: 100%;
  background: radial-gradient(circle at center top, #1e2836 0%, #0a0e17 100%);
  color: #d4b96a;
  --text-primary: #ebd69b;
  --text-secondary: #a89060;
  --text-muted: #8a7550;
  --bg-card: rgba(20, 30, 45, 0.82);
  --bg-secondary: #131d2e;
  --border: rgba(212, 185, 106, 0.2);
  --bg-hover: rgba(212, 185, 106, 0.06);
}

/* ── Sidebar footer actions ── */
.sidebar-footer-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex: 1;
  justify-content: flex-end;
}

/* ── Page header ── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ── Card labels ── */
.card-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}

.card-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ── btn-sm variants ── */
.btn-sm {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-hover);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  font-family: var(--font-body);
}

.btn-sm:hover {
  background: rgba(75, 85, 99, 0.6);
}

.btn-sm.btn-accent {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.btn-sm.btn-accent:hover {
  background: var(--accent-hover);
}

.btn-sm.btn-success {
  background: var(--success);
  color: white;
  border-color: var(--success);
}

.btn-sm.btn-danger {
  border-color: var(--danger);
  color: var(--danger);
}

.btn-sm.btn-danger:hover {
  background: rgba(239, 68, 68, 0.15);
}

/* Tables */
.table-wrap {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow-x: auto;
  backdrop-filter: blur(12px);
}

.table-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.table-header h2 {
  font-size: 16px;
  font-weight: 600;
}

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

th {
  text-align: left;
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
}

td {
  padding: 12px 20px;
  border-bottom: 1px solid rgba(75, 85, 99, 0.2);
  font-size: 14px;
}

tr:last-child td {
  border-bottom: none;
}

tr:hover td {
  background: var(--bg-hover);
}

/* Badges */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
}

.badge-green {
  background: rgba(16, 185, 129, 0.15);
  color: var(--success);
}

.badge-yellow {
  background: rgba(245, 158, 11, 0.15);
  color: var(--warning);
}

.badge-red {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger);
}

.badge-blue {
  background: rgba(59, 130, 246, 0.15);
  color: var(--info);
}

.badge-purple {
  background: rgba(139, 92, 246, 0.15);
  color: var(--purple);
}

.badge-gray {
  background: rgba(107, 114, 128, 0.15);
  color: var(--text-muted);
}

/* Config controls */
.cfg-input {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: var(--font-body);
  transition: var(--transition);
}

.cfg-input:focus {
  outline: none;
  border-color: var(--border-focus);
}

.cfg-input.mono {
  font-family: var(--font-mono);
}

select.cfg-select {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  z-index: 10;
}

select.cfg-select:focus {
  outline: none;
  border-color: var(--border-focus);
  z-index: 11;
}

/* Sub-tabs */
.subtab-bar {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
}

.subtab {
  padding: 8px 18px;
  border: 1px solid var(--border);
  background: var(--bg-hover);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  font-family: var(--font-body);
}

.subtab:hover {
  color: var(--text-primary);
}

.subtab.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

/* Search bar */
.search-bar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

/* Plan select in users table */
.plan-select {
  background: var(--bg-primary);
  color: var(--text-primary);
  border: 1px solid var(--border);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  font-size: 13px;
}

.loading {
  padding: 40px;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
}

.scroll-sentinel {
  text-align: center;
  padding: 12px 16px;
  font-size: 12px;
  color: var(--text-muted);
  letter-spacing: 0.03em;
}

/* Analysis charts */
.chart-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}

@media (max-width: 900px) {
  .chart-grid {
    grid-template-columns: 1fr;
  }
}

.chart-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  backdrop-filter: blur(12px);
  height: 280px;
  display: flex;
  flex-direction: column;
}

.chart-card canvas {
  flex: 1;
  min-height: 0;
}

.chart-card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 12px;
}

/* Extra utilities */
.text-purple {
  color: var(--purple);
}

.text-accent {
  color: var(--accent);
}

.font-mono {
  font-family: var(--font-mono);
  font-size: 12px;
}

/* Override .page width restriction from dashboard.css for Admin bounds */
.page {
  max-width: 100%;
}

/* Sortable.js drag-and-drop ghost style */
.sortable-ghost {
  opacity: 0.4;
  background: rgba(79, 143, 247, 0.1);
}
tr[data-chain-id] {
  transition: background 0.15s;
}
tr[data-chain-id]:hover {
  background: rgba(212, 185, 106, 0.04);
}

.mobile-admin-nav {
  display: none;
}

@media (max-width: 768px) {
  .mobile-admin-nav {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
    background: rgba(8, 12, 20, 0.92);
    border-top: 1px solid rgba(212, 185, 106, 0.15);
    backdrop-filter: blur(24px);
    position: sticky;
    bottom: 0;
    z-index: 20;
  }

  .mobile-admin-nav .nav-item {
    flex: 0 0 auto;
    margin-bottom: 0;
    padding: 10px 12px;
    border: 1px solid rgba(212, 185, 106, 0.18);
    border-radius: var(--radius-md);
    background: rgba(20, 30, 45, 0.8);
    transform: none;
  }

  .mobile-admin-nav .nav-item:hover {
    transform: none;
  }

  .mobile-admin-nav .nav-item.active {
    border-left: 1px solid var(--accent);
    background: linear-gradient(180deg, rgba(212, 185, 106, 0.22) 0%, rgba(20, 30, 45, 0.9) 100%);
  }

  .mobile-admin-nav .nav-icon {
    width: auto;
    font-size: 16px;
  }

  .mobile-admin-nav .nav-label {
    white-space: nowrap;
    font-size: 13px;
  }

  .content {
    padding-bottom: 12px;
  }
}
