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

/* ===== DESIGN TOKENS ===== */
:root {
  --bg-deep: #0B1020;
  --bg-primary: #0F172A;
  --bg-surface: #1E293B;
  --bg-surface-hover: #334155;
  --bg-elevated: #1A2332;
  --accent: #3B82F6;
  --accent-hover: #2563EB;
  --accent-subtle: rgba(59, 130, 246, 0.12);
  --accent-ring: rgba(59, 130, 246, 0.35);
  --success: #22C55E;
  --success-subtle: rgba(34, 197, 94, 0.12);
  --warning: #F59E0B;
  --danger: #EF4444;
  --danger-subtle: rgba(239, 68, 68, 0.1);
  --danger-border: rgba(239, 68, 68, 0.25);
  --text-primary: #F8FAFC;
  --text-secondary: #94A3B8;
  --text-muted: #64748B;
  --text-faint: #475569;
  --border: rgba(255, 255, 255, 0.08);
  --border-input: rgba(255, 255, 255, 0.12);
  --radius: 16px;
  --radius-sm: 10px;
  --radius-xs: 6px;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.25);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.35);
  --transition: all 200ms ease;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 24px; border: none; border-radius: var(--radius-sm);
  font-family: inherit; font-size: 14px; font-weight: 600;
  cursor: pointer; transition: var(--transition);
  text-decoration: none; line-height: 1;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary {
  background: var(--accent);
  color: white;
}
.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}
.btn-primary:active { transform: translateY(0); }
.btn-secondary {
  background: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--bg-surface-hover); }
.btn-danger {
  background: var(--danger);
  color: white;
}
.btn-danger:hover { background: #DC2626; }
.btn-sm { padding: 8px 14px; font-size: 13px; border-radius: var(--radius-xs); }
.btn-block { width: 100%; }
.btn-lg { padding: 16px 32px; font-size: 15px; height: 52px; }

/* ===== LOGIN — SPLIT SCREEN ===== */
.login-split {
  display: flex; min-height: 100vh;
}

/* Left brand panel */
.login-brand {
  flex: 0 0 42%; display: flex; flex-direction: column;
  justify-content: center; padding: 64px;
  background: var(--bg-deep);
  position: relative; overflow: hidden;
}
.login-brand::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; bottom: 0;
  background:
    radial-gradient(circle at 20% 30%, rgba(59, 130, 246, 0.06) 0%, transparent 60%),
    radial-gradient(circle at 80% 70%, rgba(34, 197, 94, 0.04) 0%, transparent 50%);
  pointer-events: none;
}
.login-brand::after {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; bottom: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.02) 1px, transparent 1px);
  background-size: 48px 48px;
  pointer-events: none;
}
.brand-content {
  position: relative; z-index: 2;
}
.brand-logo {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 48px;
}
.brand-logo-icon {
  width: 40px; height: 40px;
  background: var(--accent);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; color: white; font-weight: 800;
}
.brand-logo-text {
  font-size: 18px; font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.3px;
}
.brand-headline {
  font-size: 32px; font-weight: 800;
  line-height: 1.25; letter-spacing: -0.5px;
  color: var(--text-primary);
  margin-bottom: 16px;
}
.brand-desc {
  font-size: 15px; line-height: 1.7;
  color: var(--text-secondary);
  margin-bottom: 40px;
  max-width: 380px;
}
.brand-features {
  list-style: none; display: flex; flex-direction: column; gap: 16px;
}
.brand-features li {
  display: flex; align-items: center; gap: 12px;
  font-size: 14px; color: var(--text-secondary);
}
.brand-features li::before {
  content: '';
  width: 6px; height: 6px;
  background: var(--accent);
  border-radius: 50%;
  flex-shrink: 0;
}
.brand-footer {
  position: absolute; bottom: 32px; left: 64px;
  font-size: 12px; color: var(--text-faint);
  z-index: 2;
}

