@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=Manrope:wght@600;700;800&display=swap');

:root {
  /* Typography */
  --font-body: "Inter", "Segoe UI", system-ui, sans-serif;
  --font-display: "Manrope", "Inter", "Segoe UI", system-ui, sans-serif;

  /* Border Radii (softer, Apple-like) */
  --r-2xl: 24px;
  --r-xl: 20px;
  --r-lg: 16px;
  --r-md: 12px;
  --r-sm: 8px;
  --r-xs: 6px;

  /* Easing (Buttery smooth) */
  --ease: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);

  /* Timings */
  --t1: 150ms;
  --t2: 250ms;
  --t3: 400ms;

  /* Layered Shadows for realistic depth */
  --shadow-1: 0 1px 2px rgba(0,0,0,0.04), 0 2px 4px rgba(0,0,0,0.04);
  --shadow-2: 0 4px 12px rgba(0,0,0,0.05), 0 2px 4px rgba(0,0,0,0.04);
  --shadow-3: 0 12px 32px rgba(0,0,0,0.06), 0 4px 12px rgba(0,0,0,0.04);
  --shadow-hover: 0 24px 48px rgba(0,0,0,0.08), 0 8px 16px rgba(0,0,0,0.04);

  /* Focus Rings */
  --ring-color: rgba(255, 255, 255, 0.15);
  --ring: 0 0 0 3px var(--ring-color);
}

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

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  font-family: var(--font-body);
  color: var(--text);
  background-color: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  transition: background-color var(--t3) var(--ease), color var(--t3) var(--ease);
}

/* =========================================
   THEMES (DARK & LIGHT)
========================================= */
body[data-theme="dark"] {
  --bg: #09090b;
  --bg2: #121214;
  
  --panel: rgba(24, 24, 27, 0.6);
  --panel2: rgba(39, 39, 42, 0.4);
  --panel-solid: #18181b;

  --text: #fafafa;
  --muted: #a1a1aa;
  --muted2: #71717a;

  --border: rgba(255, 255, 255, 0.08);
  --border2: rgba(255, 255, 255, 0.04);
  --border-strong: rgba(255, 255, 255, 0.15);

  --accent: #ffffff;
  --accent-soft: rgba(255, 255, 255, 0.05);

  --danger: #ef4444;
  --danger-bg: rgba(239, 68, 68, 0.1);
  --warn: #f59e0b;
  
  --ring-color: rgba(255, 255, 255, 0.1);
}

body[data-theme="light"] {
  --bg: #fdfcfb;
  --bg2: #f4f4f5;

  --panel: rgba(255, 255, 255, 0.7);
  --panel2: rgba(255, 255, 255, 0.9);
  --panel-solid: #ffffff;

  --text: #09090b;
  --muted: #52525b;
  --muted2: #71717a;

  --border: rgba(0, 0, 0, 0.08);
  --border2: rgba(0, 0, 0, 0.04);
  --border-strong: rgba(0, 0, 0, 0.15);

  --accent: #18181b;
  --accent-soft: rgba(0, 0, 0, 0.03);

  --danger: #dc2626;
  --danger-bg: rgba(220, 38, 38, 0.08);
  --warn: #d97706;

  --ring-color: rgba(0, 0, 0, 0.08);

  --shadow-1: 0 1px 2px rgba(0,0,0,0.02), 0 2px 4px rgba(0,0,0,0.02);
  --shadow-2: 0 4px 12px rgba(0,0,0,0.03), 0 2px 4px rgba(0,0,0,0.02);
  --shadow-3: 0 12px 32px rgba(0,0,0,0.04), 0 4px 12px rgba(0,0,0,0.02);
  --shadow-hover: 0 24px 48px rgba(0,0,0,0.06), 0 8px 16px rgba(0,0,0,0.03);
}

/* =========================================
   BACKGROUND EFFECTS (Expensive look)
========================================= */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  background: 
    linear-gradient(var(--border2) 1px, transparent 1px),
    linear-gradient(90deg, var(--border2) 1px, transparent 1px);
  background-size: 32px 32px;
  mask-image: radial-gradient(circle at 50% 0%, black 10%, transparent 80%);
  -webkit-mask-image: radial-gradient(circle at 50% 0%, black 10%, transparent 80%);
}

.backdrop {
  position: fixed;
  inset: 0;
  z-index: -3;
  pointer-events: none;
  background:
    radial-gradient(circle at 15% 0%, var(--accent-soft) 0%, transparent 50%),
    radial-gradient(circle at 85% 100%, var(--accent-soft) 0%, transparent 50%);
  filter: blur(80px);
}

/* =========================================
   LAYOUT & TYPOGRAPHY
========================================= */
.container {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 0 5vw;
}

.content {
  padding: 40px 5vw 80px;
}

