@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap');

/* ==========================================
   DESIGN TOKENS — single anchor hue, no gradients
   ========================================== */
:root {
  --bg-page: #0c0d10;
  --bg-surface: #141518;
  --bg-raised: #1a1b20;
  --bg-inset: #111215;
  --border-subtle: rgba(255, 255, 255, 0.06);
  --border-default: rgba(255, 255, 255, 0.1);
  --border-strong: rgba(255, 255, 255, 0.18);

  --accent: #e2a832;
  --accent-dim: rgba(226, 168, 50, 0.12);
  --accent-text: #f0c261;

  --text-primary: #e8e6e3;
  --text-secondary: #8a8a8e;
  --text-muted: #55555a;

  --color-success: #34d399;
  --color-danger: #f87171;
  --color-warning: #fbbf24;
  --color-info: #60a5fa;

  --font-display: 'Space Grotesk', sans-serif;
  --font-body: 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-standard: cubic-bezier(0.4, 0, 0.2, 1);
  --transition-fast: 150ms var(--ease-out);
  --transition-normal: 280ms var(--ease-out);

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;
  --space-20: 80px;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
}

/* ==========================================
   RESET & BASE
   ========================================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.6;
  background: var(--bg-page);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

code, pre, .mono {
  font-family: var(--font-mono);
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }

::selection {
  background: var(--accent);
  color: var(--bg-page);
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ==========================================
   SHARED NAV — top bar for public pages
   ========================================== */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-6);
  max-width: 1200px;
  margin: 0 auto;
}

.top-bar__brand {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.top-bar__brand-mark {
  width: 24px;
  height: 24px;
  background: var(--accent);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--bg-page);
}

.top-bar__nav {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.top-bar__link {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  transition: color var(--transition-fast), background var(--transition-fast);
}

.top-bar__link:hover {
  color: var(--text-primary);
  background: var(--bg-raised);
}

.top-bar__link.active {
  color: var(--accent-text);
  background: var(--accent-dim);
}

/* ==========================================
   PANELS & SURFACES — solid, no glass blur
   ========================================== */
.surface {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}

.surface--raised {
  background: var(--bg-raised);
}

/* Keep .glass-panel for admin backwards compat */
.glass-panel {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}

/* ==========================================
   BUTTONS
   ========================================== */
.btn {
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 600;
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  transition: all var(--transition-fast);
  white-space: nowrap;
  line-height: 1.4;
  text-decoration: none;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--accent);
  color: var(--bg-page);
  border-color: var(--accent);
}

.btn-primary:hover {
  background: #d49a28;
  border-color: #d49a28;
}

.btn-secondary {
  background: var(--bg-raised);
  color: var(--text-primary);
  border-color: var(--border-default);
}

.btn-secondary:hover {
  border-color: var(--border-strong);
  background: #22232a;
}

.btn-danger {
  background: rgba(248, 113, 113, 0.1);
  color: var(--color-danger);
  border-color: rgba(248, 113, 113, 0.2);
}

.btn-danger:hover {
  background: var(--color-danger);
  color: white;
  border-color: var(--color-danger);
}

.btn-sm {
  font-size: 0.75rem;
  padding: var(--space-1) var(--space-3);
}

/* ==========================================
   FORMS
   ========================================== */
.form-group {
  margin-bottom: var(--space-5);
}

.form-group label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: var(--space-2);
}

.form-control {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  font-family: var(--font-body);
  font-size: 0.85rem;
  color: var(--text-primary);
  background: var(--bg-inset);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color var(--transition-fast);
}

.form-control:focus {
  border-color: var(--accent);
}

.form-control::placeholder {
  color: var(--text-muted);
}

select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L5 5L9 1' stroke='%2355555a' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

textarea.form-control {
  resize: vertical;
  min-height: 56px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
}

/* ==========================================
   TABLES
   ========================================== */
.table-container {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  text-align: left;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border-default);
  background: var(--bg-inset);
}

td {
  padding: var(--space-3) var(--space-4);
  font-size: 0.85rem;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
}

tr {
  transition: background var(--transition-fast);
}

tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

/* ==========================================
   STATUS BADGES
   ========================================== */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 2px var(--space-2);
  border-radius: 99px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.status-active {
  background: rgba(52, 211, 153, 0.1);
  color: var(--color-success);
  border: 1px solid rgba(52, 211, 153, 0.2);
}

.status-suspended {
  background: rgba(248, 113, 113, 0.1);
  color: var(--color-danger);
  border: 1px solid rgba(248, 113, 113, 0.2);
}

