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

:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface-2: #22263a;
  --border: #2e3250;
  --text: #e8eaf6;
  --text-muted: #8b90b8;
  --accent: #7c6ff7;
  --accent-hover: #9d97ff;
  --danger: #e05a6a;
  --danger-hover: #f07080;
  --success: #56c489;
  --warning: #f0b429;
  --radius: 8px;
}

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

body {
  font-family:
    "Inter",
    system-ui,
    -apple-system,
    sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}

/* ─── Nav ──────────────────────────────────────────────── */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 100;
}

nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 3.5rem;
  max-width: 1100px;
  margin: 0 auto;
}

.brand {
  color: var(--accent-hover);
  font-weight: 700;
  text-decoration: none;
  font-size: 1.1rem;
  letter-spacing: -0.02em;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.nav-links a {
  color: var(--text-muted);
  text-decoration: none;
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  transition:
    color 0.15s,
    background 0.15s;
}

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

/* Dropdown */
.nav-dropdown {
  position: relative;
}

.nav-dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 0.5rem);
  left: 0;
  min-width: 160px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  z-index: 200;
}

.nav-dropdown:hover .nav-dropdown-menu,
.nav-dropdown.open .nav-dropdown-menu {
  display: block;
}

.nav-dropdown-menu a {
  display: block;
  padding: 0.55rem 1rem;
  border-radius: 0;
}

/* Hamburger */
.hamburger {
  display: none;
  flex-direction: column;
  gap: 5px;
  cursor: pointer;
  padding: 0.5rem;
  background: none;
  border: none;
}

.hamburger span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text-muted);
  border-radius: 2px;
  transition:
    transform 0.2s,
    opacity 0.2s;
}

/* ─── Main layout ──────────────────────────────────────── */
main {
  max-width: 800px;
  margin: 2rem auto;
  padding: 0 1rem;
}

/* ─── Alerts ───────────────────────────────────────────── */
.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: 0.875rem;
  font-weight: 500;
}

.alert-success {
  background: rgba(86, 196, 137, 0.15);
  color: var(--success);
  border: 1px solid rgba(86, 196, 137, 0.3);
}

.alert-error {
  background: rgba(224, 90, 106, 0.15);
  color: var(--danger);
  border: 1px solid rgba(224, 90, 106, 0.3);
}

/* ─── Card ─────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2rem;
}

.card h1 {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
  letter-spacing: -0.02em;
}

.card h2 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

/* ─── Forms ────────────────────────────────────────────── */
form label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.35rem;
  margin-top: 1.1rem;
}

form input,
form select,
form textarea {
  width: 100%;
  padding: 0.6rem 0.85rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-family: inherit;
  color: var(--text);
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
}

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

form select option {
  background: var(--surface-2);
}

form input:focus,
form select:focus,
form textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(124, 111, 247, 0.25);
}

/* ─── Buttons ──────────────────────────────────────────── */
.btn,
button[type="submit"] {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 1.25rem;
  padding: 0.6rem 1.4rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  transition:
    background 0.15s,
    transform 0.1s;
}

.btn:hover,
button[type="submit"]:hover {
  background: var(--accent-hover);
}

.btn:active,
button[type="submit"]:active {
  transform: scale(0.98);
}

.btn-danger {
  background: var(--danger);
}

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

.btn-sm {
  padding: 0.3rem 0.75rem;
  font-size: 0.8rem;
  margin-top: 0;
}

/* ─── Tabs ─────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0;
}

.tab-btn {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 0.5rem 1rem;
  margin-bottom: -1px;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  margin-top: 0;
  transition:
    color 0.15s,
    border-color 0.15s;
}

.tab-btn:hover {
  color: var(--text);
}

.tab-btn.active {
  color: var(--accent-hover);
  border-bottom-color: var(--accent);
}

.tab-panel {
  display: none;
}
.tab-panel.active {
  display: block;
}

/* ─── Result ───────────────────────────────────────────── */
.result {
  margin-top: 1.75rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.result h2 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.75rem;
}

pre {
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 1rem;
  border-radius: var(--radius);
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.9rem;
  line-height: 1.7;
  color: var(--text);
}

