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

/* ===== CSS Variables ===== */
:root {
  --primary: #2563EB;
  --primary-light: #3B82F6;
  --primary-dark: #1D4ED8;
  --dark: #0F172A;
  --dark-secondary: #1E293B;
  --dark-tertiary: #334155;
  --light: #F8FAFC;
  --light-secondary: #E2E8F0;
  --accent: #38BDF8;
  --accent-gradient: linear-gradient(135deg, #2563EB, #38BDF8);
  --gradient-bg: linear-gradient(135deg, #0F172A 0%, #1E293B 50%, #0F172A 100%);
  --glass-bg: rgba(255, 255, 255, 0.08);
  --glass-border: rgba(255, 255, 255, 0.12);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.12);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.15);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.2);
  --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.25);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--dark);
  color: var(--light);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

a {
  text-decoration: none;
  color: inherit;
}

button {
  cursor: pointer;
  font-family: inherit;
  border: none;
  outline: none;
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: var(--dark);
}

::-webkit-scrollbar-thumb {
  background: var(--dark-tertiary);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--primary);
}

/* ===== Animations ===== */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeInScale {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes slideInLeft {
  from { opacity: 0; transform: translateX(-30px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(30px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

@keyframes ripple {
  to { transform: scale(4); opacity: 0; }
}

@keyframes gradientShift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.animate-fade-in {
  animation: fadeIn 0.6s ease-out forwards;
}

.animate-slide-left {
  animation: slideInLeft 0.5s ease-out forwards;
}

.animate-slide-right {
  animation: slideInRight 0.5s ease-out forwards;
}

/* ===== Ripple Effect ===== */
.ripple {
  position: relative;
  overflow: hidden;
}

.ripple::after {
  content: '';
  position: absolute;
  width: 100%;
  height: 100%;
  top: 50%;
  left: 50%;
  pointer-events: none;
  background: radial-gradient(circle, rgba(255,255,255,0.3) 10%, transparent 10.1%);
  transform: translate(-50%, -50%) scale(0);
  opacity: 0;
  transition: transform 0.5s, opacity 0.5s;
}

.ripple:active::after {
  transform: translate(-50%, -50%) scale(4);
  opacity: 0;
  transition: 0s;
}

/* ========================================
   LOGIN PAGE
   ======================================== */

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gradient-bg);
  position: relative;
  overflow: hidden;
}

.login-page::before {
  content: '';
  position: absolute;
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(37, 99, 235, 0.15), transparent 70%);
  top: -100px;
  right: -100px;
  border-radius: 50%;
  animation: float 6s ease-in-out infinite;
}

.login-page::after {
  content: '';
  position: absolute;
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, rgba(56, 189, 248, 0.1), transparent 70%);
  bottom: -80px;
  left: -80px;
  border-radius: 50%;
  animation: float 8s ease-in-out infinite reverse;
}

.login-card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 420px;
  padding: 48px 40px;
  background: rgba(30, 41, 59, 0.6);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  animation: fadeInScale 0.7s ease-out;
}

.login-logo {
  text-align: center;
  margin-bottom: 12px;
}

.login-logo img {
  height: 48px;
  width: auto;
}

.login-brand {
  text-align: center;
  margin-bottom: 8px;
}

.login-brand h1 {
  font-size: 1.75rem;
  font-weight: 800;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.login-subtitle {
  text-align: center;
  color: #94A3B8;
  font-size: 0.9rem;
  margin-bottom: 32px;
}

.form-group {
  margin-bottom: 24px;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: #CBD5E1;
  margin-bottom: 8px;
}

.form-group .input-wrapper {
  position: relative;
}

.form-group .input-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: #64748B;
  font-size: 1rem;
  pointer-events: none;
}

.form-group input {
  width: 100%;
  padding: 14px 16px 14px 44px;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(100, 116, 139, 0.3);
  border-radius: var(--radius-md);
  color: var(--light);
  font-size: 0.95rem;
  font-family: inherit;
  transition: var(--transition);
}

.form-group input::placeholder {
  color: #64748B;
}

.form-group input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}

.login-btn {
  width: 100%;
  padding: 14px;
  background: var(--accent-gradient);
  background-size: 200% 200%;
  animation: gradientShift 3s ease infinite;
  border: none;
  border-radius: var(--radius-md);
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.3px;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.login-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(37, 99, 235, 0.4);
}

.login-btn:active {
  transform: translateY(0);
}

.login-error {
  display: none;
  padding: 12px 16px;
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: var(--radius-sm);
  color: #FCA5A5;
  font-size: 0.85rem;
  margin-bottom: 20px;
  animation: fadeIn 0.3s ease-out;
}