.status-expired {
  background: rgba(251, 191, 36, 0.1);
  color: var(--color-warning);
  border: 1px solid rgba(251, 191, 36, 0.2);
}

/* ==========================================
   TOAST NOTIFICATIONS
   ========================================== */
#toast-container {
  position: fixed;
  top: var(--space-4);
  right: var(--space-4);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.toast {
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 500;
  animation: toastIn 280ms var(--ease-out) forwards;
  max-width: 380px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  transition: transform 0.15s ease;
  pointer-events: auto;
}
.toast:hover {
  transform: translateX(-3px);
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes toastOut {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(20px); }
}

.toast-success {
  background: var(--bg-raised);
  color: var(--color-success);
  border: 1px solid rgba(52, 211, 153, 0.2);
}

.toast-error {
  background: var(--bg-raised);
  color: var(--color-danger);
  border: 1px solid rgba(248, 113, 113, 0.2);
}

.toast-info {
  background: var(--bg-raised);
  color: var(--color-info);
  border: 1px solid rgba(96, 165, 250, 0.2);
}

/* ==========================================
   ADMIN LAYOUT — sidebar + main
   ========================================== */
.app-container {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 240px;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  padding: var(--space-5);
  position: fixed;
  height: 100vh;
  overflow-y: auto;
  z-index: 100;
}

.logo-section {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-8);
  padding-bottom: var(--space-5);
  border-bottom: 1px solid var(--border-subtle);
}

.logo-icon {
  width: 32px;
  height: 32px;
  background: var(--accent);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  color: var(--bg-page);
}

.logo-text {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.nav-links {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

.nav-item a {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.nav-item a:hover {
  color: var(--text-primary);
  background: var(--bg-raised);
}

.nav-item.active a {
  color: var(--accent-text);
  background: var(--accent-dim);
}

.nav-item a svg {
  opacity: 0.5;
  flex-shrink: 0;
}

.nav-item.active a svg {
  opacity: 1;
}

.sidebar-footer {
  padding-top: var(--space-5);
  border-top: 1px solid var(--border-subtle);
  margin-top: auto;
}

.main-content {
  flex: 1;
  margin-left: 240px;
  padding: var(--space-8);
  max-width: 100%;
}

/* ==========================================
   DOMAIN BANNER — admin top bar
   ========================================== */
.domain-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-5);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-6);
  gap: var(--space-4);
}

.domain-url {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--accent-text);
}

/* ==========================================
   TABS
   ========================================== */
.tab-section { display: none; }
.tab-section.active { display: block; }

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-6);
  gap: var(--space-4);
}

.section-title {
  font-size: 1.4rem;
  font-weight: 700;
}

/* ==========================================
   STATS GRID
   ========================================== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-8);
}

.stats-card {
  padding: var(--space-5);
}

.stats-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: var(--space-2);
}

.stats-value {
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--text-primary);
  transition: color var(--transition-normal);
}

.stats-card:hover .stats-value {
  color: var(--accent-text);
}

.stats-change {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: var(--space-1);
}

/* ==========================================
   MODALS
   ========================================== */
.modal-backdrop {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
}

.modal-backdrop.open { display: flex; }

.modal {
  width: 90%;
  max-width: 560px;
  max-height: 85vh;
  overflow-y: auto;
  padding: var(--space-8);
  animation: modalIn 200ms var(--ease-out) forwards;
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-6);
}

.modal-header h3 {
  font-size: 1.1rem;
  font-weight: 700;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.4rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: var(--space-1);
  line-height: 1;
  transition: color var(--transition-fast);
}

.modal-close:hover { color: var(--text-primary); }

/* ==========================================
   LOGIN OVERLAY
   ========================================== */
#login-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-page);
  z-index: 10000;
}

.login-card {
  width: 100%;
  max-width: 400px;
  padding: var(--space-10);
  text-align: center;
  animation: loginIn 400ms var(--ease-out) forwards;
}

@keyframes loginIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.login-card h2 {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: var(--space-2);
}

.login-card p {
  color: var(--text-secondary);
  font-size: 0.85rem;
  margin-bottom: var(--space-8);
}

/* ==========================================
   CODE BLOCKS
   ========================================== */
.code-block {
  background: var(--bg-inset);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: var(--space-4) var(--space-5);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  line-height: 1.7;
  color: var(--text-secondary);
  overflow-x: auto;
  white-space: pre;
  cursor: pointer;
  transition: border-color var(--transition-fast);
}

.code-block:hover {
  border-color: var(--border-strong);
}

