/* =============================================================
   Cryptic Hub - Key System Pages
   Dark, premium, mobile-first
   ============================================================= */

:root {
  --bg:           #07090f;
  --bg-2:         #0c1018;
  --surface:      #131826;
  --surface-2:    #1a2236;
  --border:       rgba(255, 255, 255, 0.08);
  --border-strong:rgba(255, 255, 255, 0.16);
  --text:         #e7ecf5;
  --text-muted:   #8b95ad;
  --accent:       #8b5cf6;
  --accent-2:     #ec4899;
  --accent-glow:  rgba(139, 92, 246, 0.35);
  --success:      #10b981;
  --warning:      #f59e0b;
  --error:        #ef4444;
  --radius:       16px;
  --radius-sm:    10px;
  --shadow:       0 20px 60px rgba(0, 0, 0, 0.45);
}

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

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "SF Pro Display",
               Roboto, "Helvetica Neue", Arial, "Tajawal", "Noto Sans Arabic",
               sans-serif;
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(139, 92, 246, 0.18), transparent 60%),
    radial-gradient(900px 500px at 110% 10%, rgba(236, 72, 153, 0.14), transparent 60%),
    radial-gradient(800px 800px at 50% 120%, rgba(99, 102, 241, 0.12), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  min-height: 100dvh;
}

[dir="rtl"] body { direction: rtl; }

/* ========== Layout ========== */
.app { min-height: 100dvh; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; gap: 12px;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; }
.brand-mark {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: grid; place-items: center;
  font-weight: 800; font-size: 18px; color: #fff;
  box-shadow: 0 8px 24px var(--accent-glow);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.05; }
.brand-text strong { font-size: 15px; font-weight: 700; letter-spacing: 0.2px; }
.brand-text span { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* Language */
.lang-wrap { position: relative; }
.lang-btn {
  display: flex; align-items: center; gap: 6px;
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  padding: 8px 12px; border-radius: 999px;
  font: inherit; font-size: 13px; cursor: pointer;
  transition: background .15s ease, border-color .15s ease;
}
.lang-btn:hover { background: var(--surface-2); border-color: var(--border-strong); }
.lang-btn .chev { font-size: 10px; opacity: .7; }

.lang-menu {
  position: absolute; top: calc(100% + 6px); inset-inline-end: 0;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 6px; min-width: 180px; box-shadow: var(--shadow);
  display: none; z-index: 50;
}
.lang-menu.open { display: block; }
.lang-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 8px; cursor: pointer; font-size: 14px; user-select: none;
}
.lang-item:hover { background: var(--surface-2); }
.lang-item.active { background: rgba(139, 92, 246, 0.12); color: #fff; }

/* ========== Tabs ========== */
.tabs {
  display: flex;
  justify-content: center;
  gap: 6px;
  padding: 4px 16px 0;
  flex-wrap: wrap;
}
.tab {
  text-decoration: none;
  color: var(--text-muted);
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid transparent;
  transition: background .15s, color .15s, border-color .15s;
}
.tab:hover { color: var(--text); background: var(--surface); border-color: var(--border); }
.tab.active {
  color: #fff;
  background: rgba(139, 92, 246, 0.15);
  border-color: rgba(139, 92, 246, 0.35);
}

/* ========== Banner ========== */
.banner {
  margin: 12px 16px 0;
  padding: 10px 14px;
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.3);
  border-radius: var(--radius-sm);
  color: #fcd34d;
  font-size: 13px;
  text-align: center;
}

/* ========== Main Card ========== */
.main { flex: 1; display: grid; place-items: center; padding: 24px 16px 48px; }

.card {
  width: 100%; max-width: 460px;
  background: linear-gradient(180deg, rgba(26, 34, 54, 0.85), rgba(19, 24, 38, 0.85));
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 28px 24px 24px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  position: relative; overflow: hidden;
}
.card-wide { max-width: 600px; }
.card::before {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.08), transparent 40%);
  pointer-events: none;
}

