/* Memryze brand palette — mirrors ios/Memryze/Views/MemryzeColor.swift exactly, so the
   admin dashboard reads as part of the same product rather than a generic internal tool. */
:root {
  --background:      #F8F7FC; /* Mist */
  --background-alt:  #FBFAFF;
  --surface:         #FFFFFF;
  --surface-muted:   #E4E3E1;

  --accent:          #1DB6A6; /* primary teal */
  --accent-bright:   #34D9BE;
  --accent-mint:     #7DF9E4;
  --signal-blue:     #5B8CFF;

  --ink:             #2E1A6B; /* primary text, deep violet */
  --ink-secondary:   #6F66A8;
  --ink-tertiary:    #9A93C4;

  --danger:          #D64545;
  --danger-bg:       #FBE9E9;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 2.5rem clamp(1.25rem, 4vw, 3rem);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1100px 480px at -5% -10%, #E4F9F4 0%, transparent 60%),
    radial-gradient(900px 420px at 105% 0%, #EAF0FF 0%, transparent 60%),
    var(--background);
  min-height: 100vh;
}

.container {
  max-width: 1080px;
  margin: 0 auto;
}

/* ── Header / wordmark ─────────────────────────────────────────────────── */

.header {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  margin-bottom: 1.75rem;
}

.mark {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--accent-bright), var(--accent), var(--signal-blue));
  color: #ffffff;
  font-weight: 800;
  font-size: 1.3rem;
  font-family: -apple-system, "SF Pro Rounded", ui-rounded, sans-serif;
  box-shadow: 0 8px 20px rgba(29, 182, 166, 0.28);
  flex-shrink: 0;
}

.wordmark {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
}

.wordmark .product {
  font-size: 1.45rem;
  font-weight: 800;
  font-family: -apple-system, "SF Pro Rounded", ui-rounded, sans-serif;
  color: var(--ink);
  letter-spacing: -0.01em;
}

.wordmark .subtitle {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--ink-secondary);
}

/* ── Cards ──────────────────────────────────────────────────────────────── */

.card {
  background: var(--surface);
  border: 1px solid rgba(46, 26, 107, 0.08);
  border-radius: 16px;
  box-shadow: 0 12px 28px rgba(46, 26, 107, 0.06);
  padding: 1.25rem 1.5rem;
}

.stat-block {
  margin: 1.25rem 0;
}

.stat-block strong {
  color: var(--ink);
}

/* ── Buttons ────────────────────────────────────────────────────────────── */

button, .button {
  cursor: pointer;
  font-family: inherit;
  font-weight: 700;
  font-size: 0.9rem;
  padding: 0.55rem 1.05rem;
  border-radius: 10px;
  border: 1px solid rgba(46, 26, 107, 0.14);
  background: var(--surface);
  color: var(--ink);
  transition: transform 0.08s ease, box-shadow 0.15s ease;
}

button:hover:not(:disabled) {
  box-shadow: 0 4px 14px rgba(46, 26, 107, 0.12);
}

button:active:not(:disabled) {
  transform: translateY(1px);
}

button:disabled {
  opacity: 0.5;
  cursor: default;
}

button.primary {
  background: linear-gradient(135deg, var(--accent-bright), var(--accent));
  color: #ffffff;
  border-color: transparent;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

a.dashboard-link {
  font-weight: 700;
  color: var(--signal-blue);
  text-decoration: none;
}

a.dashboard-link:hover {
  text-decoration: underline;
}

/* ── Login form ─────────────────────────────────────────────────────────── */

#loginForm {
  max-width: 340px;
  margin-top: 2.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1.75rem;
}

#loginForm input {
  padding: 0.65rem 0.8rem;
  border-radius: 10px;
  border: 1px solid rgba(46, 26, 107, 0.16);
  font-family: inherit;
  font-size: 0.95rem;
  background: var(--background-alt);
  color: var(--ink);
}

#loginForm input:focus {
  outline: 2px solid var(--accent-mint);
  outline-offset: 1px;
}

#loginForm button[type="submit"] {
  margin-top: 0.25rem;
  background: linear-gradient(135deg, var(--accent-bright), var(--accent));
  color: #ffffff;
  border-color: transparent;
}

#errorBox {
  color: var(--danger);
  background: var(--danger-bg);
  border-radius: 10px;
  padding: 0.6rem 0.9rem;
  margin: 0.75rem 0;
  font-size: 0.9rem;
  white-space: pre-wrap;
}

#errorBox:empty {
  display: none;
}

/* ── Table ──────────────────────────────────────────────────────────────── */

#dashboard {
  display: none;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1.25rem;
  background: var(--surface);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 12px 28px rgba(46, 26, 107, 0.06);
}