.generated-image {
  max-width: 100%;
  border-radius: var(--radius);
  margin-top: 0.5rem;
  border: 1px solid var(--border);
}

.generated-video {
  max-width: 100%;
  border-radius: var(--radius);
  margin-top: 0.5rem;
}

/* ─── Admin table ──────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-box {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
}

.stat-box .stat-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.stat-box .stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent-hover);
  line-height: 1.2;
  margin-top: 0.25rem;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th {
  text-align: left;
  padding: 0.5rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

td {
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tr:last-child td {
  border-bottom: none;
}

.role-badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.role-admin {
  background: rgba(124, 111, 247, 0.2);
  color: var(--accent-hover);
}

.role-user {
  background: rgba(139, 144, 184, 0.15);
  color: var(--text-muted);
}

.table-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}

/* ─── Loading overlay ──────────────────────────────────── */
#loading-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 17, 23, 0.75);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 1rem;
}

#loading-overlay.active {
  display: flex;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.spinner-label {
  color: var(--text-muted);
  font-size: 0.9rem;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ─── Misc ─────────────────────────────────────────────── */
.text-muted {
  color: var(--text-muted);
}
.mt-1 {
  margin-top: 0.5rem;
}
.mt-2 {
  margin-top: 1rem;
}
.section-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 1rem;
}

/* ─── Responsive ───────────────────────────────────────── */
@media (max-width: 640px) {
  .hamburger {
    display: flex;
  }

  .nav-links {
    display: none;
    flex-direction: column;
    align-items: flex-start;
    position: absolute;
    top: 3.5rem;
    left: 0;
    right: 0;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0.75rem 1rem;
    gap: 0.1rem;
    z-index: 99;
  }

  .nav-links.open {
    display: flex;
  }

  .nav-dropdown-menu {
    position: static;
    border: none;
    background: none;
    padding-left: 0.75rem;
  }

  .card {
    padding: 1.25rem;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 3.5rem;
}
.brand {
  color: #e0e0ff;
  font-weight: 700;
  text-decoration: none;
  font-size: 1.1rem;
}
.nav-links a {
  color: #c0c0dd;
  text-decoration: none;
  margin-left: 1.25rem;
  font-size: 0.9rem;
}
.nav-links a:hover {
  color: #fff;
}

/* Main */
main {
  max-width: 640px;
  margin: 2rem auto;
  padding: 0 1rem;
}

/* Alerts */
.alert {
  padding: 0.75rem 1rem;
  border-radius: 6px;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}
.alert-success {
  background: #d4edda;
  color: #155724;
}
.alert-error {
  background: #f8d7da;
  color: #721c24;
}

/* Card */
.card {
  background: #fff;
  border-radius: 10px;
  padding: 2rem;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}
.card h1 {
  font-size: 1.5rem;
  margin-bottom: 1.5rem;
}

/* Forms */
form label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.3rem;
  margin-top: 1rem;
}
form input,
form select,
form textarea {
  width: 100%;
  padding: 0.55rem 0.75rem;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 0.95rem;
  font-family: inherit;
}
form input:focus,
form select:focus,
form textarea:focus {
  outline: none;
  border-color: #5c6bc0;
  box-shadow: 0 0 0 2px rgba(92, 107, 192, 0.2);
}
button[type="submit"],
.btn {
  display: inline-block;
  margin-top: 1.25rem;
  padding: 0.6rem 1.4rem;
  background: #5c6bc0;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 0.95rem;
  cursor: pointer;
  text-decoration: none;
}
button[type="submit"]:hover,
.btn:hover {
  background: #3f51b5;
}

/* Result */
.result {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid #eee;
}
.result h2 {
  margin-bottom: 0.75rem;
  font-size: 1.1rem;
}
pre {
  background: #f0f0f0;
  padding: 1rem;
  border-radius: 6px;
  white-space: pre-wrap;
  word-break: break-word;
}
.generated-image {
  max-width: 100%;
  border-radius: 8px;
  margin-top: 0.5rem;
}
.generated-video {
  max-width: 100%;
  border-radius: 8px;
  margin-top: 0.5rem;
}