.muted { color: var(--muted); }
.hint {
  color: var(--muted2);
  font-size: 13px;
  line-height: 1.6;
}

h1, h2 {
  margin: 0 0 12px 0;
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
  color: var(--text);
}

p { line-height: 1.6; margin: 0; }

/* =========================================
   HEADER & NAVIGATION
========================================= */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 16px 5vw;
  border-bottom: 1px solid var(--border);
  background: var(--panel2);
  backdrop-filter: blur(24px) saturate(150%);
  -webkit-backdrop-filter: blur(24px) saturate(150%);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  user-select: none;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 18px;
  letter-spacing: -0.01em;
  color: var(--text);
}

.brand::before {
  content: "";
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--text);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.nav-links a {
  display: inline-flex;
  align-items: center;
  padding: 8px 16px;
  border-radius: var(--r-2xl);
  color: var(--muted);
  text-decoration: none;
  font-weight: 500;
  font-size: 14px;
  transition: all var(--t2) var(--ease);
}

.nav-links a:hover {
  color: var(--text);
  background: var(--accent-soft);
}

.nav-links a:active { transform: scale(0.97); }

/* =========================================
   BUTTONS (Unified & Polished)
========================================= */
button, 
.theme-toggle, 
.primary, 
.ghost, 
.danger, 
.logout-button {
  font-family: var(--font-body);
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: var(--r-2xl);
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all var(--t2) var(--ease);
  will-change: transform, box-shadow;
  appearance: none;
  -webkit-appearance: none;
}

button:focus-visible, a:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}

/* Primary Button */
.primary {
  background: var(--text);
  color: var(--bg);
  box-shadow: var(--shadow-2);
}

.primary:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-3);
  opacity: 0.9;
}

.primary:active { transform: translateY(0) scale(0.98); }

/* Ghost / Secondary Buttons (.theme-toggle, .ghost, .logout-button) */
.theme-toggle, .ghost, .logout-button {
  border-color: var(--border);
  background: transparent;
  color: var(--text);
  box-shadow: var(--shadow-1);
}

.theme-toggle:hover, .ghost:hover, .logout-button:hover {
  background: var(--accent-soft);
  border-color: var(--border-strong);
  transform: translateY(-1px);
}

.theme-toggle:active, .ghost:active, .logout-button:active {
  transform: translateY(0) scale(0.98);
}

/* Danger Button */
.danger, .logout-button.danger, .danger.logout-button {
  border-color: rgba(239, 68, 68, 0.2) !important;
  background: var(--danger-bg) !important;
  color: var(--danger) !important;
  box-shadow: none;
}

.danger:hover, .logout-button.danger:hover, .danger.logout-button:hover {
  background: rgba(239, 68, 68, 0.15) !important;
  border-color: rgba(239, 68, 68, 0.3) !important;
  transform: translateY(-1px);
}

/* =========================================
   CARDS (Glassmorphism done right)
========================================= */
.card {
  position: relative;
  padding: 32px;
  border-radius: var(--r-xl);
  border: 1px solid var(--border);
  background: var(--panel);
  box-shadow: var(--shadow-3);
  backdrop-filter: blur(20px) saturate(140%);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  animation: fadeUp 0.5s var(--ease-out) both;
  transition: transform var(--t3) var(--ease), box-shadow var(--t3) var(--ease), border-color var(--t2) var(--ease);
}

.card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
}

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

/* =========================================
   FORMS & INPUTS
========================================= */
.form-card label, .card label {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
  font-weight: 500;
  font-size: 14px;
  color: var(--text);
}

input:not([type="checkbox"]), select, textarea {
  width: 100%;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.02);
  color: var(--text);
  padding: 12px 16px;
  font-size: 14px;
  font-family: inherit;
  transition: all var(--t2) var(--ease);
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.02);
}

body[data-theme="dark"] input:not([type="checkbox"]), 
body[data-theme="dark"] select, 
body[data-theme="dark"] textarea {
  background: rgba(255, 255, 255, 0.02);
}

textarea {
  min-height: 140px;
  resize: vertical;
  line-height: 1.5;
}

input::placeholder, textarea::placeholder {
  color: var(--muted);
}

input:not([type="checkbox"]):hover, select:hover, textarea:hover {
  border-color: var(--border-strong);
}

input:not([type="checkbox"]):focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--muted);
  box-shadow: var(--ring), inset 0 1px 2px rgba(0,0,0,0.02);
  background: transparent;
}

/* =========================================
   CHECKBOXES (Premium UI style)
========================================= */
input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  min-width: 20px;
  border-radius: var(--r-xs);
  border: 1px solid var(--border-strong);
  background: var(--panel-solid);
  display: inline-grid;
  place-items: center;
  cursor: pointer;
  transition: all var(--t2) var(--ease-bounce);
  box-shadow: var(--shadow-1);
}

