:root {
  --bg: #0f172a;
  --bg2: #1e293b;
  --card: #1e293b;
  --card-hover: #334155;
  --border: #334155;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --primary: #6366f1;
  --primary-hover: #818cf8;
  --success: #22c55e;
  --danger: #ef4444;
  --warning: #f59e0b;
  --radius: 12px;
  --shadow: 0 4px 24px rgba(0,0,0,0.3);
}

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

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

/* ===== LOGIN ===== */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at top, #1e1b4b 0%, #0f172a 60%);
  padding: 20px;
}
.login-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 48px 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow);
}
.login-card h1 {
  text-align: center;
  font-size: 1.9rem;
  margin-bottom: 6px;
  background: linear-gradient(135deg, #818cf8, #c084fc);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.login-card .subtitle {
  text-align: center;
  color: var(--muted);
  margin-bottom: 32px;
  font-size: 0.95rem;
}
.form-group { margin-bottom: 18px; }
.form-group label {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
  font-size: 0.85rem;
  color: var(--muted);
}
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: 0.95rem;
  color: var(--text);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.25);
}
.form-group input::placeholder,
.form-group textarea::placeholder { color: #475569; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 11px 20px;
  border: none;
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-primary {
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: white;
  width: 100%;
}
.btn-primary:hover { filter: brightness(1.15); transform: translateY(-1px); }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { filter: brightness(1.1); }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { filter: brightness(1.1); }
.btn-warning { background: var(--warning); color: #1e293b; }
.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn-outline {
  background: transparent;
  border: 1.5px solid var(--border);
  color: var(--text);
}
.btn-outline:hover { background: var(--card-hover); }
.error-msg {
  background: rgba(239,68,68,0.15);
  color: #fca5a5;
  padding: 12px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 0.9rem;
  display: none;
  border: 1px solid rgba(239,68,68,0.3);
}

/* ===== LAYOUT ===== */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 260px;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 50;
}
.sidebar .brand {
  padding: 24px 20px;
  font-size: 1.25rem;
  font-weight: 700;
  background: linear-gradient(135deg, #818cf8, #c084fc);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  border-bottom: 1px solid var(--border);
}
.sidebar nav { flex: 1; padding: 16px 12px; overflow-y: auto; }
.sidebar .nav-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px 14px;
  border: none;
  background: transparent;
  color: var(--muted);
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  margin-bottom: 4px;
  text-align: left;
  text-decoration: none;
  box-sizing: border-box;
}
.sidebar .nav-btn:hover { background: var(--card-hover); color: var(--text); }
.sidebar .nav-btn.active {
  background: rgba(99,102,241,0.2);
  color: #a5b4fc;
}
.sidebar .bottom {
  padding: 16px;
  border-top: 1px solid var(--border);
}
.main {
  margin-left: 260px;
  flex: 1;
  padding: 28px 32px;
  max-width: 1100px;
}
.page-header { margin-bottom: 28px; }
.page-header h2 { font-size: 1.7rem; margin-bottom: 4px; }
.page-header p { color: var(--muted); font-size: 0.95rem; }

/* Cards */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.card h3 {
  margin-bottom: 16px;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  gap: 8px;
}
.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}
.form-actions { display: flex; gap: 10px; margin-top: 8px; flex-wrap: wrap; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}
th {
  background: rgba(15,23,42,0.5);
  font-weight: 600;
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
tr:hover td { background: rgba(51,65,85,0.3); }

/* Badge */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}
.badge-cat {
  color: white;
  font-size: 0.72rem;
}

/* Videos header + layout toggles */
.videos-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 18px;
}
.layout-toggles {
  display: flex;
  gap: 6px;
  background: var(--bg);
  padding: 4px;
  border-radius: 10px;
  border: 1px solid var(--border);
}
.layout-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  padding: 7px 12px;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.layout-btn:hover { color: var(--text); background: var(--card-hover); }
.layout-btn.active {
  background: var(--primary);
  color: #fff;
}

