/* ─── Variables ────────────────────────────────────────────── */
:root {
  --bg:           #0d0d1a;
  --surface:      #14142b;
  --surface2:     #1c1c38;
  --surface3:     #242448;
  --primary:      #7c3aed;
  --primary-light:#a855f7;
  --accent:       #ec4899;
  --accent-light: #f472b6;
  --green:        #10b981;
  --red:          #ef4444;
  --yellow:       #f59e0b;
  --text:         #f1f5f9;
  --text-muted:   #94a3b8;
  --text-dim:     #64748b;
  --border:       rgba(124,58,237,0.25);
  --border2:      rgba(255,255,255,0.07);
  --glow-purple:  rgba(124,58,237,0.4);
  --glow-pink:    rgba(236,72,153,0.4);
  --radius:       14px;
  --radius-sm:    8px;
  --transition:   0.25s ease;
}

/* ─── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; scroll-behavior: smooth; }

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

a { color: var(--primary-light); text-decoration: none; }
a:hover { color: var(--accent-light); }

img { max-width: 100%; display: block; }

/* ─── Scrollbar ────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--surface); }
::-webkit-scrollbar-thumb { background: var(--primary); border-radius: 99px; }

/* ─── Typography ───────────────────────────────────────────── */
h1, h2, h3, h4 { line-height: 1.3; font-weight: 700; }
h1 { font-size: clamp(1.75rem, 4vw, 2.5rem); }
h2 { font-size: clamp(1.3rem, 3vw, 1.8rem); }
h3 { font-size: 1.1rem; }

.gradient-text {
  background: linear-gradient(135deg, var(--primary-light), var(--accent-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ─── Layout ───────────────────────────────────────────────── */
.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
}

/* ─── Navbar ───────────────────────────────────────────────── */
.navbar {
  background: rgba(13,13,26,0.9);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 700;
  font-size: 1.1rem;
}

.navbar-brand .icon { font-size: 1.4rem; }

.navbar-user {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.875rem;
}

.badge-group {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  padding: 0.2rem 0.7rem;
  border-radius: 99px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.05em;
}

/* ─── Buttons ──────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.625rem 1.25rem;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  font-family: inherit;
  transition: all var(--transition);
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: white;
  box-shadow: 0 4px 15px var(--glow-purple);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 6px 20px var(--glow-purple); filter: brightness(1.1); }
.btn-primary:active { transform: translateY(0); }

.btn-secondary {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--surface3); border-color: var(--primary); }

.btn-outline {
  background: transparent;
  color: var(--primary-light);
  border: 1px solid var(--primary);
}
.btn-outline:hover { background: rgba(124,58,237,0.15); }

.btn-danger {
  background: rgba(239,68,68,0.15);
  color: var(--red);
  border: 1px solid rgba(239,68,68,0.35);
}
.btn-danger:hover { background: rgba(239,68,68,0.25); }

.btn-sm { padding: 0.4rem 0.85rem; font-size: 0.8rem; }
.btn-lg { padding: 0.875rem 1.75rem; font-size: 1rem; }
.btn-full { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }

/* ─── Cards ────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  padding: 1.5rem;
  transition: all var(--transition);
}

.card-glow:hover {
  border-color: var(--border);
  box-shadow: 0 0 24px var(--glow-purple);
  transform: translateY(-2px);
}

/* ─── Forms ────────────────────────────────────────────────── */
.form-group { margin-bottom: 1.25rem; }
.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.form-control {
  width: 100%;
  background: var(--surface2);
  border: 1.5px solid var(--border2);
  border-radius: var(--radius-sm);
  padding: 0.7rem 1rem;
  color: var(--text);
  font-size: 0.95rem;
  font-family: inherit;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(124,58,237,0.2);
}
.form-control::placeholder { color: var(--text-dim); }

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

select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2394a3b8' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.8rem center;
  padding-right: 2.2rem;
}
select.form-control option { background: var(--surface2); color: var(--text); }

/* ─── Dropzone ─────────────────────────────────────────────── */
.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 2.5rem;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  background: var(--surface);
}
.dropzone:hover, .dropzone.drag-over {
  border-color: var(--primary-light);
  background: rgba(124,58,237,0.08);
  box-shadow: 0 0 20px var(--glow-purple);
}
.dropzone input[type="file"] { display: none; }
.dropzone-icon { font-size: 2.5rem; margin-bottom: 0.75rem; }
.dropzone p { color: var(--text-muted); font-size: 0.9rem; }
.dropzone strong { color: var(--primary-light); }

/* ─── Progress bar ─────────────────────────────────────────── */
.progress-wrap {
  background: var(--surface2);
  border-radius: 99px;
  height: 8px;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  transition: width 0.4s ease;
}

