/* ============================================================
   FLUCK Admin Dashboard – Blue & White Theme
   ============================================================ */

:root {
  --bg: #F5F8FC;
  --surface: #FFFFFF;
  --ink: #0B2545;
  --blue: #144C9C;
  --blue-bright: #2F6FE4;
  --blue-light: #EAF1FE;
  --foil: #8FD8FF;
  --line: #E1E7F0;
  --text-dim: #5B6B85;
  --text-muted: #8A9BB5;
  --alert: #D64545;
  --success: #0F7A4F;
  --warning: #B8860B;
  --shadow-sm: 0 2px 8px rgba(11, 37, 69, 0.06);
  --shadow-md: 0 8px 24px -12px rgba(11, 37, 69, 0.12);
  --shadow-lg: 0 16px 48px -16px rgba(11, 37, 69, 0.18);
  --radius: 14px;
  --radius-sm: 10px;
  --transition: 0.2s ease;
  --mono: 'JetBrains Mono', Menlo, monospace;
  --body: 'Inter', -apple-system, 'Segoe UI', sans-serif;
}

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

html { background: var(--bg); font-family: var(--body); color: var(--ink); -webkit-font-smoothing: antialiased; }
body { margin: 0; min-height: 100vh; }

/* ─── Scrollbar ─── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--blue-bright); }

/* ─── Loading Screen ─── */
.loading-screen {
  position: fixed; inset: 0; background: var(--bg);
  display: flex; align-items: center; justify-content: center; z-index: 999;
  transition: opacity 0.6s ease;
}
.loading-screen.hidden { opacity: 0; pointer-events: none; }
.loading-screen .brand {
  display: flex; align-items: center; gap: 12px;
  font-weight: 700; font-size: 20px; color: var(--ink);
  animation: pulseLogo 1.6s ease-in-out infinite;
}
.loading-screen .logo {
  width: 36px; height: 36px; border-radius: 8px;
  background: linear-gradient(135deg, var(--blue-bright), var(--foil));
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 800; font-size: 18px;
}
.loading-screen .name span { color: var(--blue-bright); }
@keyframes pulseLogo {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.04); opacity: 0.85; }
}

/* ─── App ─── */
.app { display: flex; min-height: 100vh; opacity: 0; animation: appFadeIn 0.5s ease forwards; }
@keyframes appFadeIn { to { opacity: 1; } }

/* ─── Sidebar ─── */
.sidebar {
  position: sticky; top: 0; height: 100vh; width: 240px;
  background: var(--surface); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 20px 16px;
  flex-shrink: 0; overflow-y: auto; z-index: 20;
  transition: transform 0.3s cubic-bezier(0.22, 0.68, 0.12, 1);
}
.sidebar .brand {
  display: flex; align-items: center; gap: 10px;
  font-weight: 700; font-size: 18px; color: var(--ink);
  padding: 0 4px 18px 4px; border-bottom: 1px solid var(--line);
  margin-bottom: 16px;
}
.sidebar .brand .logo {
  width: 32px; height: 32px; border-radius: 6px;
  background: linear-gradient(135deg, var(--blue-bright), var(--foil));
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 800; font-size: 16px;
}
.sidebar .brand .name span { color: var(--blue-bright); }

.sidebar-backdrop {
  position: fixed; inset: 0; background: rgba(11, 37, 69, 0.3);
  z-index: 15; opacity: 0; pointer-events: none;
  transition: opacity 0.3s ease;
}
.sidebar-backdrop.open { opacity: 1; pointer-events: auto; }

.nav {
  display: flex; flex-direction: column; gap: 2px; flex: 1;
}
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border: none; border-radius: var(--radius-sm);
  background: transparent; color: var(--text-dim);
  font-family: var(--body); font-size: 13.5px; font-weight: 500;
  cursor: pointer; transition: background var(--transition), color var(--transition), transform 0.1s ease;
  width: 100%; text-align: left;
}
.nav-item:hover { background: var(--blue-light); color: var(--ink); transform: translateX(4px); }
.nav-item.active { background: var(--blue-light); color: var(--blue); font-weight: 600; }
.nav-item .ic { width: 20px; height: 20px; flex-shrink: 0; opacity: 0.7; }
.nav-item.active .ic { opacity: 1; color: var(--blue); }
.nav-item .badge {
  font-size: 11px; font-weight: 600; background: var(--warning);
  color: #fff; padding: 1px 8px; border-radius: 12px; margin-left: auto;
}
.nav-sep {
  font-size: 10px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--text-muted);
  padding: 16px 12px 6px;
}

