/*
  Admin panel stylesheet.

  This file uses plain CSS so the admin panel works without a frontend build
  tool, paid UI kit, or JavaScript framework.
*/

/* Global reset keeps layout predictable across browsers. */
* {
  box-sizing: border-box;
}

/* Root colors keep the design consistent and easy to change later. */
:root {
  --bg: #f3f4f6;
  --surface: #ffffff;
  --surface-soft: #f9fafb;
  --text: #111827;
  --muted: #6b7280;
  --border: #e5e7eb;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --danger: #dc2626;
  --warning: #d97706;
  --success: #16a34a;
  --shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
  --radius: 14px;
}

/* Body sets the main admin shell background and font. */
body {
  margin: 0;
  font-family: "Segoe UI", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
}

/* Sidebar stays fixed on desktop for fast navigation. */
.admin-sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 270px;
  padding: 20px;
  background: #0f172a;
  color: #ffffff;
  overflow-y: auto;
  z-index: 10;
}

/* Brand groups the logo mark and product name. */
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 26px;
}

/* Brand mark gives the admin panel a simple visual identity. */
.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--primary);
  color: #ffffff;
  font-weight: 800;
}

/* Brand subtitle stays small and muted. */
.brand span {
  display: block;
  color: #cbd5e1;
  font-size: 13px;
}

/* Sidebar navigation uses stacked links for clarity. */
.admin-nav {
  display: grid;
  gap: 6px;
}

/* Navigation links are large enough for comfortable clicking. */
.admin-nav a {
  color: #e5e7eb;
  text-decoration: none;
  padding: 10px 12px;
  border-radius: 10px;
  transition: background 0.15s ease, color 0.15s ease;
}

/* Hover state improves discoverability. */
.admin-nav a:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

/* Main content is offset by the sidebar width. */
.admin-main {
  margin-left: 270px;
  min-height: 100vh;
  padding: 24px;
}

/* Topbar holds page title and account actions. */
.admin-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

/* Topbar headings remain compact. */
.admin-topbar h1 {
  margin: 0;
  font-size: 28px;
}

/* Page subtitle uses muted text. */
.admin-topbar p {
  margin: 4px 0 0;
  color: var(--muted);
}

/* Topbar actions align admin email and logout. */
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Sidebar toggle is hidden on desktop. */
.sidebar-toggle {
  display: none;
}

/* Panel is the main content card style. */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 18px;
}

/* Panel header aligns titles and action buttons. */
.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

/* Panel titles are consistent across pages. */
.panel-header h2 {
  margin: 0;
  font-size: 18px;
}

/* Metric grid adapts to available space. */
.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

/* Metric cards highlight important dashboard numbers. */
.metric-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}

/* Metric labels are muted for hierarchy. */
.metric-card span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 8px;
}

/* Metric values are large and bold. */
.metric-card strong {
  font-size: 28px;
}

/* Action grid shows shortcuts. */
.action-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
}

/* Action cards are clickable shortcut tiles. */
.action-card {
  display: block;
  padding: 16px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-soft);
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
}

/* Table wrapper allows horizontal scrolling on small screens. */
.table-wrap {
  overflow-x: auto;
}

/* Tables use full width and clean borders. */
table {
  width: 100%;
  border-collapse: collapse;
}

/* Table cells keep content readable. */
th,
td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

/* Header cells use muted uppercase labels. */
th {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Secondary text inside table cells is stacked. */
td span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

/* Buttons share a base style. */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 0;
  border-radius: 10px;
  padding: 9px 13px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  color: #ffffff;
  background: var(--primary);
  transition: background 0.15s ease, transform 0.15s ease;
}

/* Buttons lift slightly on hover. */
.btn:hover {
  transform: translateY(-1px);
  background: var(--primary-dark);
}

/* Small buttons fit dense tables. */
.btn-small {
  padding: 6px 9px;
  font-size: 12px;
}

/* Secondary button uses neutral background. */
.btn-secondary {
  background: #475569;
}

/* Danger button indicates destructive action. */
.btn-danger {
  background: var(--danger);
}

/* Warning button indicates caution. */
.btn-warning {
  background: var(--warning);
}

/* Primary button is explicit for consistency. */
.btn-primary {
  background: var(--primary);
}

/* Row of buttons uses spacing. */
.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

/* Badges show statuses and labels. */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: 999px;
  background: #e5e7eb;
  color: #111827;
  font-size: 12px;
  font-weight: 700;
}

/* Common status badge colors. */
.badge-active,
.badge-approved,
.badge-paid,
.badge-succeeded,
.badge-completed,
.badge-success {
  background: #dcfce7;
  color: #166534;
}