/* Right form panel */
.login-form-panel {
  flex: 1; display: flex; align-items: center; justify-content: center;
  padding: 48px;
  background: var(--bg-primary);
}
.login-form-wrap {
  width: 100%; max-width: 440px;
  animation: formEnter 500ms ease;
}
@keyframes formEnter {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
.login-heading {
  font-size: 24px; font-weight: 700;
  letter-spacing: -0.3px;
  margin-bottom: 8px;
}
.login-subtext {
  font-size: 14px; color: var(--text-secondary);
  margin-bottom: 36px; line-height: 1.5;
}

/* Form fields */
.form-group { margin-bottom: 20px; }
.form-label {
  display: block; font-size: 13px; font-weight: 500;
  color: var(--text-secondary); margin-bottom: 8px;
}
.form-input {
  width: 100%; height: 52px; padding: 0 16px;
  background: var(--bg-deep);
  border: 1px solid var(--border-input);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit; font-size: 15px;
  transition: var(--transition);
  outline: none;
}
.form-input:hover { border-color: rgba(255, 255, 255, 0.18); }
.form-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}
.form-input::placeholder { color: var(--text-faint); }

/* Error alert */
.alert-error {
  display: none; align-items: center; gap: 10px;
  padding: 14px 16px; margin-top: 20px;
  background: var(--danger-subtle);
  border: 1px solid var(--danger-border);
  border-radius: var(--radius-sm);
  color: #FCA5A5;
  font-size: 13px; line-height: 1.5;
}
.alert-error.visible { display: flex; }
.alert-error-icon {
  flex-shrink: 0; width: 18px; height: 18px;
  background: var(--danger);
  color: white; font-size: 11px; font-weight: 800;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}