/* ─── Status badges ────────────────────────────────────────── */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.7rem;
  border-radius: 99px;
  font-size: 0.75rem;
  font-weight: 600;
}
.status-complete { background: rgba(16,185,129,0.15); color: var(--green); border: 1px solid rgba(16,185,129,0.3); }
.status-partial  { background: rgba(245,158,11,0.15); color: var(--yellow); border: 1px solid rgba(245,158,11,0.3); }
.status-empty    { background: rgba(100,116,139,0.15); color: var(--text-dim); border: 1px solid rgba(100,116,139,0.3); }

/* ─── Alert ────────────────────────────────────────────────── */
.alert {
  padding: 0.875rem 1.2rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  margin-bottom: 1rem;
}
.alert-error  { background: rgba(239,68,68,0.1);  color: #fca5a5; border: 1px solid rgba(239,68,68,0.3); }
.alert-success{ background: rgba(16,185,129,0.1); color: #6ee7b7; border: 1px solid rgba(16,185,129,0.3); }
.alert-info   { background: rgba(59,130,246,0.1); color: #93c5fd; border: 1px solid rgba(59,130,246,0.3); }

/* ─── Plane grid ───────────────────────────────────────────── */
.planes-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
}

@media (max-width: 900px)  { .planes-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 640px)  { .planes-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 400px)  { .planes-grid { grid-template-columns: 1fr; } }

.plane-card {
  background: var(--surface);
  border: 1.5px solid var(--border2);
  border-radius: var(--radius);
  overflow: hidden;
  transition: all var(--transition);
  cursor: pointer;
  position: relative;
}
.plane-card:hover {
  border-color: var(--primary);
  box-shadow: 0 0 20px var(--glow-purple);
  transform: translateY(-3px);
}
.plane-card.has-file { border-color: rgba(124,58,237,0.5); }

.plane-number {
  position: absolute;
  top: 0.5rem;
  left: 0.5rem;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: white;
  font-size: 0.7rem;
  font-weight: 800;
  padding: 0.15rem 0.5rem;
  border-radius: 99px;
  z-index: 2;
  letter-spacing: 0.05em;
}

.plane-thumb {
  width: 100%;
  aspect-ratio: 16/9;
  object-fit: cover;
  background: var(--surface2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  color: var(--text-dim);
  position: relative;
}

.plane-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.plane-thumb .pdf-icon {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  font-size: 2rem;
  color: #ef4444;
}
.plane-thumb .pdf-icon small { font-size: 0.7rem; color: var(--text-muted); font-family: inherit; }

.plane-body {
  padding: 0.75rem;
}

.plane-type-tag {
  display: inline-block;
  background: rgba(124,58,237,0.2);
  color: var(--primary-light);
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: 99px;
  margin-bottom: 0.35rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.plane-desc {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.plane-empty-text {
  font-size: 0.8rem;
  color: var(--text-dim);
  text-align: center;
  padding: 1.5rem 0.5rem;
}
.plane-empty-text .add-icon { font-size: 1.5rem; margin-bottom: 0.3rem; display: block; }

/* ─── Save indicator ───────────────────────────────────────── */
.save-indicator {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  font-size: 0.7rem;
  z-index: 3;
  transition: all 0.3s;
}
.save-indicator.saving { color: var(--yellow); }
.save-indicator.saved  { color: var(--green); }
.save-indicator.error  { color: var(--red); }

/* ─── Modal ────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  transform: scale(0.95) translateY(10px);
  transition: transform 0.2s;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5), 0 0 40px var(--glow-purple);
}
.modal-overlay.open .modal { transform: scale(1) translateY(0); }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border2);
}
.modal-header h3 { font-size: 1rem; }
.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.25rem;
  padding: 0.25rem;
  line-height: 1;
  transition: color var(--transition);
}
.modal-close:hover { color: var(--accent-light); }

.modal-body { padding: 1.5rem; }
.modal-footer {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border2);
}

/* ─── Login page ───────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: radial-gradient(ellipse at 20% 50%, rgba(124,58,237,0.15) 0%, transparent 60%),
              radial-gradient(ellipse at 80% 20%, rgba(236,72,153,0.1) 0%, transparent 60%),
              var(--bg);
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.4), 0 0 40px var(--glow-purple);
}

.login-logo {
  text-align: center;
  margin-bottom: 2rem;
}

.login-logo .logo-icon {
  font-size: 3.5rem;
  display: block;
  margin-bottom: 0.75rem;
  filter: drop-shadow(0 0 12px var(--primary));
}

/* ─── Student header ───────────────────────────────────────── */
.student-header {
  background: linear-gradient(135deg, var(--surface2), var(--surface3));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  display: flex;
  align-items: center;
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

.student-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: 800;
  flex-shrink: 0;
  box-shadow: 0 0 16px var(--glow-purple);
}

.student-info h2 { font-size: 1.15rem; margin-bottom: 0.25rem; }
.student-info p  { font-size: 0.8rem; color: var(--text-muted); }

/* ─── Option cards ─────────────────────────────────────────── */
.option-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin: 1.5rem 0;
}

@media (max-width: 520px) { .option-cards { grid-template-columns: 1fr; } }

.option-card {
  background: var(--surface);
  border: 2px solid var(--border2);
  border-radius: var(--radius);
  padding: 1.75rem 1.25rem;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
}
.option-card:hover {
  border-color: var(--primary);
  background: rgba(124,58,237,0.07);
  box-shadow: 0 0 24px var(--glow-purple);
  transform: translateY(-3px);
}
.option-card.active {
  border-color: var(--accent);
  background: rgba(236,72,153,0.07);
  box-shadow: 0 0 24px var(--glow-pink);
}

.option-icon { font-size: 2.5rem; margin-bottom: 0.75rem; display: block; }
.option-card h3 { font-size: 0.95rem; margin-bottom: 0.4rem; }
.option-card p  { font-size: 0.78rem; color: var(--text-muted); line-height: 1.5; }

/* ─── Storyboard view ──────────────────────────────────────── */
.storyboard-header {
  background: linear-gradient(135deg, var(--surface2) 0%, var(--surface3) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  margin-bottom: 2rem;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.storyboard-header::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(124,58,237,0.08), rgba(236,72,153,0.05));
  pointer-events: none;
}

.storyboard-title {
  font-size: clamp(1.3rem, 4vw, 2rem);
  margin-bottom: 0.5rem;
}

.storyboard-meta {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  flex-wrap: wrap;
  margin-top: 1rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}
.storyboard-meta span { display: flex; align-items: center; gap: 0.35rem; }

/* ─── Admin table ──────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border2); }

table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
thead th {
  background: var(--surface2);
  padding: 0.875rem 1rem;
  text-align: left;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  white-space: nowrap;
}
tbody tr { border-bottom: 1px solid var(--border2); transition: background var(--transition); }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: rgba(124,58,237,0.05); }
tbody td { padding: 0.875rem 1rem; }

/* ─── Tabs (admin) ─────────────────────────────────────────── */
.group-tabs {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}
.group-tab {
  padding: 0.4rem 0.9rem;
  border-radius: 99px;
  border: 1px solid var(--border2);
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 600;
  transition: all var(--transition);
}
.group-tab:hover { border-color: var(--primary); color: var(--primary-light); }
.group-tab.active {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: white;
  border-color: transparent;
}

/* ─── Loading spinner ──────────────────────────────────────── */
.spinner {
  display: inline-block;
  width: 1.25rem;
  height: 1.25rem;
  border: 2px solid rgba(255,255,255,0.2);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.spinner-lg { width: 2.5rem; height: 2.5rem; border-width: 3px; }

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

.loading-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 1rem;
  color: var(--text-muted);
}

/* ─── Utilities ────────────────────────────────────────────── */
.text-center { text-align: center; }
.text-muted  { color: var(--text-muted); }
.text-sm     { font-size: 0.875rem; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 0.75rem; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.hidden { display: none !important; }

/* ─── Page fade-in ─────────────────────────────────────────── */
.page-content {
  padding: 2rem 1rem;
  animation: fadeIn 0.3s ease;
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ─── Print styles ─────────────────────────────────────────── */
@media print {
  .navbar, .btn, .modal-overlay, .no-print { display: none !important; }
  body { background: white; color: black; }
  .planes-grid { grid-template-columns: repeat(4, 1fr); gap: 0.5rem; }
  .plane-card { border: 1px solid #ccc; break-inside: avoid; }
  .storyboard-header { background: #f5f5f5; border: 1px solid #ddd; }
}

/* ─── Image preview in modal ───────────────────────────────── */
.img-preview-wrap {
  width: 100%;
  aspect-ratio: 16/9;
  background: var(--surface2);
  border-radius: var(--radius-sm);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1rem;
  font-size: 0.85rem;
  color: var(--text-dim);
}
.img-preview-wrap img { width: 100%; height: 100%; object-fit: contain; }

/* ─── Lightbox ─────────────────────────────────────────────── */
#lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.92);
  z-index: 300;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}
#lightbox.open { display: flex; }
#lightbox img { max-width: 100%; max-height: 90vh; border-radius: var(--radius); object-fit: contain; }
#lightbox-close {
  position: absolute;
  top: 1rem;
  right: 1.5rem;
  background: none;
  border: none;
  color: white;
  font-size: 2rem;
  cursor: pointer;
  opacity: 0.7;
}
#lightbox-close:hover { opacity: 1; }