th, td {
  text-align: left;
  padding: 0.75rem 1rem;
  font-size: 0.9rem;
}

th {
  font-weight: 700;
  color: var(--ink-secondary);
  border-bottom: 1px solid rgba(46, 26, 107, 0.1);
  background: var(--background-alt);
}

tbody tr {
  border-bottom: 1px solid rgba(46, 26, 107, 0.06);
}

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

tbody tr:hover {
  background: var(--background-alt);
}

.status-pill {
  display: inline-block;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
}

.status-enabled {
  background: rgba(29, 182, 166, 0.14);
  color: var(--accent);
}

.status-disabled {
  background: var(--danger-bg);
  color: var(--danger);
}

/* ── Filters / search ───────────────────────────────────────────────────── */

.filters {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}

.filters input, .filters select {
  padding: 0.55rem 0.8rem;
  border-radius: 10px;
  border: 1px solid rgba(46, 26, 107, 0.16);
  font-family: inherit;
  font-size: 0.9rem;
  background: var(--surface);
  color: var(--ink);
}

#searchInput {
  min-width: 240px;
}

.filters input:focus, .filters select:focus {
  outline: 2px solid var(--accent-mint);
  outline-offset: 1px;
}

/* ── Sortable column headers ────────────────────────────────────────────── */

th.sortable {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

th.sortable:hover {
  color: var(--ink);
}

th.sortable .sort-arrow {
  display: inline-block;
  margin-left: 0.3rem;
  color: var(--accent);
  font-size: 0.75rem;
}

/* ── Pagination ─────────────────────────────────────────────────────────── */

.pagination {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  justify-content: center;
  margin-top: 1.25rem;
}

.pagination #pageInfo {
  font-size: 0.88rem;
  color: var(--ink-secondary);
  font-weight: 600;
}

/* ── Page nav ───────────────────────────────────────────────────────────── */

.page-nav {
  display: flex;
  gap: 0.4rem;
  margin-right: auto;
}

.nav-link {
  background: transparent;
  border: 1px solid transparent;
  color: var(--ink-secondary);
  font-weight: 700;
}

.nav-link.active {
  background: var(--surface);
  color: var(--ink);
  border-color: rgba(46, 26, 107, 0.12);
  box-shadow: 0 4px 14px rgba(46, 26, 107, 0.08);
}

.page[hidden] {
  display: none;
}

.stat-block .dashboard-link {
  float: right;
}

/* ── Metrics grid (Overview page) ───────────────────────────────────────── */

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.9rem;
  margin-top: 1rem;
}

.metric-card {
  background: var(--surface);
  border: 1px solid rgba(46, 26, 107, 0.08);
  border-radius: 14px;
  box-shadow: 0 10px 24px rgba(46, 26, 107, 0.05);
  padding: 1rem 1.15rem;
}

.metric-loading {
  color: var(--ink-tertiary);
  font-size: 0.9rem;
}

.metric-label {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--ink-secondary);
  margin-bottom: 0.3rem;
}

.metric-value {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--ink);
  font-family: -apple-system, "SF Pro Rounded", ui-rounded, sans-serif;
}

.metric-card.metric-alert .metric-value {
  color: var(--danger);
}

.metric-sparkline {
  display: block;
  margin-top: 0.5rem;
  width: 100%;
  height: 32px;
  overflow: visible; /* hover dots sit slightly outside the 0-32 viewBox at the peaks */
}

.metric-sparkline circle {
  opacity: 0;
  cursor: crosshair;
}

.metric-sparkline circle:hover {
  opacity: 1;
}

/* ── Range labels / captions ────────────────────────────────────────────── */

.range-label {
  font-size: 0.82rem;
  color: var(--ink-tertiary);
  margin: 0.9rem 0 0.4rem;
  font-weight: 600;
}

.cost-caveat {
  display: block;
  margin-top: 0.3rem;
  font-weight: 500;
}

/* ── Shared hover tooltip (sparklines + cost chart) ─────────────────────── */

.chart-tooltip {
  position: fixed;
  pointer-events: none;
  background: var(--ink);
  color: #ffffff;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.3rem 0.55rem;
  border-radius: 8px;
  z-index: 50;
  display: none;
  white-space: nowrap;
}

/* ── Cost chart (bar chart, Costs page) ─────────────────────────────────── */

.cost-chart {
  background: var(--surface);
  border: 1px solid rgba(46, 26, 107, 0.08);
  border-radius: 14px;
  box-shadow: 0 10px 24px rgba(46, 26, 107, 0.05);
  padding: 1rem;
  height: 160px;
}

.cost-chart svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.cost-chart rect {
  fill: var(--accent);
  cursor: crosshair;
}

.cost-chart rect:hover {
  fill: var(--ink);
}
