/* ════════════════════════════════════════════════
   FlashAI — Design System
   ════════════════════════════════════════════════ */

/* ── Reset & Base ── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  /* Colors */
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --primary-light: #818cf8;
  --primary-bg: #eef2ff;
  --success: #10b981;
  --success-bg: #d1fae5;
  --warning: #f59e0b;
  --warning-bg: #fef3c7;
  --error: #ef4444;
  --error-bg: #fee2e2;
  --info: #3b82f6;
  --info-bg: #dbeafe;

  /* Neutrals */
  --bg: #f8fafc;
  --bg-card: #ffffff;
  --bg-sidebar: #1e1b4b;
  --text: #1e293b;
  --text-light: #64748b;
  --text-muted: #94a3b8;
  --border: #e2e8f0;
  --border-focus: #6366f1;

  /* Spacing */
  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 16px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md:
    0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px rgba(0, 0, 0, 0.04);
  --shadow-lg:
    0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px rgba(0, 0, 0, 0.04);

  /* Typography */
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}
body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  min-height: 100vh;
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: color 0.2s;
}
a:hover {
  color: var(--primary-dark);
}

h1,
h2,
h3,
h4 {
  font-weight: 700;
  line-height: 1.3;
  color: var(--text);
}
h1 {
  font-size: 1.75rem;
}
h2 {
  font-size: 1.375rem;
}
h3 {
  font-size: 1.125rem;
}

img {
  max-width: 100%;
}

/* ── Container ── */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem;
}

/* ── Navbar ── */
.navbar {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}
.navbar-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
}
.navbar-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--text);
}
.brand-icon {
  font-size: 1.5rem;
}
.navbar-links {
  display: flex;
  gap: 0.25rem;
}
.nav-link {
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  color: var(--text-light);
  font-size: 0.875rem;
  font-weight: 500;
  transition:
    background 0.2s,
    color 0.2s;
}
.nav-link:hover {
  background: var(--primary-bg);
  color: var(--primary);
}
.nav-link--admin {
  color: var(--primary);
}
.navbar-user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.user-greeting {
  font-size: 0.875rem;
  color: var(--text-light);
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.625rem 1.25rem;
  font-family: var(--font);
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: 2px solid transparent;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  line-height: 1.4;
}
.btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}
.btn:active {
  transform: translateY(0);
}

.btn--primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.btn--primary:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
  color: #fff;
}

.btn--success {
  background: var(--success);
  color: #fff;
}
.btn--success:hover {
  background: #059669;
  color: #fff;
}

.btn--danger {
  background: var(--error);
  color: #fff;
}
.btn--danger:hover {
  background: #dc2626;
  color: #fff;
}

.btn--warning {
  background: var(--warning);
  color: #fff;
}

.btn--outline {
  background: transparent;
  color: var(--text-light);
  border-color: var(--border);
}
.btn--outline:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-bg);
}

.btn--sm {
  padding: 0.375rem 0.75rem;
  font-size: 0.8125rem;
}
.btn--full {
  width: 100%;
}
.btn--icon {
  padding: 0.5rem;
}

/* ── Forms ── */
.form-group {
  margin-bottom: 1rem;
}
.form-label {
  display: block;
  margin-bottom: 0.375rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
}
.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 0.625rem 0.875rem;
  font-family: var(--font);
  font-size: 0.9375rem;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text);
  transition:
    border-color 0.2s,
    box-shadow 0.2s;
}
.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}
.form-input::placeholder {
  color: var(--text-muted);
}
.form-textarea {
  min-height: 100px;
  resize: vertical;
}

/* ── Cards ── */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  transition: box-shadow 0.2s;
}
.card:hover {
  box-shadow: var(--shadow-md);
}
.card-header {
  margin-bottom: 1rem;
}
.card-title {
  font-size: 1.125rem;
  font-weight: 700;
}
.card-footer {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

/* ── Stats Grid ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 1.25rem;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 1rem;
}
.stat-icon {
  font-size: 2rem;
}
.stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.2;
}
.stat-label {
  font-size: 0.8125rem;
  color: var(--text-light);
}

/* ── Category Grid ── */
.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem;
}
.category-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  transition: all 0.2s;
  cursor: pointer;
}
.category-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.category-icon {
  font-size: 2.25rem;
}
.category-name {
  font-weight: 600;
  font-size: 1rem;
}
.category-count {
  font-size: 0.8125rem;
  color: var(--text-light);
}