.login-error.show {
  display: flex;
  align-items: center;
  gap: 8px;
}

.login-footer {
  margin-top: 24px;
  text-align: center;
  font-size: 0.8rem;
  color: #64748B;
}

.login-footer a {
  color: var(--accent);
  font-weight: 500;
}

.login-footer a:hover {
  text-decoration: underline;
}

/* Toggle password visibility */
.toggle-password {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: #64748B;
  cursor: pointer;
  font-size: 1rem;
  padding: 4px;
  transition: var(--transition);
}

.toggle-password:hover {
  color: var(--accent);
}

/* ========================================
   DASHBOARD PAGE
   ======================================== */

.dashboard {
  display: grid;
  grid-template-columns: 300px 1fr;
  grid-template-rows: 64px 1fr;
  min-height: 100vh;
  background: var(--dark);
}

/* ===== Top Bar ===== */
.topbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  background: var(--dark-secondary);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  z-index: 100;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.topbar-logo img {
  height: 32px;
  width: auto;
}

.topbar-brand {
  font-size: 1.1rem;
  font-weight: 700;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.menu-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--light);
  font-size: 1.4rem;
  padding: 8px;
  cursor: pointer;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.topbar-progress {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: #94A3B8;
}

.topbar-progress-bar {
  width: 120px;
  height: 4px;
  background: var(--dark-tertiary);
  border-radius: 2px;
  overflow: hidden;
}

.topbar-progress-fill {
  height: 100%;
  background: var(--accent-gradient);
  border-radius: 2px;
  transition: width 0.5s ease;
}

.logout-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.25);
  border-radius: var(--radius-sm);
  color: #FCA5A5;
  font-size: 0.85rem;
  font-weight: 500;
  transition: var(--transition);
}

.logout-btn:hover {
  background: rgba(239, 68, 68, 0.2);
  border-color: rgba(239, 68, 68, 0.4);
}

/* ===== Sidebar ===== */
.sidebar {
  grid-row: 2;
  background: var(--dark-secondary);
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  overflow-y: auto;
  position: sticky;
  top: 64px;
  height: calc(100vh - 64px);
  transition: var(--transition);
}

.sidebar-header {
  padding: 24px 20px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.sidebar-header h2 {
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #64748B;
  margin-bottom: 4px;
}

.sidebar-header .course-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--light);
}

.sidebar-header .course-meta {
  font-size: 0.8rem;
  color: #64748B;
  margin-top: 4px;
}

.lecture-list {
  padding: 8px 0;
  list-style: none;
}

.lecture-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  cursor: pointer;
  transition: var(--transition);
  border-left: 3px solid transparent;
  position: relative;
}

.lecture-item:hover {
  background: rgba(255, 255, 255, 0.04);
}

.lecture-item.active {
  background: rgba(37, 99, 235, 0.1);
  border-left-color: var(--primary);
}

.lecture-item.completed {
  opacity: 0.7;
}

.lecture-number {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  min-width: 32px;
  border-radius: 50%;
  background: var(--dark-tertiary);
  font-size: 0.8rem;
  font-weight: 600;
  color: #94A3B8;
  transition: var(--transition);
}

.lecture-item.active .lecture-number {
  background: var(--primary);
  color: #fff;
}

.lecture-item.completed .lecture-number {
  background: rgba(34, 197, 94, 0.2);
  color: #4ADE80;
}

.lecture-info {
  flex: 1;
  min-width: 0;
}

.lecture-title {
  font-size: 0.88rem;
  font-weight: 500;
  color: #CBD5E1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: var(--transition);
}

.lecture-item.active .lecture-title {
  color: var(--light);
  font-weight: 600;
}

.lecture-duration {
  font-size: 0.75rem;
  color: #64748B;
  margin-top: 2px;
}

.lecture-status-icon {
  font-size: 0.75rem;
  color: #64748B;
}

.lecture-item.active .lecture-status-icon {
  color: var(--accent);
}

.lecture-item.completed .lecture-status-icon {
  color: #4ADE80;
}

/* ===== Main Content ===== */
.main-content {
  grid-row: 2;
  padding: 24px;
  overflow-y: auto;
  animation: fadeIn 0.5s ease-out;
}

/* ===== Video Player ===== */
.video-container {
  background: #000;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  position: relative;
  animation: fadeInScale 0.5s ease-out;
}

.video-wrapper {
  position: relative;
  width: 100%;
  padding-top: 56.25%; /* 16:9 aspect ratio */
  background: #0a0a0a;
}

.video-wrapper iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: none;
}

.video-placeholder {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--dark-secondary);
  color: #64748B;
  gap: 16px;
}