/* Video grid (default) */
.video-grid {
  display: grid;
  gap: 20px;
}
.video-grid.layout-grid {
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
}
.video-grid.layout-list {
  grid-template-columns: 1fr;
  gap: 24px;
}
.video-grid.layout-list .video-date-items {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}
.video-grid.layout-list .yt-player-shell {
  padding-bottom: 0;
  height: 0;
  padding-top: min(56.25%, 420px);
}
.video-grid.layout-compact {
  grid-template-columns: 1fr;
  gap: 16px;
}
.video-grid.layout-compact .video-date-items {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.video-grid.layout-compact .video-card {
  display: flex;
  flex-direction: row;
  align-items: stretch;
}
.video-grid.layout-compact .video-card .platform {
  writing-mode: vertical-rl;
  text-orientation: mixed;
  padding: 10px 6px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.video-grid.layout-compact .yt-player-shell {
  width: 220px;
  min-width: 180px;
  padding-bottom: 0;
  height: 124px;
  flex-shrink: 0;
}
.video-grid.layout-compact .video-card .body {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.video-date-group { margin-bottom: 8px; }
.video-date-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

.video-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  transition: transform 0.2s, border-color 0.2s;
}
.video-card:hover {
  transform: translateY(-3px);
  border-color: var(--primary);
}
.video-card .platform {
  padding: 6px 12px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.video-card .platform.youtube { background: rgba(239,68,68,0.2); color: #fca5a5; }
.video-card .platform.mega { background: rgba(59,130,246,0.2); color: #93c5fd; }
.video-card .body { padding: 14px; }
.video-card h4 { margin-bottom: 6px; font-size: 1rem; }
.video-card p { color: var(--muted); font-size: 0.85rem; margin-bottom: 10px; }
.video-card a { color: var(--primary-hover); text-decoration: none; font-weight: 600; font-size: 0.85rem; }
.video-card a:hover { text-decoration: underline; }

.video-title-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 6px;
}
.video-title-row h4 { margin-bottom: 0; flex: 1; }
.video-date {
  font-size: 0.72rem;
  color: var(--muted);
  white-space: nowrap;
  background: rgba(148,163,184,0.12);
  padding: 3px 8px;
  border-radius: 6px;
  font-weight: 600;
}

/* Custom locked YouTube player — branding / title / Watch on YT not clickable */
.yt-player-shell {
  position: relative;
  width: 100%;
  padding-bottom: 56.25%;
  background: #000;
  overflow: hidden;
}
.yt-player-shell .yt-api-player,
.yt-player-shell iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: 0;
  /* Block all clicks on YouTube UI (title, logo, Watch on YouTube, copy link) */
  pointer-events: none !important;
}
.yt-overlay-play {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.25);
  cursor: pointer;
  z-index: 2;
  transition: opacity 0.25s;
}
.yt-play-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: rgba(99,102,241,0.9);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  padding-left: 4px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
}
.yt-overlay-play:hover .yt-play-icon {
  transform: scale(1.08);
  background: var(--primary-hover);
}
.yt-controls {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: linear-gradient(transparent, rgba(0,0,0,0.85));
  pointer-events: auto;
}
.yt-ctrl-play,
.yt-ctrl-mute,
.yt-ctrl-fs {
  background: rgba(255,255,255,0.1);
  border: none;
  color: #fff;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  flex-shrink: 0;
}
.yt-ctrl-play:hover,
.yt-ctrl-mute:hover,
.yt-ctrl-fs:hover {
  background: rgba(255,255,255,0.2);
}
.yt-seek {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  border-radius: 2px;
  background: rgba(255,255,255,0.15);
  outline: none;
  cursor: pointer;
}
.yt-seek::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #818cf8;
  cursor: pointer;
}
.yt-time {
  font-size: 0.7rem;
  color: #cbd5e1;
  white-space: nowrap;
  min-width: 72px;
  text-align: right;
}
.yt-player-shell:fullscreen,
.yt-player-shell.yt-is-fullscreen {
  padding-bottom: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  max-width: 100vw;
  background: #000;
}
.yt-player-shell:fullscreen .yt-api-player,
.yt-player-shell:fullscreen iframe,
.yt-player-shell.yt-is-fullscreen .yt-api-player,
.yt-player-shell.yt-is-fullscreen iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.yt-player-shell:fullscreen .yt-controls,
.yt-player-shell.yt-is-fullscreen .yt-controls {
  padding: 12px 16px;
}
.video-grid.layout-compact .yt-controls {
  padding: 4px 6px;
  gap: 4px;
}
.video-grid.layout-compact .yt-time { display: none; }
.video-grid.layout-compact .yt-play-icon {
  width: 44px;
  height: 44px;
  font-size: 16px;
}

