/* ═══════════════════════════════════════════════════════════════════
   Gudnak Admin — Shared Styles (inspired by cg-wms)
   ═══════════════════════════════════════════════════════════════════ */

:root {
  --bg-darkest: #0a0c10;
  --bg-dark: #111520;
  --bg-card: #171c2a;
  --bg-card-hover: #1c2235;
  --bg-surface: #141825;
  --accent: #4aedc4;
  --accent-dim: #3bc4a1;
  --accent-glow: rgba(74, 237, 196, 0.12);
  --accent-glow-strong: rgba(74, 237, 196, 0.22);
  --brand: #FF533F;
  --brand-dim: #e04535;
  --brand-glow: rgba(255, 83, 63, 0.12);
  --text-primary: #eaeff5;
  --text-secondary: #8a94a8;
  --text-muted: #4f5b72;
  --border: #1e2538;
  --border-light: #28304a;
  --danger: #f5425a;
  --warning: #f5a623;
  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 14px;
  --shadow: 0 2px 12px rgba(0,0,0,0.25);
  --shadow-lg: 0 12px 48px rgba(0,0,0,0.5);
  --transition: 0.18s ease;
}

/* ── Animations ────────────────────────────────────────────────── */
@keyframes pageFadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes cardFadeIn {
  from { opacity: 0; transform: translateY(12px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
@keyframes backdropIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes tabSlide {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── Page layout ───────────────────────────────────────────────── */
.admin-page {
  background: linear-gradient(135deg, var(--bg-darkest) 0%, #0c0e14 100%);
  min-height: 100vh;
  color: var(--text-primary);
  font-family: 'jaf-lapture', Georgia, serif;
}

.admin-container {
  max-width: 90rem;
  margin: 0 auto;
  padding: 24px 24px 80px;
  animation: pageFadeIn 0.35s ease both;
}

/* ── Page header ───────────────────────────────────────────────── */
.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}
.admin-header h1 {
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
  font-family: 'jaf-lapture', Georgia, serif;
}

/* ── Stat pills ────────────────────────────────────────────────── */
.stat-pills { display: flex; gap: 8px; flex-wrap: wrap; }
.stat-pill {
  padding: 5px 14px;
  border-radius: 8px;
  font-size: 0.72rem;
  font-weight: 600;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  transition: all var(--transition);
}
.stat-pill strong { color: var(--accent); font-weight: 700; }
.stat-pill:hover { border-color: var(--border-light); }

/* ── Tabs ──────────────────────────────────────────────────────── */
.admin-tabs {
  display: flex;
  gap: 2px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
}
.admin-tab {
  padding: 10px 20px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
}
.admin-tab:hover { color: var(--text-secondary); }
.admin-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* ── Table card ────────────────────────────────────────────────── */
.table-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  overflow: hidden;
  box-shadow: var(--shadow);
  animation: cardFadeIn 0.45s ease both;
  animation-delay: 0.1s;
}

/* ── Tables ────────────────────────────────────────────────────── */
.admin-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}
.admin-table th {
  background: rgba(20, 24, 37, 0.8);
  text-align: left;
  padding: 0.7rem 1rem;
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 5;
}
.admin-table td {
  padding: 0.65rem 1rem;
  border-bottom: 1px solid rgba(30, 37, 56, 0.5);
  font-size: 0.82rem;
  color: var(--text-secondary);
  transition: background 0.12s ease;
  vertical-align: middle;
}
.admin-table tr:last-child td { border-bottom: none; }
.admin-table tr.clickable { cursor: pointer; }
.admin-table tr.clickable:hover td { background: rgba(74, 237, 196, 0.04); }
.admin-table tr.clickable:active td { background: rgba(74, 237, 196, 0.08); }

/* ── Monospace / SKU ───────────────────────────────────────────── */
.mono {
  font-family: "SF Mono", "Fira Code", "JetBrains Mono", monospace;
  font-size: 0.78rem;
  letter-spacing: 0.02em;
}

/* ── Badges ────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border: 1px solid transparent;
}
.badge-linked { background: var(--accent-glow); color: var(--accent); border-color: rgba(74, 237, 196, 0.25); }
.badge-unlinked { background: rgba(255,255,255,0.03); color: var(--text-muted); }
.badge-success { background: var(--accent-glow); color: var(--accent); border-color: rgba(74, 237, 196, 0.25); }
.badge-warning { background: rgba(245, 166, 35, 0.12); color: var(--warning); border-color: rgba(245, 166, 35, 0.25); }
.badge-danger { background: rgba(245, 66, 90, 0.08); color: var(--danger); border-color: rgba(245, 66, 90, 0.2); }
.badge-info { background: rgba(96, 165, 250, 0.12); color: #60a5fa; border-color: rgba(96, 165, 250, 0.25); }
.badge-brand { background: var(--brand-glow); color: var(--brand); border-color: rgba(255, 83, 63, 0.25); }

/* ── Buttons ───────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  border: none;
  white-space: nowrap;
}
.btn-sm { padding: 5px 10px; font-size: 0.72rem; border-radius: var(--radius-sm); }

.btn-primary {
  background: linear-gradient(135deg, var(--brand) 0%, #e04535 100%);
  color: white;
  box-shadow: 0 2px 8px rgba(255, 83, 63, 0.2);
}
.btn-primary:hover { box-shadow: 0 4px 16px rgba(255, 83, 63, 0.3); transform: translateY(-1px); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none; }

.btn-accent {
  background: linear-gradient(135deg, var(--accent) 0%, #38d4ad 100%);
  color: var(--bg-darkest);
  box-shadow: 0 2px 8px rgba(74, 237, 196, 0.2);
}
.btn-accent:hover { box-shadow: 0 4px 16px rgba(74, 237, 196, 0.3); transform: translateY(-1px); }

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-secondary);
  border: 1px solid var(--border-light);
}
.btn-secondary:hover { background: var(--bg-card-hover); color: var(--text-primary); border-color: var(--text-muted); }

.btn-outline {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-light);
}
.btn-outline:hover { border-color: var(--text-muted); color: var(--text-primary); }

.btn-danger {
  background: rgba(245, 66, 90, 0.1);
  color: var(--danger);
  border: 1px solid rgba(245, 66, 90, 0.2);
}
.btn-danger:hover { background: rgba(245, 66, 90, 0.18); border-color: rgba(245, 66, 90, 0.35); }

.btn-merge {
  background: var(--accent-glow);
  color: var(--accent);
  border: 1px solid rgba(74, 237, 196, 0.2);
}
.btn-merge:hover { background: var(--accent-glow-strong); }

/* ── Modals ────────────────────────────────────────────────────── */
.modal-bg {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  animation: backdropIn 0.15s ease;
}
.modal-bg.active { display: flex; }

.modal-card {
  background: var(--bg-dark);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg), 0 0 80px rgba(0,0,0,0.3);
  animation: modalIn 0.2s ease;
}
.modal-card h2 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
  font-family: 'jaf-lapture', Georgia, serif;
}

