/* ═══════════════════════════════════════════════════════════════
   Shuish Key Manager — Main Stylesheet
   ═══════════════════════════════════════════════════════════════ */

/* ── Variables ──────────────────────────────────────────────────── */
:root {
  --sidebar-w: 240px;
  --sidebar-bg: #16192b;
  --sidebar-border: rgba(255,255,255,.07);
  --sidebar-text: #9ba3b5;
  --sidebar-hover-bg: rgba(255,255,255,.06);
  --sidebar-active-bg: rgba(99,102,241,.18);
  --sidebar-active-text: #818cf8;
  --accent: #6366f1;
  --accent-dark: #4f46e5;
  --body-bg: #f0f2f5;
  --card-radius: 10px;
  --topbar-h: 58px;
  --transition: .2s ease;
}

/* ── Reset / Base ───────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; font-family: 'Segoe UI', system-ui, sans-serif; }

/* ═══════════════════════════════════════════════════════════════
   ADMIN LAYOUT
   ═══════════════════════════════════════════════════════════════ */
.admin-body { background: var(--body-bg); }

.layout-wrapper {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ─────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  z-index: 200;
  transition: transform var(--transition);
  border-right: 1px solid var(--sidebar-border);
}

.sidebar.collapsed { transform: translateX(calc(-1 * var(--sidebar-w))); }

/* Brand */
.sidebar-header {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--sidebar-border);
}
.brand-link { text-decoration: none; display: flex; align-items: center; }
.brand-s    { font-size: 1.7rem; font-weight: 800; color: var(--accent); letter-spacing: -1px; line-height: 1; }
.brand-rest { font-size: 1.4rem; font-weight: 700; color: #fff; line-height: 1; }

/* Nav */
.sidebar-nav {
  flex: 1;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
}
.sn-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 12px;
  border-radius: 8px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: .875rem;
  font-weight: 500;
  transition: background var(--transition), color var(--transition);
}
.sn-item i { font-size: 1rem; flex-shrink: 0; }
.sn-item:hover { background: var(--sidebar-hover-bg); color: #fff; }
.sn-item.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-active-text);
}

/* Footer */
.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--sidebar-border);
}
.sf-user {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--sidebar-text);
  font-size: .8rem;
  margin-bottom: 6px;
}
.sf-user i { font-size: 1.1rem; }