.icon-wrap {
  width: 64px; height: 64px;
  border-radius: 18px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: grid; place-items: center;
  margin: 0 auto 18px;
  box-shadow: 0 12px 30px var(--accent-glow);
  position: relative;
}
.icon-wrap.success { background: linear-gradient(135deg, #10b981, #059669); box-shadow: 0 12px 30px rgba(16,185,129,.35); }
.icon-wrap.warning { background: linear-gradient(135deg, #f59e0b, #ef4444); box-shadow: 0 12px 30px rgba(245,158,11,.35); }
.icon-wrap svg { width: 32px; height: 32px; color: #fff; }

.card h1 { text-align: center; font-size: 22px; font-weight: 700; margin-bottom: 8px; letter-spacing: -0.2px; }
.card .sub { text-align: center; color: var(--text-muted); font-size: 14.5px; margin-bottom: 22px; }

/* Pills */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 11px; border-radius: 999px;
  font-size: 12px; font-weight: 600;
  background: rgba(139, 92, 246, 0.15); color: #c4b5fd;
  border: 1px solid rgba(139, 92, 246, 0.3);
}
.pill.success { background: rgba(16,185,129,.12); color: #6ee7b7; border-color: rgba(16,185,129,.3); }
.pill.warning { background: rgba(245,158,11,.12); color: #fcd34d; border-color: rgba(245,158,11,.3); }
.pill.muted   { background: rgba(255,255,255,.06); color: var(--text-muted); border-color: var(--border); }
.pill-sm { padding: 3px 8px; font-size: 11px; }
.pill-row { display: flex; justify-content: center; margin-bottom: 14px; }

/* Countdown (small) */
.countdown { display: flex; justify-content: center; gap: 8px; margin: 18px 0 22px; flex-wrap: wrap; }
.cd-cell {
  background: rgba(255,255,255,0.04); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px 14px; min-width: 64px; text-align: center;
}
.cd-cell .num { font-size: 22px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.cd-cell .lbl { font-size: 11px; color: var(--text-muted); margin-top: 4px; text-transform: uppercase; letter-spacing: .5px; }

/* Big countdown (keys page) */
.big-cd-wrap {
  text-align: center;
  padding: 18px 14px 24px;
  margin-bottom: 18px;
  background:
    radial-gradient(120% 80% at 50% 0%, rgba(139, 92, 246, 0.18), transparent 60%),
    linear-gradient(180deg, rgba(139, 92, 246, 0.08), rgba(236, 72, 153, 0.04));
  border: 1px solid rgba(139, 92, 246, 0.22);
  border-radius: 18px;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.05),
    0 8px 28px rgba(139, 92, 246, 0.18);
}
.big-cd-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 14px;
  background: rgba(16,185,129,.14);
  color: #6ee7b7;
  border: 1px solid rgba(16,185,129,.35);
  border-radius: 999px;
  font-size: 12px; font-weight: 700;
  margin-bottom: 18px;
  letter-spacing: .3px;
  box-shadow: 0 0 16px rgba(16,185,129,.18);
}
.big-cd-pill::before {
  content: "";
  width: 7px; height: 7px; border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 8px #10b981;
  animation: pulseDot 1.6s ease-in-out infinite;
}
@keyframes pulseDot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: .55; transform: scale(.85); }
}
.big-cd { display: flex; justify-content: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.big-cell {
  position: relative;
  background: linear-gradient(180deg, rgba(20, 24, 40, 0.85), rgba(14, 17, 28, 0.85));
  border: 1px solid rgba(139, 92, 246, 0.28);
  border-radius: 14px;
  padding: 14px 14px 12px;
  min-width: 72px;
  text-align: center;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.06),
    0 6px 18px rgba(0,0,0,.35);
}
.big-num {
  font-size: 38px; font-weight: 800; line-height: 1;
  font-variant-numeric: tabular-nums;
  background: linear-gradient(135deg, #c4b5fd 0%, #ec4899 100%);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
  text-shadow: 0 0 18px rgba(139, 92, 246, 0.25);
}
@supports not ((-webkit-background-clip: text) or (background-clip: text)) {
  .big-num { color: #c4b5fd; -webkit-text-fill-color: #c4b5fd; }
}
.big-lbl { font-size: 10px; color: var(--text-muted); margin-top: 8px; text-transform: uppercase; letter-spacing: 1px; }
.big-cd-label { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* Progress bar */
.progress {
  width: 100%; height: 6px;
  background: rgba(255,255,255,.05);
  border-radius: 999px; overflow: hidden;
  margin: 6px 0 18px;
}
.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  border-radius: 999px;
  transition: width 0.4s ease;
}

/* Key info grid */
.kv-grid { display: grid; gap: 8px; margin-bottom: 6px; }
.kv-row {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 12px 14px;
  background: linear-gradient(180deg, rgba(255,255,255,.04), rgba(255,255,255,.015));
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 13.5px;
  transition: background .15s ease, border-color .15s ease;
}
.kv-row:hover {
  background: linear-gradient(180deg, rgba(139,92,246,.08), rgba(255,255,255,.02));
  border-color: rgba(139,92,246,.22);
}
.kv-k { color: var(--text-muted); font-weight: 500; }
.kv-v { color: var(--text); font-weight: 600; text-align: end; font-variant-numeric: tabular-nums; }

/* Actions */
.actions { margin-top: 12px; display: flex; flex-direction: column; gap: 0; }
.hint { font-size: 12px; color: var(--text-muted); text-align: center; margin-top: 12px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 14px 20px;
  border-radius: 12px; border: none;
  font: inherit; font-size: 15.5px; font-weight: 600;
  cursor: pointer;
  transition: transform .06s ease, box-shadow .15s ease, background .15s ease, opacity .15s ease;
  text-decoration: none; color: #fff;
}
.btn:active { transform: scale(0.985); }
.btn:disabled { opacity: .65; cursor: progress; }

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 10px 30px var(--accent-glow);
}
.btn-primary:hover { box-shadow: 0 14px 36px var(--accent-glow); }

.btn-secondary {
  background: var(--surface-2); border: 1px solid var(--border-strong);
}
.btn-secondary:hover { background: #222b42; }

.btn-inline { width: auto; padding: 10px 16px; font-size: 14px; }

.btn + .btn { margin-top: 10px; }

.btn-link {
  background: none; border: none; color: var(--accent);
  font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; padding: 6px 8px;
}
.btn-link:hover { color: #c4b5fd; }
.btn-link.danger { color: var(--error); }
.btn-link.danger:hover { color: #fca5a5; }

/* Inputs */
.input-wrap { margin-bottom: 14px; }
input, .input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  color: var(--text);
  padding: 12px 14px;
  border-radius: 10px;
  font: inherit; font-size: 14.5px;
  transition: border-color .15s, background .15s;
}
input:focus, .input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface-2);
}
input[type="number"] { -moz-appearance: textfield; }
input::-webkit-outer-spin-button, input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.error-line { color: #fca5a5; font-size: 13px; text-align: center; margin-top: 10px; }

/* Spinner */
.spin {
  width: 18px; height: 18px;
  border: 2px solid rgba(255,255,255,.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Center loader */
.loader {
  display: grid; place-items: center; gap: 14px; padding: 20px 0;
  color: var(--text-muted); font-size: 14px;
}
.loader .spin { width: 28px; height: 28px; border-width: 3px; }

/* Hidden helper */
.hidden { display: none !important; }

/* ========== Admin dashboard ========== */
.dash-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.dash-head h1 { font-size: 22px; font-weight: 700; text-align: start; margin: 0; }

.toggle-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 16px;
  background: rgba(255,255,255,.03);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 16px;
}
.toggle-info { min-width: 0; }
.toggle-title { font-weight: 700; font-size: 14.5px; }
.toggle-sub { color: var(--text-muted); font-size: 12.5px; margin-top: 2px; }

.switch { position: relative; display: inline-block; width: 50px; height: 28px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute; cursor: pointer; inset: 0;
  background: #2b3550; border-radius: 999px; transition: background .2s;
}
.slider::before {
  content: ""; position: absolute; height: 22px; width: 22px;
  left: 3px; top: 3px; background: #fff; border-radius: 50%;
  transition: transform .2s;
}
.switch input:checked + .slider { background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
.switch input:checked + .slider::before { transform: translateX(22px); }

.stat-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px;
  margin-bottom: 18px;
}
.stat {
  background: rgba(255,255,255,.03);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 12px;
  text-align: center;
}
.stat-num { font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; }
.stat-lbl { font-size: 11.5px; color: var(--text-muted); margin-top: 4px; text-transform: uppercase; letter-spacing: .5px; }

.panel {
  background: rgba(255,255,255,.03);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 14px;
}
.panel-title { font-weight: 700; font-size: 14px; margin-bottom: 10px; }
.panel-title-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.panel-title-row .panel-title { margin: 0; }
.panel-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.panel-row > input { flex: 1 1 120px; }
.panel-row > input[type="number"] { flex: 0 0 90px; }

.table-wrap { overflow-x: auto; }
.data-table {
  width: 100%; border-collapse: collapse; font-size: 12.5px;
}
.data-table th, .data-table td {
  padding: 8px 10px; text-align: start; vertical-align: middle;
  border-bottom: 1px solid var(--border);
}
.data-table th {
  font-weight: 700; color: var(--text-muted); font-size: 11px;
  text-transform: uppercase; letter-spacing: .5px;
}
.data-table td.muted { color: var(--text-muted); text-align: center; padding: 16px; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 12px; }

[dir="rtl"] .dash-head { flex-direction: row-reverse; }

/* Footer */
.foot {
  text-align: center; padding: 20px 16px 28px;
  color: var(--text-muted); font-size: 12.5px;
  display: flex; flex-direction: column; gap: 4px;
}
.foot a { color: var(--text-muted); text-decoration: underline; text-decoration-color: var(--border-strong); }

/* Toast */
.toast {
  position: fixed; bottom: 22px; left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--surface); color: var(--text);
  padding: 12px 18px; border-radius: 999px;
  border: 1px solid var(--border-strong); box-shadow: var(--shadow);
  font-size: 14px;
  opacity: 0; pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
  z-index: 100; max-width: 90vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { border-color: rgba(239, 68, 68, .5); }

/* Tiny screens */
@media (max-width: 380px) {
  .card { padding: 22px 18px 18px; }
  .card h1 { font-size: 20px; }
  .cd-cell { min-width: 56px; padding: 8px 10px; }
  .cd-cell .num { font-size: 18px; }
  .big-cell { min-width: 64px; padding: 10px 12px; }
  .big-num { font-size: 28px; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
}