@media (max-width: 640px) {
  .video-grid.layout-compact .video-card {
    flex-direction: column;
  }
  .video-grid.layout-compact .video-card .platform {
    writing-mode: horizontal-tb;
    padding: 6px 12px;
  }
  .video-grid.layout-compact .yt-player-shell {
    width: 100%;
    height: 0;
    padding-bottom: 56.25%;
  }
  .video-grid.layout-compact .yt-time { display: inline; }
}

/* Assignment / Note items */
.item-list { display: flex; flex-direction: column; gap: 12px; }
.item {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 18px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
}
.item h4 { margin-bottom: 4px; }
.item .meta { color: var(--muted); font-size: 0.8rem; margin-top: 6px; }
.item .content { color: #cbd5e1; font-size: 0.9rem; margin-top: 6px; white-space: pre-wrap; word-break: break-word; }

/* Student ID box */
.student-id-box {
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  color: white;
  padding: 28px;
  border-radius: 16px;
  text-align: center;
  margin-bottom: 24px;
  box-shadow: 0 8px 32px rgba(79,70,229,0.3);
}
.student-id-box .label { font-size: 0.9rem; opacity: 0.85; margin-bottom: 6px; }
.student-id-box .id { font-size: 2.1rem; font-weight: 700; letter-spacing: 2px; }
.student-id-box .cat-tag {
  display: inline-block;
  margin-top: 10px;
  background: rgba(255,255,255,0.2);
  padding: 4px 14px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
}

/* Filter bar */
.filter-bar {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.filter-bar select {
  background: var(--bg);
  border: 1.5px solid var(--border);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.9rem;
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 20px;
}
.modal-overlay.show { display: flex; }
.modal {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
}
.modal h3 { margin-bottom: 18px; }
.modal-actions { display: flex; gap: 10px; margin-top: 16px; justify-content: flex-end; }

/* Empty */
.empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--muted);
  font-size: 0.95rem;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #1e293b;
  color: white;
  padding: 14px 22px;
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.4);
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.3s;
  z-index: 999;
  border: 1px solid var(--border);
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast.success { border-color: var(--success); background: #14532d; }
.toast.error { border-color: var(--danger); background: #7f1d1d; }

/* Note type badges */
.ntype-note { background: rgba(99,102,241,0.2); color: #a5b4fc; }
.ntype-link { background: rgba(34,197,94,0.2); color: #86efac; }
.ntype-credential { background: rgba(245,158,11,0.2); color: #fcd34d; }
.ntype-attachment { background: rgba(59,130,246,0.2); color: #93c5fd; }

/* Responsive */
@media (max-width: 768px) {
  .sidebar { width: 100%; position: relative; border-right: none; border-bottom: 1px solid var(--border); }
  .layout { flex-direction: column; }
  .main { margin-left: 0; padding: 20px 16px; }
  .sidebar nav { display: flex; flex-wrap: wrap; gap: 4px; padding: 10px; }
  .sidebar .nav-btn { width: auto; flex: 1 1 auto; justify-content: center; font-size: 0.8rem; padding: 8px 10px; }
}