/* ── Forms ──────────────────────────────────────────────────────── */
.field-label {
  display: block;
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.35rem;
}
.field-input,
.field-select,
.field-textarea {
  width: 100%;
  padding: 0.6rem 0.85rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 0.85rem;
  transition: all var(--transition);
  font-family: inherit;
  box-sizing: border-box;
}
.field-input::placeholder,
.field-textarea::placeholder { color: var(--text-muted); }
.field-input:hover,
.field-select:hover,
.field-textarea:hover { border-color: var(--border-light); background: rgba(20, 24, 37, 0.7); }
.field-input:focus,
.field-select:focus,
.field-textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow), 0 0 12px rgba(74, 237, 196, 0.06);
  background: rgba(17, 21, 32, 0.95);
}

/* Custom select */
.field-select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%234f5b72' stroke-width='2.5'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2.25rem;
  cursor: pointer;
}
.field-select:focus {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%234aedc4' stroke-width='2.5'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
}

.field-textarea { min-height: 80px; resize: vertical; }

/* ── Toggle switches ───────────────────────────────────────────── */
.perm-toggle input:checked + div { background: var(--accent); }
.perm-toggle div {
  background: rgba(255,255,255,0.1);
  width: 2.25rem;
  height: 1.25rem;
  border-radius: 9999px;
  position: relative;
  transition: background 0.2s;
  flex-shrink: 0;
  cursor: pointer;
}
.perm-toggle div::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 1rem;
  height: 1rem;
  border-radius: 9999px;
  background: white;
  transition: transform 0.2s;
}
.perm-toggle input:checked + div::after { transform: translateX(1rem); }

/* ── Search input ──────────────────────────────────────────────── */
.search-wrap { position: relative; }
.search-wrap input {
  padding: 8px 12px 8px 36px;
  border-radius: var(--radius);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text-primary);
  width: 18rem;
  font-size: 0.85rem;
  transition: all var(--transition);
}
.search-wrap input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.search-wrap svg {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-muted);
}

/* ── Info rows (modal detail view) ─────────────────────────────── */
.info-row {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.info-row .info-label {
  width: 100px;
  flex-shrink: 0;
  font-size: 0.62rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  padding-top: 3px;
}
.info-row .info-value {
  font-size: 0.88rem;
  color: var(--text-primary);
  font-weight: 500;
}

/* ── Error / Alert boxes ───────────────────────────────────────── */
.alert-error {
  background: rgba(245, 66, 90, 0.08);
  border: 1px solid rgba(245, 66, 90, 0.2);
  color: var(--danger);
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 500;
}
.alert-success {
  background: var(--accent-glow);
  border: 1px solid rgba(74, 237, 196, 0.25);
  color: var(--accent);
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 500;
}

/* ── Empty state ───────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 2rem;
  color: var(--text-muted);
  font-size: 0.88rem;
}

/* ── Merge account cards ───────────────────────────────────────── */
.merge-account-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: all var(--transition);
}
.merge-account-card:hover { border-color: var(--border-light); background: var(--bg-card-hover); }
.merge-account-card.selected { border-color: var(--accent); background: var(--accent-glow); }
.merge-account-card .avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--border);
}

/* ── Merge preview ─────────────────────────────────────────────── */
.merge-preview {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}

/* ── Tab content animation ─────────────────────────────────────── */
.tab-content {
  animation: tabSlide 0.25s ease both;
}

/* ── Responsive ────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .admin-container { padding: 16px 12px 60px; }
  .admin-header { flex-direction: column; align-items: flex-start; }
  .search-wrap input { width: 100%; }
}