.badge-pending,
.badge-pending_review,
.badge-running,
.badge-reviewing,
.badge-warning {
  background: #fef3c7;
  color: #92400e;
}

.badge-suspended,
.badge-blocked,
.badge-failed,
.badge-rejected,
.badge-error,
.badge-critical {
  background: #fee2e2;
  color: #991b1b;
}

.badge-removed,
.badge-closed,
.badge-cancelled,
.badge-terminated {
  background: #e5e7eb;
  color: #374151;
}

/* Forms use responsive grid layout. */
.grid-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

/* Labels stack input and label text. */
label {
  display: grid;
  gap: 6px;
  color: #374151;
  font-size: 13px;
  font-weight: 700;
}

/* Span helper lets large fields occupy both columns. */
.span-2 {
  grid-column: span 2;
}

/* Inputs share consistent styling. */
input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 11px;
  font: inherit;
  color: var(--text);
  background: #ffffff;
}

/* Textareas are vertically resizable only. */
textarea {
  resize: vertical;
}

/* Detail grid displays record fields neatly. */
.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin: 0;
}

/* Detail cells look like mini cards. */
.detail-grid div {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  background: var(--surface-soft);
}

/* Detail labels are muted. */
dt {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 4px;
}

/* Detail values are emphasized. */
dd {
  margin: 0;
  font-weight: 700;
}

/* Empty-state text centers table messages. */
.empty-state {
  text-align: center;
  color: var(--muted);
  padding: 24px;
}

/* Muted text helper. */
.muted {
  color: var(--muted);
}

/* Flash area shows success/error messages from JavaScript. */
.flash-area {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
}

/* Flash messages are dismissible-looking cards. */
.flash {
  border-radius: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  background: #eff6ff;
  color: #1e3a8a;
}

/* Error flash uses red styling. */
.flash.error {
  background: #fef2f2;
  color: #991b1b;
}

/* Success flash uses green styling. */
.flash.success {
  background: #f0fdf4;
  color: #166534;
}

/* Login page centers the login card. */
.login-page {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
}

/* Login card limits form width. */
.login-card {
  width: min(420px, 100%);
}

/* Login brand uses dark text instead of sidebar white. */
.login-brand {
  color: var(--text);
}

/* Login form card. */
.form-card {
  display: grid;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
}

/* Message cards display support conversations. */
.message-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 10px;
  background: var(--surface-soft);
}

/* Internal support messages are visually distinct. */
.message-card.internal {
  border-color: #f59e0b;
  background: #fffbeb;
}

/* Message box displays original ticket description. */
.message-box {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  background: var(--surface-soft);
}

/* Code block is used on error pages. */
.code-block {
  overflow-x: auto;
  background: #111827;
  color: #e5e7eb;
  border-radius: 12px;
  padding: 14px;
}

/* Utility margin helper. */
.mt-16 {
  margin-top: 16px;
}

/* Responsive layout collapses sidebar and form columns. */
@media (max-width: 900px) {
  .admin-sidebar {
    transform: translateX(-100%);
    transition: transform 0.2s ease;
  }

  .admin-sidebar.open {
    transform: translateX(0);
  }

  .admin-main {
    margin-left: 0;
  }

  .sidebar-toggle {
    display: inline-flex;
  }

  .grid-form {
    grid-template-columns: 1fr;
  }

  .span-2 {
    grid-column: span 1;
  }

  .admin-topbar {
    align-items: flex-start;
    flex-direction: column;
  }
}

/* Public legal page layout reuses the admin visual system without the admin shell. */
.legal-page {
  min-height: 100vh;
  background: var(--bg);
}

/* Legal shell centers readable policy content. */
.legal-shell {
  max-width: 920px;
  margin: 0 auto;
  padding: 40px 20px;
}

/* Legal card matches the admin panel card style. */
.legal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
}

/* Legal page brand uses dark text instead of sidebar white. */
.legal-brand {
  color: var(--text);
  margin-bottom: 24px;
}

/* Legal headings keep the policy scannable. */
.legal-card h1 {
  margin: 0 0 8px;
  color: var(--primary);
  font-size: 30px;
}

/* Legal section headings match the admin text color. */
.legal-card h2 {
  margin: 28px 0 8px;
  color: var(--text);
  font-size: 20px;
}

/* Legal paragraphs are readable and not too wide. */
.legal-card p {
  margin: 10px 0;
}

/* Legal lists use comfortable spacing. */
.legal-card li {
  margin-bottom: 8px;
}

/* Legal links use the primary brand color. */
.legal-card a {
  color: var(--primary);
  font-weight: 700;
}