input[type="checkbox"]::before {
  content: "";
  width: 10px;
  height: 10px;
  transform: scale(0);
  transform-origin: center;
  transition: transform 0.2s var(--ease-bounce);
  background-color: var(--bg);
  clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0%, 43% 62%);
}

input[type="checkbox"]:hover {
  border-color: var(--muted);
  transform: scale(1.05);
}

input[type="checkbox"]:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}

input[type="checkbox"]:checked {
  background: var(--text);
  border-color: var(--text);
}

input[type="checkbox"]:checked::before {
  transform: scale(1);
}

input[type="checkbox"]:active {
  transform: scale(0.92);
}

/* =========================================
   LISTS & TABLES
========================================= */
.table { display: grid; gap: 8px; }

.table-head, .table-row {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr 0.4fr 0.8fr;
  gap: 16px;
  align-items: center;
  padding: 16px 20px;
  border-radius: var(--r-md);
  border: 1px solid transparent;
  transition: all var(--t2) var(--ease);
}

.table-head {
  font-weight: 600;
  font-size: 13px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border2);
  border-radius: 0;
  padding-bottom: 12px;
}

.table-row {
  background: var(--panel2);
  border: 1px solid var(--border2);
}

.table-row:hover {
  transform: scale(1.01);
  background: var(--panel);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-2);
}

.build-list { display: grid; gap: 8px; }
.build-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 16px 0;
  border-bottom: 1px solid var(--border2);
}
.build-row:last-child { border-bottom: none; }

/* =========================================
   FLASH MESSAGES
========================================= */
.flash-stack {
  display: grid;
  gap: 12px;
  margin-bottom: 24px;
}

.flash {
  position: relative;
  padding: 16px 20px;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--panel);
  box-shadow: var(--shadow-2);
  display: flex;
  align-items: center;
  font-size: 14px;
  font-weight: 500;
  animation: fadeUp 0.4s var(--ease-out) both;
}

.flash::before {
  content: "";
  position: absolute;
  left: -1px;
  top: 50%;
  transform: translateY(-50%);
  height: calc(100% - 16px);
  width: 3px;
  border-radius: 0 4px 4px 0;
}

.flash-success::before { background: #10b981; }
.flash-warning::before { background: var(--warn); }
.flash-error::before { background: var(--danger); }
.flash-error { border-color: var(--danger-bg); }

/* =========================================
   SCRIPT OPTIONS (Interactive Cards)
========================================= */
.script-list { display: grid; gap: 12px; }
.script-item {
  padding-top: 16px;
  border-top: 1px solid var(--border2);
}

.script-option {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px;
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
  background: var(--panel2);
  cursor: pointer;
  user-select: none;
  transition: all var(--t3) var(--ease);
}

.script-option:hover {
  border-color: var(--border-strong);
  background: var(--panel);
  box-shadow: var(--shadow-2);
  transform: translateY(-2px);
}

.script-option:active { transform: scale(0.99); }

.script-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.script-title {
  font-weight: 600;
  color: var(--text);
  font-size: 15px;
}

.script-desc {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

/* Parent selection state (if supported) */
@supports selector(:has(*)) {
  .script-option:has(input[type="checkbox"]:checked) {
    border-color: var(--text);
    background: var(--accent-soft);
    box-shadow: var(--shadow-3);
  }
}

/* =========================================
   UTILITIES & FOOTER
========================================= */
.actions { display: flex; gap: 12px; flex-wrap: wrap; }
.search { display: flex; gap: 12px; margin-bottom: 20px; }
.inline-form { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 24px; }
.checkbox { display: flex; align-items: center; gap: 10px; font-weight: 500; font-size: 14px; }
.script-form { display: grid; gap: 16px; margin-bottom: 24px; }

.captcha {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 0;
}

.captcha-question {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 20px;
  color: var(--text);
}

.site-footer {
  padding: 32px 5vw;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  color: var(--muted);
  font-size: 13px;
  border-top: 1px solid var(--border);
}

/* =========================================
   RESPONSIVE
========================================= */
@media (max-width: 900px) {
  .site-header { flex-direction: column; align-items: flex-start; gap: 16px; }
  .table-head { display: none; }
  .table-row { grid-template-columns: 1fr; gap: 8px; padding: 16px; }
  .build-row { flex-direction: column; align-items: flex-start; }
  .site-footer { flex-direction: column; align-items: center; text-align: center; }
}

@media (max-width: 640px) {
  .card { padding: 24px; }
  .script-option { padding: 16px; }
  .actions { flex-direction: column; width: 100%; }
  .actions button, .actions a { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Utility helpers */
.hidden { display: none !important; }