/* ── Main content ───────────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  transition: margin-left var(--transition);
  min-width: 0;
}
.main-content.full { margin-left: 0; }

/* Top bar */
.top-bar {
  height: var(--topbar-h);
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 4px rgba(0,0,0,.05);
}
.top-bar-title { font-size: 1rem; font-weight: 600; color: #111827; }
.sidebar-toggle-btn {
  background: none; border: none; padding: 6px;
  cursor: pointer; color: #6b7280; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  transition: background var(--transition);
}
.sidebar-toggle-btn:hover { background: #f3f4f6; }

/* Page body */
.page-body { padding: 24px; }

/* ── Cards ──────────────────────────────────────────────────────── */
.card {
  border: 1px solid #e5e7eb;
  border-radius: var(--card-radius);
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
}
.card-header {
  background: #fff;
  border-bottom: 1px solid #f0f0f0;
  padding: 12px 16px;
  border-radius: var(--card-radius) var(--card-radius) 0 0;
}

/* ── Stat cards ─────────────────────────────────────────────────── */
.stat-card {
  border-radius: var(--card-radius);
  padding: 20px;
  color: #fff;
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: relative;
  overflow: hidden;
}
.stat-card::after {
  content: '';
  position: absolute;
  right: -10px; bottom: -10px;
  width: 80px; height: 80px;
  border-radius: 50%;
  background: rgba(255,255,255,.12);
}
.stat-primary  { background: linear-gradient(135deg, #6366f1, #4f46e5); }
.stat-success  { background: linear-gradient(135deg, #22c55e, #16a34a); }
.stat-warning  { background: linear-gradient(135deg, #f59e0b, #d97706); }
.stat-info     { background: linear-gradient(135deg, #3b82f6, #2563eb); }

.stat-icon { font-size: 1.5rem; opacity: .9; }
.stat-val  { font-size: 2rem; font-weight: 800; line-height: 1; }
.stat-lbl  { font-size: .8rem; opacity: .85; }

/* ── Tables ─────────────────────────────────────────────────────── */
.table th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: #6b7280; }
.table td { font-size: .875rem; }
.table-hover > tbody > tr:hover > td { background: #f8faff; }

.key-code {
  font-family: 'Courier New', monospace;
  font-size: .8rem;
  background: #f3f4f6;
  padding: 2px 6px;
  border-radius: 4px;
  user-select: all;
}
.key-table .key-code { max-width: 280px; display: inline-block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: middle; }

/* ── Buttons ────────────────────────────────────────────────────── */
.btn-primary { background: var(--accent); border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.btn-xs {
  padding: 2px 7px;
  font-size: .75rem;
  border-radius: 5px;
}

/* ── Empty state ────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: #9ca3af;
}
.empty-state i { font-size: 2.5rem; display: block; margin-bottom: 10px; }
.empty-state p { margin: 0; }

/* ── API code block ─────────────────────────────────────────────── */
.api-block {
  background: #1e2130;
  color: #a5d6a7;
  border-radius: 8px;
  padding: 12px 14px;
  font-size: .75rem;
  margin: 0;
  overflow-x: auto;
}

/* ═══════════════════════════════════════════════════════════════
   LOGIN PAGE
   ═══════════════════════════════════════════════════════════════ */
.login-body {
  min-height: 100vh;
  background: linear-gradient(135deg, #1a1e2e 0%, #2d3250 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.login-wrap { width: 100%; max-width: 400px; }
.login-card {
  background: #fff;
  border-radius: 16px;
  padding: 40px;
  box-shadow: 0 20px 60px rgba(0,0,0,.35);
}
.login-brand { display: flex; align-items: flex-end; justify-content: center; }
.brand-s-lg    { font-size: 3rem; font-weight: 800; color: var(--accent); letter-spacing: -2px; line-height: 1; }
.brand-rest-lg { font-size: 2.4rem; font-weight: 700; color: #1a1e2e; line-height: 1; }

/* ═══════════════════════════════════════════════════════════════
   PUBLIC KEY PAGE
   ═══════════════════════════════════════════════════════════════ */
.public-body {
  min-height: 100vh;
  background: #0d0f1e;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  overflow: hidden;
}

/* ── Canvas particle background ─────────────────────────────────── */
#bg-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

/* ── Ambient glow orbs ──────────────────────────────────────────── */
.orb {
  position: fixed;
  border-radius: 50%;
  pointer-events: none;
  z-index: 0;
  animation: orb-drift ease-in-out infinite alternate;
}
.orb-1 {
  width: 520px; height: 520px;
  background: radial-gradient(circle at 40% 40%, rgba(99,102,241,.35), transparent 70%);
  top: -160px; left: -160px;
  animation-duration: 22s;
}
.orb-2 {
  width: 420px; height: 420px;
  background: radial-gradient(circle at 60% 60%, rgba(139,92,246,.3), transparent 70%);
  bottom: -120px; right: -120px;
  animation-duration: 30s;
  animation-delay: -12s;
}
.orb-3 {
  width: 280px; height: 280px;
  background: radial-gradient(circle at 50% 50%, rgba(59,130,246,.25), transparent 70%);
  top: 38%; left: 58%;
  animation-duration: 24s;
  animation-delay: -6s;
}
@keyframes orb-drift {
  from { transform: translate(0, 0) scale(1); }
  to   { transform: translate(35px, 28px) scale(1.08); }
}

/* ── Layout ──────────────────────────────────────────────────────── */
.public-wrap {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
}
.pub-brand { display: flex; align-items: flex-end; }
.pub-brand-rest { color: #fff !important; }

/* ── Card ────────────────────────────────────────────────────────── */
.pub-card {
  width: 100%;
  border-radius: 20px;
  padding: 40px 36px;
  text-align: center;
  background: rgba(255,255,255,.96);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: 0 24px 72px rgba(0,0,0,.5), 0 0 0 1px rgba(99,102,241,.15);
}

/* ── Key icon with glow ──────────────────────────────────────────── */
.pub-icon-wrap { position: relative; display: inline-flex; justify-content: center; }
.pub-icon-glow {
  position: absolute;
  inset: -12px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(99,102,241,.25), transparent 70%);
  animation: icon-pulse 3s ease-in-out infinite;
}
@keyframes icon-pulse {
  0%, 100% { transform: scale(1);   opacity: .7; }
  50%       { transform: scale(1.2); opacity: 1;  }
}

.pub-icon { font-size: 3rem; line-height: 1; }
.pub-icon-key { color: var(--accent); }
.pub-icon-ok  { color: #22c55e; }

.pub-card h4 { font-weight: 700; color: #111827; margin-top: 12px; }

/* ── Key display ─────────────────────────────────────────────────── */
.key-display {
  background: linear-gradient(135deg, #f0f0ff, #e8e8ff);
  border: 2px dashed var(--accent);
  border-radius: 10px;
  padding: 16px 20px;
  font-family: 'Courier New', monospace;
  font-size: 1.05rem;
  font-weight: 700;
  color: #1a1e2e;
  letter-spacing: .08em;
  user-select: all;
  word-break: break-all;
}

.pub-deadline {
  font-size: .8rem;
  color: #9ca3af;
}
.pub-expired-msg {
  font-size: 1.1rem;
  font-weight: 600;
  color: #374151;
  margin: 16px 0 8px;
}
.pub-card-error   { border-top: 4px solid #ef4444; }
.pub-card-expired { border-top: 4px solid #22c55e; }
.pub-card-active  { border-top: 4px solid var(--accent); }

/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════════ */
@media (max-width: 767.98px) {
  :root { --sidebar-w: 220px; }
  .sidebar { transform: translateX(calc(-1 * var(--sidebar-w))); }
  .sidebar.mobile-open { transform: translateX(0); box-shadow: 4px 0 24px rgba(0,0,0,.4); }
  .main-content { margin-left: 0 !important; }
  .page-body { padding: 16px; }
  .stat-val { font-size: 1.6rem; }
  .pub-card { padding: 28px 20px; }
}