/* ===== NAV BAR ===== */
.navbar {
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center; justify-content: space-between;
  height: 60px; padding: 0 32px;
  background: rgba(15, 23, 42, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.nav-brand {
  display: flex; align-items: center; gap: 10px;
  font-size: 15px; font-weight: 700;
  color: var(--text-primary);
}
.nav-brand-icon {
  width: 30px; height: 30px;
  background: var(--accent);
  border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; color: white; font-weight: 800;
}
.nav-center {
  display: flex; gap: 4px;
}
.nav-tab {
  padding: 8px 16px; border-radius: var(--radius-xs);
  font-size: 13px; font-weight: 500;
  color: var(--text-muted);
  background: transparent; border: none;
  cursor: pointer; transition: var(--transition);
  text-decoration: none; font-family: inherit;
}
.nav-tab:hover { color: var(--text-secondary); background: var(--bg-surface); }
.nav-tab.active { color: var(--text-primary); background: var(--bg-surface); }
.nav-right {
  display: flex; align-items: center; gap: 16px;
}
.nav-user-info {
  text-align: right;
}
.nav-username {
  font-size: 13px; font-weight: 500; color: var(--text-primary);
}
.nav-role {
  display: block; font-size: 11px; color: var(--text-muted);
}

/* ===== GALLERY ===== */
.gallery-container { padding: 32px; max-width: 1400px; margin: 0 auto; }
.course-section { margin-bottom: 48px; }
.course-header {
  display: flex; align-items: center; gap: 16px;
  margin-bottom: 16px; padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.course-dot {
  width: 8px; height: 8px; border-radius: 50%;
  flex-shrink: 0;
}
.course-title {
  font-size: 16px; font-weight: 700;
  letter-spacing: -0.2px;
}
.course-level {
  font-size: 12px; color: var(--text-muted);
  background: var(--bg-surface);
  padding: 4px 10px; border-radius: 20px;
}
.course-progress-bar {
  flex: 1; max-width: 160px; height: 4px;
  background: var(--bg-surface);
  border-radius: 2px; overflow: hidden;
  margin-left: auto;
}
.course-progress-fill {
  height: 100%; border-radius: 2px;
  background: var(--accent);
  transition: width 0.4s ease;
}
.course-progress-text {
  font-size: 12px; color: var(--text-muted); font-weight: 500;
  min-width: 70px; text-align: right;
}

.slides-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}
.slide-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  transition: var(--transition);
  cursor: pointer;
  position: relative;
}
.slide-card:hover {
  border-color: rgba(59, 130, 246, 0.3);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.slide-card.viewed { border-color: rgba(34, 197, 94, 0.25); }
.slide-card.viewed .slide-check { display: flex; }
.slide-check {
  display: none; position: absolute; top: 8px; right: 8px;
  width: 22px; height: 22px;
  background: var(--success);
  color: white; font-size: 12px; font-weight: 700;
  border-radius: 50%;
  align-items: center; justify-content: center;
  z-index: 2;
}
.slide-thumb {
  width: 100%; height: 120px;
  object-fit: cover;
  background: var(--bg-elevated);
  display: block;
}
.slide-info { padding: 10px 12px; }
.slide-name {
  font-size: 12px; font-weight: 600;
  margin-bottom: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.slide-unit {
  font-size: 11px; color: var(--text-muted);
}

/* ===== SLIDE VIEWER ===== */
.viewer-container {
  position: fixed; top: 0; left: 0;
  width: 100%; height: 100%;
  background: #000;
  z-index: 1000;
  display: flex; flex-direction: column;
}
.viewer-header {
  display: flex; align-items: center; justify-content: space-between;
  height: 48px; padding: 0 20px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
}
.viewer-title { font-size: 13px; font-weight: 500; color: var(--text-secondary); }
.viewer-close {
  background: transparent; color: var(--text-secondary);
  border: 1px solid var(--border);
  padding: 6px 14px; border-radius: var(--radius-xs);
  cursor: pointer; font-family: inherit; font-size: 13px; font-weight: 500;
  transition: var(--transition);
}
.viewer-close:hover { background: var(--danger); color: white; border-color: var(--danger); }
.viewer-iframe { flex: 1; border: none; width: 100%; height: 100%; }

/* ===== ADMIN ===== */
.admin-container { padding: 32px; max-width: 1200px; margin: 0 auto; }
.admin-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 28px;
}
.admin-title { font-size: 20px; font-weight: 700; letter-spacing: -0.3px; }
.admin-stats {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px; margin-bottom: 28px;
}
.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 20px;
}
.stat-value {
  font-size: 28px; font-weight: 800;
  color: var(--text-primary);
}
.stat-label { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

.admin-table-wrap {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.admin-table { width: 100%; border-collapse: collapse; }
.admin-table th, .admin-table td {
  padding: 12px 16px; text-align: left;
  border-bottom: 1px solid var(--border);
}
.admin-table th {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.5px; color: var(--text-faint);
  background: var(--bg-elevated);
}
.admin-table td { font-size: 13px; }
.admin-table tbody tr:hover td { background: rgba(255,255,255,0.02); }

.badge {
  display: inline-block; padding: 3px 8px;
  border-radius: 4px; font-size: 11px; font-weight: 600;
}
.badge-active { background: var(--success-subtle); color: var(--success); }
.badge-inactive { background: var(--danger-subtle); color: #FCA5A5; }
.badge-admin { background: var(--accent-subtle); color: var(--accent); }
.badge-student { background: rgba(100,116,139,0.12); color: var(--text-muted); }
.badge-online { background: var(--success-subtle); color: var(--success); }
.badge-offline { background: rgba(100,116,139,0.1); color: var(--text-faint); }

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed; top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0,0,0,0.6);
  z-index: 500;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.modal {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  width: 100%; max-width: 440px;
  box-shadow: var(--shadow-lg);
  animation: formEnter 250ms ease;
}
.modal h2 { font-size: 18px; font-weight: 700; margin-bottom: 20px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }

/* ===== SESSION KICKED ===== */
.kicked-overlay {
  position: fixed; top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0,0,0,0.92);
  z-index: 9999;
  display: flex; align-items: center; justify-content: center;
}
.kicked-card {
  background: var(--bg-surface);
  border: 1px solid var(--danger-border);
  border-radius: var(--radius);
  padding: 40px; text-align: center;
  max-width: 400px;
  animation: formEnter 400ms ease;
}
.kicked-icon {
  width: 56px; height: 56px; margin: 0 auto 20px;
  background: var(--danger-subtle);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px;
}
.kicked-title { font-size: 18px; font-weight: 700; margin-bottom: 8px; }
.kicked-msg { color: var(--text-secondary); font-size: 14px; margin-bottom: 24px; line-height: 1.6; }

/* ===== LOADING ===== */
.spinner {
  width: 32px; height: 32px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 48px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-surface-hover); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-faint); }

/* ===== RESPONSIVE ===== */
@media (max-width: 900px) {
  .login-split { flex-direction: column; }
  .login-brand {
    flex: none; padding: 32px 24px;
    min-height: auto;
  }
  .brand-headline { font-size: 24px; }
  .brand-features { display: none; }
  .login-form-panel { padding: 32px 24px; }
  .navbar { padding: 0 16px; }
  .gallery-container { padding: 16px; }
  .slides-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
  .admin-container { padding: 16px; }
}
@media (max-width: 480px) {
  .login-brand { padding: 24px 20px; }
  .login-form-panel { padding: 24px 20px; }
  .course-header { flex-wrap: wrap; }
}