.video-placeholder .placeholder-icon {
  font-size: 3rem;
  opacity: 0.5;
}

.video-placeholder .placeholder-text {
  font-size: 1rem;
  font-weight: 500;
}

.video-placeholder .retry-btn {
  padding: 10px 24px;
  background: var(--primary);
  border: none;
  border-radius: var(--radius-sm);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
}

.video-placeholder .retry-btn:hover {
  background: var(--primary-dark);
}

/* Video loading state */
.video-loading {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--dark-secondary);
  z-index: 5;
  transition: opacity 0.3s ease;
}

.video-loading.hidden {
  opacity: 0;
  pointer-events: none;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 3px solid var(--dark-tertiary);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ===== Player Controls ===== */
.player-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: var(--dark-secondary);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.player-controls .control-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: #CBD5E1;
  font-size: 0.9rem;
  transition: var(--transition);
  position: relative;
}

.player-controls .control-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--light);
}

.player-controls .control-btn.active {
  color: var(--accent);
}

.player-controls .control-separator {
  width: 1px;
  height: 20px;
  background: rgba(255, 255, 255, 0.1);
  margin: 0 4px;
}

.speed-select {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-sm);
  color: #CBD5E1;
  font-size: 0.8rem;
  font-family: inherit;
  padding: 6px 8px;
  cursor: pointer;
  transition: var(--transition);
}

.speed-select:hover {
  border-color: var(--primary);
}

.speed-select:focus {
  outline: none;
  border-color: var(--primary);
}

.player-time {
  font-size: 0.8rem;
  color: #64748B;
  margin-left: auto;
  font-variant-numeric: tabular-nums;
}

/* ===== Lecture Info Below Player ===== */
.lecture-detail {
  padding: 24px 0;
}

.lecture-detail-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--light);
  margin-bottom: 8px;
}

.lecture-detail-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 0.85rem;
  color: #64748B;
}

.lecture-detail-meta span {
  display: flex;
  align-items: center;
  gap: 6px;
}

.lecture-nav {
  display: flex;
  justify-content: space-between;
  margin-top: 24px;
  gap: 12px;
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  background: var(--dark-secondary);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-md);
  color: #CBD5E1;
  font-size: 0.9rem;
  font-weight: 500;
  transition: var(--transition);
}

.nav-btn:hover:not(:disabled) {
  background: rgba(37, 99, 235, 0.1);
  border-color: var(--primary);
  color: var(--light);
}

.nav-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ===== Mobile Sidebar Overlay ===== */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  z-index: 199;
}

.sidebar-overlay.show {
  display: block;
}

/* ========================================
   RESPONSIVE DESIGN
   ======================================== */

@media (max-width: 1024px) {
  .dashboard {
    grid-template-columns: 260px 1fr;
  }

  .topbar-progress {
    display: none;
  }
}

@media (max-width: 768px) {
  .dashboard {
    grid-template-columns: 1fr;
    grid-template-rows: 64px 1fr;
  }

  .menu-toggle {
    display: block;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: -300px;
    width: 300px;
    height: 100vh;
    z-index: 200;
    transition: left 0.3s ease;
  }

  .sidebar.open {
    left: 0;
  }

  .sidebar-overlay.show {
    display: block;
  }

  .main-content {
    padding: 16px;
    grid-column: 1;
  }

  .video-container {
    border-radius: var(--radius-md);
  }

  .lecture-detail-title {
    font-size: 1.2rem;
  }

  .lecture-nav {
    flex-direction: column;
  }

  .nav-btn {
    justify-content: center;
  }

  .player-controls {
    flex-wrap: wrap;
    gap: 4px;
    padding: 10px 12px;
  }

  .player-time {
    width: 100%;
    text-align: center;
    margin-top: 4px;
    margin-left: 0;
  }

  .login-card {
    margin: 16px;
    padding: 32px 24px;
  }

  .topbar-progress {
    display: none;
  }

  .logout-btn span {
    display: none;
  }
}

@media (max-width: 480px) {
  .login-card {
    padding: 28px 20px;
  }

  .login-brand h1 {
    font-size: 1.4rem;
  }

  .form-group input {
    padding: 12px 14px 12px 40px;
  }

  .lecture-detail-meta {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
}

/* ===== Utility Classes ===== */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ===== Tooltip ===== */
[data-tooltip] {
  position: relative;
}

[data-tooltip]::before {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 10px;
  background: var(--dark);
  color: #CBD5E1;
  font-size: 0.75rem;
  font-weight: 500;
  border-radius: 6px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
  transform: translateX(-50%) translateY(4px);
  z-index: 10;
}

[data-tooltip]:hover::before {
  opacity: 1;
  transform: translateX(-50%) translateY(-4px);
}