/* ── Tables ── */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}
th,
td {
  padding: 0.75rem 1rem;
  text-align: left;
}
th {
  background: #f1f5f9;
  font-weight: 600;
  font-size: 0.8125rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-light);
  border-bottom: 2px solid var(--border);
}
tr {
  border-bottom: 1px solid var(--border);
}
tr:last-child {
  border-bottom: none;
}
tr:hover td {
  background: #f8fafc;
}

/* ── Badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.625rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 9999px;
  line-height: 1;
}
.badge--success {
  background: var(--success-bg);
  color: #065f46;
}
.badge--warning {
  background: var(--warning-bg);
  color: #92400e;
}
.badge--error {
  background: var(--error-bg);
  color: #991b1b;
}
.badge--info {
  background: var(--info-bg);
  color: #1e40af;
}
.badge--neutral {
  background: #f1f5f9;
  color: var(--text-light);
}

/* ── Flash Messages ── */
.flash {
  padding: 0.875rem 1.25rem;
  border-radius: var(--radius-sm);
  margin: 1rem 1.5rem;
  font-weight: 500;
  font-size: 0.9375rem;
  animation: flashIn 0.3s ease;
  transition: opacity 0.5s;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.flash-close {
  background: none;
  border: none;
  font-size: 1.25rem;
  line-height: 1;
  color: inherit;
  opacity: 0.6;
  cursor: pointer;
  padding: 0 0 0 1rem;
}
.flash-close:hover {
  opacity: 1;
}
.flash--success {
  background: var(--success-bg);
  color: #065f46;
  border-left: 4px solid var(--success);
}
.flash--error {
  background: var(--error-bg);
  color: #991b1b;
  border-left: 4px solid var(--error);
}
.flash--warning {
  background: var(--warning-bg);
  color: #92400e;
  border-left: 4px solid var(--warning);
}
@keyframes flashIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ── Login Page ── */
.login-body {
  background: linear-gradient(135deg, #1e1b4b 0%, #312e81 50%, #4338ca 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}
.login-container {
  width: 100%;
  max-width: 420px;
  padding: 1rem;
}
.login-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 2.5rem;
  box-shadow: var(--shadow-lg);
}
.login-header {
  text-align: center;
  margin-bottom: 2rem;
}
.login-icon {
  font-size: 3rem;
  display: block;
  margin-bottom: 0.5rem;
}
.login-header h1 {
  font-size: 1.75rem;
  margin-bottom: 0.25rem;
}
.login-subtitle {
  color: var(--text-light);
  font-size: 0.9375rem;
}
.login-form .btn {
  margin-top: 0.5rem;
}

/* ── Admin Layout ── */
.admin-body {
  overflow: hidden;
}
.admin-layout {
  display: flex;
  height: 100vh;
}

.sidebar {
  width: 240px;
  min-width: 240px;
  background: var(--bg-sidebar);
  color: #c7d2fe;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}
.sidebar-brand {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.sidebar-brand a {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: #fff;
  font-weight: 700;
  font-size: 1.125rem;
}
.sidebar-nav {
  flex: 1;
  padding: 0.75rem 0;
}
.sidebar-link {
  display: block;
  padding: 0.625rem 1.5rem;
  color: #c7d2fe;
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.2s;
  border-left: 3px solid transparent;
}
.sidebar-link:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  border-left-color: var(--primary-light);
}
.sidebar-link--logout {
  color: #fca5a5;
}
.sidebar-link--logout:hover {
  color: #fecaca;
  background: rgba(239, 68, 68, 0.1);
}
.sidebar-divider {
  border: none;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  margin: 0.5rem 0;
}
.sidebar-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.8125rem;
}
.user-name {
  display: block;
  font-weight: 600;
  color: #e0e7ff;
  margin-bottom: 0.5rem;
}

.admin-main {
  flex: 1;
  overflow-y: auto;
  background: var(--bg);
}
.admin-topbar {
  padding: 1.25rem 2rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
}
.admin-page-title {
  font-size: 1.375rem;
}
.admin-content {
  padding: 1.5rem 2rem;
}

/* ── Progress Bar ── */
.progress-bar {
  background: #e2e8f0;
  border-radius: 9999px;
  height: 8px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: 9999px;
  background: linear-gradient(90deg, var(--primary), var(--primary-light));
  transition: width 0.6s ease;
  min-width: 0;
}

/* ── Card variants ── */
.card--hover {
  transition: all 0.2s;
  cursor: pointer;
}
.card--hover:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

/* ── Grids ── */
.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}
.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
}