.sidebar-foot {
  border-top: 1px solid var(--line); padding-top: 14px; margin-top: auto;
}
.user-chip {
  display: flex; align-items: center; gap: 12px;
  padding: 6px 4px; border-radius: var(--radius-sm);
  cursor: pointer; transition: background 0.2s;
}
.user-chip:hover { background: var(--blue-light); }
.user-chip .av {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--blue-light); color: var(--blue);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px;
}
.user-chip .meta .u { font-weight: 600; font-size: 13px; }
.user-chip .meta .r { font-size: 11px; color: var(--text-dim); }
.user-chip .chevron {
  margin-left: auto; color: var(--text-muted);
  transition: transform 0.2s ease;
}
.user-chip .chevron.open { transform: rotate(180deg); }

/* ─── User switcher dropdown ─── */
.user-switcher {
  display: none; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 6px; margin-top: 8px; box-shadow: var(--shadow-md);
}
.user-switcher.open { display: block; }
.user-switcher .switcher-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius-sm);
  cursor: pointer; font-size: 13px;
  transition: background 0.15s;
}
.user-switcher .switcher-item:hover { background: var(--blue-light); }
.user-switcher .switcher-item.active { background: var(--blue-light); color: var(--blue); font-weight: 600; }
.user-switcher .switcher-item .av-sm {
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--blue-light); color: var(--blue);
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 11px;
}

/* ─── Buttons ─── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px; padding: 8px 16px; border: none;
  border-radius: var(--radius-sm); font-family: var(--body);
  font-size: 13px; font-weight: 600; cursor: pointer;
  transition: background var(--transition), transform 0.1s ease, box-shadow var(--transition);
  background: var(--bg); color: var(--ink);
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: scale(0.97); }
.btn-primary {
  background: var(--blue-bright); color: #fff;
  box-shadow: 0 4px 12px -4px rgba(47, 111, 228, 0.35);
}
.btn-primary:hover { background: #1D5ACF; box-shadow: 0 6px 16px -4px rgba(47, 111, 228, 0.45); }
.btn-ghost { background: transparent; color: var(--text-dim); }
.btn-ghost:hover { background: var(--bg); color: var(--ink); }
.btn-danger { background: var(--alert); color: #fff; }
.btn-danger:hover { background: #c0392b; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-warning:hover { background: #a67c0a; }
.btn-sm { font-size: 12px; padding: 6px 12px; }
.btn-block { width: 100%; }
.btn-lg { padding: 13px 20px; font-size: 15px; }

/* ─── Main ─── */
.main { flex: 1; min-width: 0; padding: 20px 28px 40px; }

.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding-bottom: 20px; border-bottom: 1px solid var(--line);
  flex-wrap: wrap; gap: 12px;
}
.topbar h1 { font-size: 22px; font-weight: 700; margin: 0; color: var(--ink); }
.topbar .sub { font-size: 13px; color: var(--text-dim); margin-top: 2px; }
.mobile-menu-btn { display: none; }

.content { padding-top: 24px; }
.view { display: none; animation: viewFade 0.3s ease; }
.view.active { display: block; }
@keyframes viewFade {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ─── Cards & Stats ─── */
.grid { display: grid; gap: 16px; }
.stats-grid { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); margin-bottom: 24px; }
.stat {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition), transform 0.15s ease;
}
.stat:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.stat .stat-icon { font-size: 20px; margin-bottom: 6px; display: block; }
.stat .label {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.04em; color: var(--text-dim);
}
.stat .value {
  font-size: 28px; font-weight: 700; margin: 4px 0 2px;
  font-family: var(--mono); letter-spacing: -0.02em;
}
.stat .value.accent { color: var(--blue); }
.stat .value.danger { color: var(--alert); }
.stat .value.warn { color: var(--warning); }
.stat .value.success { color: var(--success); }
.stat .foot { font-size: 12px; color: var(--text-muted); }

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 20px 24px;
  box-shadow: var(--shadow-sm); transition: box-shadow var(--transition), transform 0.15s ease;
}
.card:hover { box-shadow: var(--shadow-md); }
.card-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  flex-wrap: wrap; gap: 12px; margin-bottom: 16px;
}
.card-head h2 { font-size: 16px; font-weight: 700; margin: 0; }
.card-head p { font-size: 13px; color: var(--text-dim); margin: 2px 0 0; }
.mt-16 { margin-top: 16px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }

.empty {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; padding: 40px 20px;
  color: var(--text-dim); font-size: 14px; gap: 8px;
}
.empty .big { font-weight: 600; color: var(--ink); }
.spinner {
  width: 24px; height: 24px; border: 3px solid var(--line);
  border-top-color: var(--blue-bright); border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Toolbar ─── */
.toolbar {
  display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 16px;
}
.toolbar .grow { flex: 1; min-width: 140px; }
.input {
  padding: 8px 14px; border: 1px solid var(--line);
  border-radius: var(--radius-sm); font-family: var(--body);
  font-size: 13px; background: var(--surface); color: var(--ink);
  transition: border-color var(--transition), box-shadow 0.2s;
  width: 100%;
}
.input:focus {
  outline: none; border-color: var(--blue-bright);
  box-shadow: 0 0 0 3px rgba(47, 111, 228, 0.12);
}
.select {
  padding: 8px 14px; border: 1px solid var(--line);
  border-radius: var(--radius-sm); font-family: var(--body);
  font-size: 13px; background: var(--surface); color: var(--ink);
  cursor: pointer; transition: border-color var(--transition);
}
.select:focus { outline: none; border-color: var(--blue-bright); }

/* ─── Bulk Bar ─── */
.bulk-bar {
  display: none; align-items: center; gap: 12px;
  background: var(--blue-light); border: 1px solid #D3E3FC;
  border-radius: var(--radius-sm); padding: 10px 16px;
  margin-bottom: 16px; flex-wrap: wrap;
  animation: slideDown 0.25s ease;
}
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}
.bulk-bar.show { display: flex; }
.bulk-bar .count { font-size: 13px; font-weight: 600; color: var(--blue); }

/* ─── Tables ─── */
.table-wrap {
  overflow-x: auto; border: 1px solid var(--line);
  border-radius: var(--radius); background: var(--surface);
}
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead { background: var(--bg); }
th {
  text-align: left; padding: 12px 14px;
  font-weight: 600; font-size: 11px; text-transform: uppercase;
  letter-spacing: 0.04em; color: var(--text-dim);
  border-bottom: 1px solid var(--line);
}
td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: none; }

/* ─── Row selection highlighting ─── */
tr.selectable { cursor: pointer; transition: background 0.15s; }
tr.selectable:hover td { background: var(--blue-light); }
tr.selectable.selected td { background: var(--blue-light); border-left: 3px solid var(--blue-bright); }
tr.selectable td:first-child { padding-left: 11px; }

.checkbox {
  width: 16px; height: 16px; accent-color: var(--blue-bright);
  cursor: pointer;
}
/* Custom checkbox for better visuals */
.checkbox-wrap {
  display: flex; align-items: center; justify-content: center;
}
.checkbox-custom {
  width: 18px; height: 18px; border: 2px solid var(--line);
  border-radius: 4px; background: var(--surface);
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s ease; cursor: pointer;
}
.checkbox-custom.checked {
  background: var(--blue-bright); border-color: var(--blue-bright);
}
.checkbox-custom.checked::after {
  content: "✓"; color: #fff; font-size: 12px; font-weight: 700;
}
.checkbox-custom:hover { border-color: var(--blue-bright); }