/* ==========================================
   COPY BUTTON (inline icon)
   ========================================== */
.copy-icon-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px;
  vertical-align: middle;
  transition: color var(--transition-fast);
}

.copy-icon-btn:hover { color: var(--accent-text); }

.masked-key {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-secondary);
}

/* ==========================================
   RECEIPT / CLIENT PORTAL
   ========================================== */
.receipt-container {
  max-width: 680px;
  margin: 0 auto;
  padding: var(--space-8) var(--space-5);
}

.receipt-header {
  margin-bottom: var(--space-10);
}

.receipt-header h1 {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: var(--space-2);
  letter-spacing: -0.02em;
}

.receipt-header p {
  color: var(--text-secondary);
  font-size: 0.95rem;
}

/* Key input bar */
.key-input-group {
  display: flex;
  gap: var(--space-3);
  margin-bottom: var(--space-8);
}

.key-input-group .form-control {
  flex: 1;
  font-family: var(--font-mono);
  font-size: 0.85rem;
}

/* Metric cards for portal */
.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-8);
}

.metric-card {
  padding: var(--space-5);
}

.metric-card__label {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: var(--space-1);
}

.metric-card__value {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
}

.metric-card__sub {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Timer cards */
.timer-section {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-3);
  margin-bottom: var(--space-8);
}

.timer-card {
  text-align: center;
  padding: var(--space-5) var(--space-3);
  transition: border-color var(--transition-normal);
}

.timer-card:hover {
  border-color: var(--accent);
}

.timer-card__value {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-primary);
}

.timer-card__label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: var(--space-1);
}

/* ==========================================
   PULSE ANIMATIONS
   ========================================== */
@keyframes pulseGreen {
  0%, 100% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.4); }
  50% { box-shadow: 0 0 0 4px rgba(52, 211, 153, 0); }
}

@keyframes pulseRed {
  0%, 100% { box-shadow: 0 0 0 0 rgba(248, 113, 113, 0.4); }
  50% { box-shadow: 0 0 0 4px rgba(248, 113, 113, 0); }
}

/* ==========================================
   RESPONSIVE BREAKPOINTS
   ========================================== */
@media (max-width: 768px) {
  .app-container { flex-direction: column; }
  .sidebar {
    width: 100%; height: auto; position: relative;
    flex-direction: row; padding: var(--space-3) var(--space-4);
    overflow-x: auto;
  }
  .sidebar .nav-links {
    flex-direction: row; overflow-x: auto; gap: 2px;
  }
  .sidebar .nav-item a {
    padding: var(--space-2) var(--space-3);
    font-size: 0.78rem; white-space: nowrap;
  }
  .sidebar .logo-section { margin-bottom: 0; padding-bottom: 0; border-bottom: 0; }
  .sidebar-footer { display: none; }
  .main-content { margin-left: 0; padding: var(--space-5); }
  .domain-banner {
    flex-direction: column; text-align: center; gap: var(--space-3);
  }
  .domain-url { font-size: 0.8rem; word-break: break-all; }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: var(--space-3); }
  .section-header { flex-direction: column; gap: var(--space-3); align-items: stretch; }
  .table-container { font-size: 0.82rem; }
  th, td { padding: var(--space-2) var(--space-3); }
  .modal { width: 95%; padding: var(--space-5); }
  .form-row { grid-template-columns: 1fr; }
  .receipt-container { padding: var(--space-5) var(--space-3); }
  .timer-section { grid-template-columns: repeat(2, 1fr); }
  .top-bar { flex-direction: column; gap: var(--space-3); }
  .top-bar__nav { flex-wrap: wrap; justify-content: center; }
  .key-input-group { flex-direction: column; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .receipt-header h1 { font-size: 1.5rem; }
  .metric-grid { grid-template-columns: 1fr; }
}

/* ==========================================
   ACCESSIBILITY
   ========================================== */
.btn:focus-visible, .form-control:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Loading skeleton */
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.skeleton {
  background: linear-gradient(90deg, rgba(255,255,255,0.02) 25%, rgba(255,255,255,0.06) 50%, rgba(255,255,255,0.02) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: var(--radius-sm);
  min-height: 20px;
}

/* Copy success flash */
.btn-copied {
  background: rgba(52, 211, 153, 0.1) !important;
  border-color: var(--color-success) !important;
  color: var(--color-success) !important;
}

/* ==========================================
   SCROLLBAR for tables
   ========================================== */
.table-container::-webkit-scrollbar { height: 4px; }
.table-container::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 2px;
}