/* ── Breadcrumbs ── */
.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: var(--text-light);
  margin-bottom: 1rem;
}
.breadcrumbs a {
  color: var(--text-light);
}
.breadcrumbs a:hover {
  color: var(--primary);
}
.breadcrumbs .sep {
  color: var(--border);
}

/* ── Tooltips (CSS-only) ── */
[data-tooltip] {
  position: relative;
  cursor: help;
}
[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(-4px);
  background: var(--text);
  color: #fff;
  padding: 0.375rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  z-index: 50;
}
[data-tooltip]:hover::after {
  opacity: 1;
}

/* ── Sidebar active ── */
.sidebar-link--active {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border-left-color: var(--primary-light);
  font-weight: 700;
}

/* ── Hamburger nav (mobile) ── */
.hamburger {
  display: none;
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.25rem;
  color: var(--text);
}

/* ── Drag & Drop Zone ── */
.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 3rem 2rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--bg);
}
.dropzone:hover,
.dropzone--active {
  border-color: var(--primary);
  background: var(--primary-bg);
}
.dropzone-icon {
  font-size: 3rem;
  margin-bottom: 0.5rem;
}
.dropzone-text {
  color: var(--text-light);
  font-size: 0.9375rem;
}
.dropzone-hint {
  color: var(--text-muted);
  font-size: 0.8125rem;
  margin-top: 0.25rem;
}

/* ── Footer ── */
.footer {
  text-align: center;
  padding: 1.5rem;
  color: var(--text-muted);
  font-size: 0.8125rem;
  border-top: 1px solid var(--border);
  margin-top: 2rem;
}

/* ── Utilities ── */
.text-center {
  text-align: center;
}
.text-right {
  text-align: right;
}
.text-muted {
  color: var(--text-light);
}
.text-primary {
  color: var(--primary);
}
.text-sm {
  font-size: 0.875rem;
}
.mt-1 {
  margin-top: 0.5rem;
}
.mt-2 {
  margin-top: 1rem;
}
.mt-3 {
  margin-top: 1.5rem;
}
.mb-1 {
  margin-bottom: 0.5rem;
}
.mb-2 {
  margin-bottom: 1rem;
}
.mb-3 {
  margin-bottom: 1.5rem;
}
.gap-0 {
  gap: 0;
}
.gap-1 {
  gap: 0.5rem;
}
.gap-2 {
  gap: 1rem;
}
.flex {
  display: flex;
}
.flex-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.flex-center {
  display: flex;
  align-items: center;
}
.flex-wrap {
  flex-wrap: wrap;
}
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .navbar-inner {
    flex-wrap: wrap;
    height: auto;
    padding: 0.75rem 0;
    gap: 0.5rem;
  }
  .navbar-links {
    display: none;
  }
  .navbar-links--open {
    display: flex;
    width: 100%;
    justify-content: center;
  }
  .hamburger {
    display: block;
  }
  .sidebar {
    position: fixed;
    left: -260px;
    top: 0;
    height: 100vh;
    z-index: 200;
    transition: left 0.3s;
  }
  .sidebar--open {
    left: 0;
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.3);
  }
  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 199;
  }
  .sidebar-overlay--visible {
    display: block;
  }
  .admin-content {
    padding: 1rem;
  }
  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }
  .grid-2 {
    grid-template-columns: 1fr;
  }
  .grid-3 {
    grid-template-columns: 1fr;
  }
  .grid-4 {
    grid-template-columns: 1fr 1fr;
  }
  .category-grid {
    grid-template-columns: 1fr;
  }
  .table-wrap {
    font-size: 0.8125rem;
  }
}

@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }
  .grid-4 {
    grid-template-columns: 1fr;
  }
}