/* ─── Badges ─── */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 12px; font-size: 11px;
  font-weight: 600; border: 1px solid transparent;
}
.badge.dot::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: currentColor; flex-shrink: 0;
}
.badge-green { background: #E7F6EF; color: var(--success); border-color: #BDE7D3; }
.badge-red { background: #FDE8E8; color: var(--alert); border-color: #F5C2C2; }
.badge-amber { background: #FDF1E6; color: var(--warning); border-color: #F5D9A0; }
.badge-blue { background: var(--blue-light); color: var(--blue); border-color: #D3E3FC; }
.badge-gray { background: var(--bg); color: var(--text-dim); border-color: var(--line); }

.status-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 12px;
  font-size: 11px; font-weight: 600; text-transform: capitalize;
}
.status-badge .dot { width: 6px; height: 6px; border-radius: 50%; }
.status-badge.unused { background: #E7F6EF; color: var(--success); }
.status-badge.unused .dot { background: var(--success); }
.status-badge.used { background: var(--blue-light); color: var(--blue); }
.status-badge.used .dot { background: var(--blue); }
.status-badge.banned { background: #FDE8E8; color: var(--alert); }
.status-badge.banned .dot { background: var(--alert); }
.status-badge.expired { background: #FDF1E6; color: var(--warning); }
.status-badge.expired .dot { background: var(--warning); }

.action-btn {
  background: transparent; border: none; padding: 4px 8px;
  border-radius: 4px; color: var(--text-dim);
  cursor: pointer; transition: background var(--transition), color var(--transition);
}
.action-btn:hover { background: var(--blue-light); color: var(--blue); }
.action-btn.danger:hover { background: #FDE8E8; color: var(--alert); }

.copy-btn {
  background: transparent; border: none; padding: 2px 6px;
  border-radius: 4px; color: var(--text-muted);
  cursor: pointer; transition: color var(--transition);
}
.copy-btn:hover { color: var(--blue); }

.key-cell { font-family: var(--mono); font-size: 13px; }

/* ─── Modal ─── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(11, 37, 69, 0.4);
  backdrop-filter: blur(4px); z-index: 100;
  display: none; align-items: center; justify-content: center; padding: 20px;
}
.modal-overlay.show { display: flex; }
.modal {
  background: var(--surface); border-radius: var(--radius);
  padding: 32px 36px; max-width: 480px; width: 100%;
  box-shadow: var(--shadow-lg); animation: modalIn 0.25s ease;
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(0.94) translateY(12px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
.modal h3 { font-size: 20px; margin: 0 0 6px; }
.modal p.desc { color: var(--text-dim); font-size: 14px; margin: 0 0 20px; }
.modal .field { margin-bottom: 14px; }
.modal .field label {
  display: block; font-size: 12px; font-weight: 600;
  color: var(--text-dim); margin-bottom: 4px;
}
.modal .field input,
.modal .field select,
.modal .field textarea {
  width: 100%; padding: 8px 12px; border: 1px solid var(--line);
  border-radius: var(--radius-sm); font-family: var(--body);
  font-size: 13px; background: var(--surface); color: var(--ink);
  transition: border-color var(--transition);
}
.modal .field input:focus,
.modal .field select:focus,
.modal .field textarea:focus {
  outline: none; border-color: var(--blue-bright);
  box-shadow: 0 0 0 3px rgba(47, 111, 228, 0.12);
}
.modal .modal-actions {
  display: flex; gap: 12px; margin-top: 20px; justify-content: flex-end;
}

/* ─── Toast ─── */
.toast-wrap {
  position: fixed; top: 20px; right: 20px; z-index: 100;
  display: flex; flex-direction: column; gap: 10px;
}
.toast {
  min-width: 260px; max-width: 360px; background: var(--surface);
  border: 1px solid var(--line); border-left: 3px solid var(--text-muted);
  border-radius: var(--radius-sm); padding: 12px 16px;
  box-shadow: var(--shadow-lg); font-size: 14px;
  animation: slideIn 0.25s ease;
}
.toast .t-title { font-weight: 700; margin-bottom: 2px; }
.toast .t-msg { color: var(--text-dim); font-size: 13px; }
.toast.ok { border-left-color: var(--success); }
.toast.err { border-left-color: var(--alert); }
.toast.warn { border-left-color: var(--warning); }
@keyframes slideIn {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ─── Utilities ─── */
.text-muted { color: var(--text-muted); }
.text-primary { color: var(--blue); }
.text-danger { color: var(--alert); }
.text-success { color: var(--success); }
.mono { font-family: var(--mono); }
.mt-16 { margin-top: 16px; }
.mb-16 { margin-bottom: 16px; }
.flex { display: flex; align-items: center; gap: 8px; }

/* ─── Master-only visibility ─── */
.master-only { display: none; }
.user-master .master-only { display: flex; }
.user-master .master-only.nav-item { display: flex; }
.user-master .master-only.nav-sep { display: block; }

/* ─── Responsive ─── */
@media (max-width: 820px) {
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0;
    transform: translateX(-100%); width: 280px;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: translateX(0); }
  .mobile-menu-btn { display: flex !important; }
  .main { padding: 16px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .topbar h1 { font-size: 18px; }
}
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat .value { font-size: 22px; }
  .card { padding: 16px; }
  .modal { padding: 24px 20px; }
  .toolbar { flex-direction: column; }
  .toolbar .grow { min-width: unset; }
}

/* ─── Auth pages (login / register) ─── */
.auth-wrap {
  min-height: 100vh; display: flex; align-items: center;
  justify-content: center; padding: 24px;
  background: var(--bg);
}
.auth-card {
  width: 100%; max-width: 420px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 16px; padding: 32px;
  box-shadow: var(--shadow-lg);
}
.auth-card .brand { justify-content: center; margin-bottom: 6px; }
.auth-title {
  text-align: center; font-size: 22px; font-weight: 700;
  margin-top: 14px;
}
.auth-sub {
  text-align: center; color: var(--text-dim); font-size: 14px;
  margin-bottom: 24px;
}
.field-hint { font-size: 12px; color: var(--text-muted); margin-top: 6px; }

/* ─── Notification alert ─── */
.alert-info {
  background: var(--blue-light); border-left: 3px solid var(--blue-bright);
  padding: 12px 14px; border-radius: var(--radius-sm);
}
