/* ============================================================
   Asset Yogi Learning Portal — Master Stylesheet
   Design System: Dark Purple #2D0850, Off-white #F8F8F8
   ============================================================ */

/* ----- CSS Variables ----- */
:root {
  --primary:       #2D0850;
  --primary-hover: #4a0d82;
  --primary-light: #f3eaff;
  --bg:            #F8F8F8;
  --card-bg:       #FFFFFF;
  --text:          #1A1A1A;
  --text-muted:    #666666;
  --border:        #E5E5E5;
  --success:       #22C55E;
  --danger:        #EF4444;
  --warning:       #F59E0B;
  --radius:        8px;
  --radius-lg:     12px;
  --shadow:        0 2px 8px rgba(0,0,0,0.08);
  --shadow-hover:  0 6px 20px rgba(45,8,80,0.15);
  --header-h:      60px;
}

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

html { font-size: 16px; }

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

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

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

/* ----- Header ----- */
.site-header {
  height: var(--header-h);
  background: var(--primary);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.header-logo {
  font-weight: 700;
  font-size: 1.2rem;
  color: #fff;
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  color: rgba(255,255,255,0.7);
  font-size: 0.875rem;
  overflow: hidden;
  flex: 1;
  min-width: 0;
}

.breadcrumb a { color: rgba(255,255,255,0.85); text-decoration: none; white-space: nowrap; }
.breadcrumb a:hover { color: #fff; }
.breadcrumb > span:last-child {
  color: rgba(255,255,255,0.6);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  margin-left: auto;
}

.header-email {
  color: rgba(255,255,255,0.75);
  font-size: 0.8rem;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ----- User menu dropdown ----- */
.user-menu {
  position: relative;
  flex-shrink: 0;
}

.user-menu-trigger {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 4px 10px 4px 6px;
  border-radius: 20px;
  border: 1px solid rgba(255,255,255,0.2);
  cursor: pointer;
  background: transparent;
  transition: background 0.15s, border-color 0.15s;
  color: #fff;
}
.user-menu-trigger:hover,
.user-menu:hover .user-menu-trigger {
  background: rgba(255,255,255,0.12);
  border-color: rgba(255,255,255,0.35);
}

.user-menu-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: rgba(255,255,255,0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.user-menu-email {
  font-size: 0.78rem;
  color: rgba(255,255,255,0.85);
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-menu-chevron {
  font-size: 0.6rem;
  color: rgba(255,255,255,0.5);
  margin-left: 2px;
  transition: transform 0.15s;
}
.user-menu:hover .user-menu-chevron {
  transform: rotate(180deg);
}

.user-menu-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
  border: 1px solid var(--border);
  min-width: 220px;
  padding: 16px 8px 8px; /* top padding bridges the gap visually */
  margin-top: 0;
  z-index: 500;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-6px);
  transition: opacity 0.18s, transform 0.18s;
}
/* Invisible bridge covers the gap between trigger and dropdown */
.user-menu-dropdown::before {
  content: '';
  position: absolute;
  top: -10px;
  left: 0;
  right: 0;
  height: 10px;
}
.user-menu:hover .user-menu-dropdown {
  opacity: 1;
  pointer-events: all;
  transform: translateY(0);
}

/* Days left row */
.um-days-row {
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--bg);
  margin-bottom: 6px;
}
.um-days-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  font-weight: 600;
  margin-bottom: 4px;
}
.um-days-value {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--primary);
}
.um-days-sub {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 1px;
}

/* Menu items */
.um-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  transition: background 0.12s;
  border: none;
  background: none;
  width: 100%;
  cursor: pointer;
}
.um-item:hover {
  background: var(--primary-light);
  color: var(--primary);
  text-decoration: none;
}
.um-item-icon {
  font-size: 1rem;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}
.um-item.um-support {
  color: #059669;
}
.um-item.um-support:hover {
  background: #d1fae5;
  color: #047857;
}
.um-divider {
  height: 1px;
  background: var(--border);
  margin: 6px 0;
}

/* ----- Access days badge + tooltip ----- */
.access-chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.3px;
  white-space: nowrap;
  cursor: default;
  flex-shrink: 0;
}
.access-chip-ok   { background: rgba(52,211,153,0.2); color: #6ee7b7; border: 1px solid rgba(52,211,153,0.3); }
.access-chip-warn { background: rgba(251,191,36,0.2);  color: #fcd34d; border: 1px solid rgba(251,191,36,0.3); }
.access-chip-low  { background: rgba(239,68,68,0.2);   color: #fca5a5; border: 1px solid rgba(239,68,68,0.3); }

/* Tooltip shown on hover */
.access-chip::after {
  content: attr(data-tip);
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  background: #1a1a2e;
  color: #fff;
  font-size: 0.78rem;
  font-weight: 400;
  padding: 8px 12px;
  border-radius: 8px;
  white-space: nowrap;
  box-shadow: 0 4px 16px rgba(0,0,0,0.35);
  border: 1px solid rgba(255,255,255,0.1);
  opacity: 0;
  pointer-events: none;
  transform: translateY(-4px);
  transition: opacity 0.18s, transform 0.18s;
  z-index: 500;
}
.access-chip:hover::after {
  opacity: 1;
  transform: translateY(0);
}

/* ----- Header WhatsApp link ----- */
.header-wa-link {
  color: #4ade80;
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
  flex-shrink: 0;
  text-decoration: none;
  border: 1px solid rgba(74,222,128,0.4);
  padding: 3px 10px;
  border-radius: 20px;
  transition: background 0.15s;
  display: flex;
  align-items: center;
  gap: 2px;
}
.header-wa-link:hover {
  background: rgba(74,222,128,0.15);
  text-decoration: none;
}
.wa-msg-text {
  color: rgba(255,255,255,0.8);
  font-weight: 500;
  font-size: 0.75rem;
}
@media (max-width: 900px) {
  .wa-msg-text { display: none; }
}

/* ----- Footer ----- */
.site-footer {
  background: var(--card-bg);
  border-top: 1px solid var(--border);
  padding: 24px 0;
  margin-top: auto;
}
.footer-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.footer-contact {
  font-size: 0.875rem;
  color: var(--text-muted);
}
.footer-contact a {
  color: var(--primary);
  font-weight: 600;
  text-decoration: none;
}
.footer-contact a:hover { text-decoration: underline; }
.footer-copy {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ----- Buttons ----- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  border: 2px solid transparent;
  transition: background 0.15s, border-color 0.15s, transform 0.1s, box-shadow 0.15s;
  white-space: nowrap;
  text-decoration: none;
  line-height: 1;
}

.btn:hover { text-decoration: none; }
.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }

.btn-outline {
  background: transparent;
  color: var(--primary);
  border-color: var(--primary);
}
.btn-outline:hover { background: var(--primary-light); }

/* White outline for on-dark-bg use */
.btn-outline-white {
  background: transparent;
  color: #fff;
  border-color: rgba(255,255,255,0.5);
}
.btn-outline-white:hover { background: rgba(255,255,255,0.1); transform: scale(1.07); }

.btn-block { width: 100%; }

.btn-sm { padding: 6px 14px; font-size: 0.8rem; }

.btn.disabled, .btn[disabled] {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

/* ----- Alerts ----- */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 0.9rem;
  margin-bottom: 16px;
}
.alert-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.alert-error   { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.alert-info    { background: #dbeafe; color: #1e40af; border: 1px solid #bfdbfe; }

/* ----- Forms ----- */
.form-group { margin-bottom: 16px; }

.form-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-family: inherit;
  color: var(--text);
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.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(45,8,80,0.1);
}

/* ----- Containers ----- */
.container       { max-width: 1200px; margin: 0 auto; padding: 0 24px; }
.container-narrow { max-width: 860px; margin: 0 auto; padding: 0 24px; }

.main-content { padding: 32px 0; }

.section-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 24px;
}

/* ----- Login Page ----- */
.login-page {
  background:
    radial-gradient(ellipse 80% 60% at 70% 10%, rgba(120,40,220,0.35) 0%, transparent 60%),
    radial-gradient(ellipse 60% 50% at 10% 90%, rgba(80,10,160,0.4) 0%, transparent 60%),
    linear-gradient(150deg, #0e0225 0%, #1c0442 45%, #2a0660 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 32px 20px;
  position: relative;
  overflow: hidden;
}

/* Decorative floating circles */
.login-page::before {
  content: '';
  position: fixed;
  top: -180px; right: -180px;
  width: 480px; height: 480px;
  background: radial-gradient(circle, rgba(140,50,255,0.18) 0%, transparent 70%);
  border-radius: 50%;
  pointer-events: none;
}
.login-page::after {
  content: '';
  position: fixed;
  bottom: -160px; left: -160px;
  width: 420px; height: 420px;
  background: radial-gradient(circle, rgba(90,20,180,0.22) 0%, transparent 70%);
  border-radius: 50%;
  pointer-events: none;
}

.login-wrapper {
  width: 100%;
  max-width: 440px;
  position: relative;
  z-index: 1;
}

.login-logo {
  text-align: center;
  margin-bottom: 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

/* Small icon above logo text */
.login-logo-icon {
  width: 52px; height: 52px;
  background: linear-gradient(135deg, #7c3aed, #4f1d96);
  border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 4px;
  box-shadow: 0 8px 24px rgba(124,58,237,0.45);
}

.logo-text {
  font-size: 2rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.5px;
  text-shadow: 0 2px 12px rgba(0,0,0,0.3);
}

.logo-sub {
  font-size: 0.8rem;
  color: rgba(255,255,255,0.55);
  letter-spacing: 2.5px;
  text-transform: uppercase;
}

.login-card {
  background: #fff;
  border-radius: 20px;
  padding: 40px 36px;
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.08),
    0 24px 80px rgba(0,0,0,0.45),
    0 8px 24px rgba(80,10,160,0.2);
  position: relative;
  overflow: hidden;
}

/* Purple accent bar at top of card */
.login-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: linear-gradient(90deg, #7c3aed, #4f1d96, #a855f7);
  border-radius: 20px 20px 0 0;
}

.login-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 6px;
}

.login-desc {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 28px;
}

.login-note {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  line-height: 1.8;
}

/* ----- Join / Contact box on login page ----- */
.login-join-box {
  background: rgba(255,255,255,0.06);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 20px;
  padding: 28px 28px 24px;
  text-align: center;
  margin-top: 16px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}
.login-join-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 6px;
  letter-spacing: -0.2px;
}
.login-join-sub {
  font-size: 0.82rem;
  color: rgba(255,255,255,0.55);
  margin-bottom: 20px;
  line-height: 1.5;
}
.login-join-btns {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}
.login-join-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 22px;
  border-radius: 10px;
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
  transition: transform 0.15s, box-shadow 0.15s;
}
.login-join-btn:hover { transform: translateY(-2px); }
.login-join-wa {
  background: linear-gradient(135deg, #25D366, #1da851);
  color: #fff;
  box-shadow: 0 4px 16px rgba(37,211,102,0.35);
}
.login-join-wa:hover { box-shadow: 0 6px 20px rgba(37,211,102,0.5); }
.login-join-email {
  background: rgba(255,255,255,0.1);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.22);
}
.login-join-email:hover { background: rgba(255,255,255,0.18); }

/* "Request Access" link in login note */
.login-request-link {
  color: var(--primary) !important;
  font-weight: 700;
  font-size: 0.85rem;
  text-decoration: none;
  display: inline-block;
  margin-top: 6px;
  transition: color 0.15s;
}
.login-request-link:hover { color: var(--primary-dark, #5b21b6) !important; text-decoration: underline; }

/* Generic utility */
.hidden { display: none !important; }

/* ----- Request Access Modal ----- */
.req-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}
.req-modal-backdrop.hidden { display: none; }

.req-modal-box {
  background: #fff;
  border-radius: 20px;
  padding: 36px 32px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 24px 80px rgba(0,0,0,0.4);
  position: relative;
  animation: modalIn 0.22s ease;
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(16px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.req-modal-header { margin-bottom: 24px; padding-right: 32px; }
.req-modal-title  { font-size: 1.4rem; font-weight: 700; color: var(--primary); margin-bottom: 4px; }
.req-modal-sub    { color: var(--text-muted); font-size: 0.875rem; }
.req-modal-close  {
  position: absolute;
  top: 20px; right: 20px;
  background: var(--bg);
  border: none;
  width: 32px; height: 32px;
  border-radius: 50%;
  font-size: 1.2rem;
  cursor: pointer;
  color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s, color 0.15s;
}
.req-modal-close:hover { background: var(--border); color: var(--text); }

/* ----- Dashboard Course Grid ----- */
.course-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

.course-card {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: var(--text);
  border: 2px solid transparent;
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
}

.course-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-hover);
  border-color: var(--primary);
  text-decoration: none;
  color: var(--text);
}

.course-thumb {
  width: 100%;
  aspect-ratio: 16/9;
  overflow: hidden;
  background: var(--primary);
}

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

.course-thumb-placeholder {
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, var(--primary), var(--primary-hover));
  display: flex;
  align-items: center;
  justify-content: center;
}

.course-thumb-placeholder span {
  font-size: 2.5rem;
  font-weight: 800;
  color: rgba(255,255,255,0.3);
  text-transform: uppercase;
}

.course-card-body {
  padding: 16px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.course-name {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
}

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

.course-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
}

.lesson-count {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
}

.lang-badges { display: flex; gap: 4px; }

.badge {
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.3px;
}
.badge-hi { background: #fef3c7; color: #92400e; }
.badge-en { background: #dbeafe; color: #1e40af; }

/* ----- Course Page ----- */
.course-header {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow);
  margin-bottom: 24px;
}

.course-title {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--primary);
  margin-bottom: 12px;
}

.course-header-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.lesson-count-label {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.meta-divider { color: var(--border); }

/* Language toggle */
.lang-toggle-form {
  display: flex;
  align-items: center;
  gap: 8px;
}

.lang-label {
  font-size: 0.875rem;
  color: var(--text-muted);
  font-weight: 500;
}

.lang-radio {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 12px;
  border-radius: 20px;
  border: 1.5px solid var(--border);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  color: var(--text-muted);
}

.lang-radio input[type="radio"] { display: none; }

.lang-radio.active,
.lang-radio:has(input:checked) {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary);
}

/* Sections accordion */
.sections-list { display: flex; flex-direction: column; gap: 12px; }

.section-block {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.section-header {
  width: 100%;
  padding: 14px 20px;
  background: var(--card-bg);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  text-align: left;
  transition: background 0.1s;
}

.section-header:hover { background: var(--bg); }

.section-arrow {
  color: var(--primary);
  font-size: 0.8rem;
  transition: transform 0.2s;
  flex-shrink: 0;
}

.section-name { flex: 1; }

.section-lesson-count {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 400;
}

.section-body { display: none; }
.section-body.open { display: block; }

.lesson-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 20px 11px 32px;
  border-top: 1px solid var(--border);
  color: var(--text);
  text-decoration: none;
  transition: background 0.1s;
  font-size: 0.875rem;
}

.lesson-row:hover { background: var(--primary-light); text-decoration: none; color: var(--primary); }

.lesson-num {
  font-size: 0.75rem;
  color: var(--text-muted);
  min-width: 26px;
  text-align: right;
}

.lesson-play-icon {
  color: var(--primary);
  font-size: 0.7rem;
  flex-shrink: 0;
}

.lesson-title { flex: 1; }

.coming-soon-badge {
  padding: 2px 8px;
  background: #f3f4f6;
  border-radius: 4px;
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 500;
  white-space: nowrap;
}

.lesson-duration {
  font-size: 0.8rem;
  color: var(--text-muted);
  min-width: 40px;
  text-align: right;
}

.lesson-coming-soon {
  opacity: 0.55;
  cursor: default;
}

/* ----- Lesson Player Page ----- */
.lesson-page body, body.lesson-page { background: #111; }


.lesson-layout {
  display: flex;
  min-height: calc(100vh - var(--header-h));
  background: #111;
}

.lesson-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: #111;
  height: calc(100vh - var(--header-h));
  overflow: hidden;
}

/* Player — fills all remaining height after the info bar */
.player-wrapper {
  position: relative;
  width: 100%;
  background: #000;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.player-container {
  position: relative;
  width: 100%;
  height: 100%;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
}

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

.spinner-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  color: rgba(255,255,255,0.5);
  font-size: 0.85rem;
}

.spinner {
  width: 36px; height: 36px;
  border: 3px solid rgba(255,255,255,0.2);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Autoplay overlay */
.autoplay-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

.autoplay-overlay.hidden { display: none; }

.autoplay-box {
  background: #1a1a2e;
  border-radius: var(--radius-lg);
  padding: 28px 32px;
  text-align: center;
  max-width: 320px;
  width: 90%;
  border: 1px solid rgba(255,255,255,0.1);
}

.autoplay-label {
  color: rgba(255,255,255,0.7);
  font-size: 0.9rem;
  margin-bottom: 8px;
}

#countdown { color: #fff; font-weight: 700; font-size: 1.1rem; }

.autoplay-next-title {
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 16px;
}

.autoplay-progress-bar {
  height: 4px;
  background: rgba(255,255,255,0.15);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 20px;
}

#autoplay-bar {
  height: 100%;
  background: var(--primary-hover);
  width: 100%;
  transition: width 1s linear;
}

.autoplay-actions { display: flex; gap: 10px; justify-content: center; }
.autoplay-actions .btn-outline { color: rgba(255,255,255,0.7); border-color: rgba(255,255,255,0.3); }
.autoplay-actions .btn-outline:hover { background: rgba(255,255,255,0.1); }

/* Lesson info bar — title + nav + fullscreen all in one compact row */
.lesson-info-bar {
  background: #1a1a1a;
  padding: 10px 20px;
  border-bottom: 1px solid #2a2a2a;
  display: flex;
  align-items: center;
  gap: 12px;
}

.lesson-info-text { flex: 1; min-width: 0; overflow: hidden; }

/* Inline prev/next nav inside info bar */
.lesson-nav-inline {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}
.lesson-nav-inline .btn-outline {
  color: rgba(255,255,255,0.7);
  border-color: rgba(255,255,255,0.25);
}
.lesson-nav-inline .btn-outline:hover { background: rgba(255,255,255,0.08); }

/* Custom fullscreen button */
.btn-fullscreen {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: transparent;
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 6px;
  color: rgba(255,255,255,0.7);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.btn-fullscreen:hover {
  background: rgba(255,255,255,0.1);
  border-color: rgba(255,255,255,0.45);
  color: #fff;
}

/* Player wrapper — native fullscreen overrides */
.player-wrapper:fullscreen,
.player-wrapper:-webkit-full-screen,
.player-wrapper:-moz-full-screen,
.player-wrapper:-ms-fullscreen {
  width: 100vw !important;
  height: 100vh !important;
  background: #000;
  display: flex;
  flex-direction: column;
}
.player-wrapper:fullscreen .player-container,
.player-wrapper:-webkit-full-screen .player-container,
.player-wrapper:-moz-full-screen .player-container,
.player-wrapper:-ms-fullscreen .player-container {
  width: 100%;
  height: 100%;
}

/* CSS fake fullscreen — for iOS Safari */
.player-wrapper.css-fullscreen {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  z-index: 9999 !important;
  background: #000 !important;
  padding: 0 !important;
  margin: 0 !important;
  border-radius: 0 !important;
}
.player-wrapper.css-fullscreen .player-container {
  position: absolute !important;
  top: 0; left: 0;
  width: 100% !important;
  height: 100% !important;
  padding: 0 !important;
}
.player-wrapper.css-fullscreen .player-container iframe {
  width: 100% !important;
  height: 100% !important;
}
/* Keep fullscreen button visible on top */
.player-wrapper.css-fullscreen .btn-fullscreen {
  position: absolute;
  bottom: 12px;
  right: 12px;
  z-index: 10000;
  background: rgba(0,0,0,0.6);
}

.lesson-title-h2 {
  font-size: 0.95rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lesson-meta-text { font-size: 0.8rem; color: rgba(255,255,255,0.5); }

/* lesson-nav removed — nav buttons now live inside .lesson-info-bar via .lesson-nav-inline */

/* Sidebar */
.lesson-sidebar {
  width: 320px;
  flex-shrink: 0;
  background: #1a1a1a;
  border-left: 1px solid #2a2a2a;
  overflow-y: auto;
  height: calc(100vh - var(--header-h));
  position: sticky;
  top: var(--header-h);
}

.sidebar-inner { padding: 0; }

.sidebar-lang {
  padding: 14px 16px;
  border-bottom: 1px solid #2a2a2a;
}

.sidebar-lang .lang-label { color: rgba(255,255,255,0.5); }
.sidebar-lang .lang-radio  { color: rgba(255,255,255,0.6); border-color: rgba(255,255,255,0.2); }
.sidebar-lang .lang-radio.active,
.sidebar-lang .lang-radio:has(input:checked) {
  border-color: var(--primary-hover);
  background: rgba(74,13,130,0.3);
  color: #c084fc;
}

.sidebar-course-title {
  padding: 12px 16px 8px;
  font-size: 0.75rem;
  font-weight: 700;
  color: rgba(255,255,255,0.4);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.sidebar-section { border-bottom: 1px solid #2a2a2a; }

.sidebar-section-header {
  width: 100%;
  padding: 10px 16px;
  background: transparent;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  color: rgba(255,255,255,0.6);
  text-align: left;
  transition: background 0.1s;
}
.sidebar-section-header:hover { background: rgba(255,255,255,0.05); color: #fff; }
.sidebar-section-header.open { color: #fff; }
.sidebar-arrow { font-size: 0.6rem; flex-shrink: 0; }

.sidebar-section-body { display: none; }
.sidebar-section-body.open { display: block; }

.sidebar-lesson {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px 8px 28px;
  font-size: 0.8rem;
  color: rgba(255,255,255,0.5);
  text-decoration: none;
  transition: background 0.1s;
  border-top: 1px solid rgba(255,255,255,0.05);
}
.sidebar-lesson:hover { background: rgba(255,255,255,0.05); color: rgba(255,255,255,0.8); text-decoration: none; }
.sidebar-lesson.current { background: rgba(45,8,80,0.5); color: #c084fc; font-weight: 600; }
.sidebar-lesson.unavail { opacity: 0.4; cursor: default; pointer-events: none; }

.sidebar-lesson-icon { font-size: 0.65rem; flex-shrink: 0; }
.sidebar-lesson-text { flex: 1; line-height: 1.3; }
.sidebar-duration { font-size: 0.7rem; color: rgba(255,255,255,0.3); white-space: nowrap; }

/* ----- Admin Panel ----- */
.admin-body { background: var(--bg); }

.admin-layout {
  display: flex;
  min-height: calc(100vh - var(--header-h));
}

.admin-sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--card-bg);
  border-right: 1px solid var(--border);
  padding: 20px 0;
}

.admin-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 20px;
  color: var(--text);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: background 0.1s;
  border-left: 3px solid transparent;
}
.admin-nav-item:hover { background: var(--bg); text-decoration: none; }
.admin-nav-item.active {
  background: var(--primary-light);
  color: var(--primary);
  border-left-color: var(--primary);
  font-weight: 700;
}

.admin-main {
  flex: 1;
  padding: 28px;
  min-width: 0;
  overflow-y: auto;
}

.admin-page-title {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--primary);
  margin-bottom: 20px;
}

/* Admin table */
.admin-table-wrap {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}
.admin-table th {
  background: var(--bg);
  padding: 10px 16px;
  text-align: left;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.admin-table td {
  padding: 11px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
.admin-table tr:last-child td { border-bottom: none; }
.admin-table tr:hover td { background: var(--bg); }

/* Admin toolbar */
.admin-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.admin-search {
  flex: 1;
  max-width: 300px;
  padding: 8px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-family: inherit;
}
.admin-search:focus { outline: none; border-color: var(--primary); }

/* Inline ID edit fields */
.id-input {
  width: 140px;
  padding: 5px 8px;
  border: 1.5px solid var(--border);
  border-radius: 5px;
  font-size: 0.8rem;
  font-family: monospace;
  color: var(--text);
}
.id-input:focus { outline: none; border-color: var(--primary); }

.id-status { font-size: 1rem; }

/* Admin accordion for courses */
.admin-course-block {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 12px;
  overflow: hidden;
}

.admin-course-header {
  padding: 14px 20px;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  border: none;
  width: 100%;
  text-align: left;
  font-size: 0.95rem;
}

.admin-section-block { border-bottom: 1px solid var(--border); }
.admin-section-header {
  padding: 10px 20px;
  background: var(--bg);
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  border: none;
  width: 100%;
  text-align: left;
  font-size: 0.875rem;
  color: var(--text);
}
.admin-section-header:hover { background: #efefef; }
.admin-section-body { display: none; }
.admin-section-body.open { display: block; }

/* Pagination */
.pagination {
  display: flex;
  gap: 4px;
  margin-top: 16px;
  align-items: center;
}
.page-link {
  padding: 6px 12px;
  border-radius: 5px;
  border: 1.5px solid var(--border);
  font-size: 0.8rem;
  color: var(--text);
  text-decoration: none;
  background: #fff;
}
.page-link:hover { border-color: var(--primary); color: var(--primary); }
.page-link.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* Status badge */
.status-active   { color: var(--success); font-weight: 600; }
.status-inactive { color: var(--text-muted); }

/* Misc utils */
.text-muted  { color: var(--text-muted); }
.text-danger { color: var(--danger); }
.text-center { text-align: center; }
.mt-16       { margin-top: 16px; }
.mt-24       { margin-top: 24px; }
.flex        { display: flex; }
.items-center { align-items: center; }
.gap-8       { gap: 8px; }
.gap-12      { gap: 12px; }

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

/* Tablet: 640–1023px */
@media (max-width: 1023px) {
  .course-grid { grid-template-columns: repeat(2, 1fr); }

  .lesson-sidebar { width: 280px; }

  .header-email-hide { display: none; }

  .admin-sidebar { width: 180px; }
}

/* Mobile: <640px */
@media (max-width: 639px) {

  /* ── Global ─────────────────────────────────────────── */
  html { font-size: 16px; } /* prevent Safari auto-zoom */
  :root { --header-h: 52px; }

  .container, .container-narrow { padding: 0 16px; }
  .main-content { padding: 16px 0; }

  /* ── Header ─────────────────────────────────────────── */
  .site-header {
    padding: 0 14px;
    gap: 8px;
    height: 52px;
  }
  .header-logo { font-size: 1rem; }
  .breadcrumb  { display: none; }
  .header-email { display: none; }

  /* ── Buttons — bigger tap targets ───────────────────── */
  .btn { padding: 11px 18px; font-size: 0.875rem; min-height: 44px; }
  .btn-sm { padding: 8px 14px; font-size: 0.8rem; min-height: 38px; }
  .btn-block { width: 100%; }

  /* ── Login page ─────────────────────────────────────── */
  .login-card {
    padding: 28px 20px;
    border-radius: var(--radius);
  }
  .login-title { font-size: 1.35rem; }

  /* ── Course grid ─────────────────────────────────────── */
  .course-grid { grid-template-columns: 1fr; gap: 14px; }

  /* ── Lesson page ─────────────────────────────────────── */
  .lesson-layout {
    flex-direction: column;
    min-height: unset;        /* don't force full-screen height */
  }

  /* Main column: auto height, scroll naturally */
  .lesson-main {
    height: auto;
    overflow: visible;
    flex: none;
  }

  /* Info bar above the video */
  .lesson-info-bar {
    padding: 8px 12px;
    gap: 6px;
    flex-wrap: wrap;
  }
  .lesson-title-h2 {
    font-size: 0.85rem;
    white-space: normal;       /* allow wrap on small screens */
  }
  .lesson-meta-text { font-size: 0.75rem; }

  /* Nav buttons in info bar */
  .lesson-nav-inline { gap: 6px; }
  .lesson-nav-inline .btn { padding: 7px 10px; font-size: 0.75rem; min-height: 36px; }

  /* Fullscreen button */
  .btn-fullscreen { width: 34px; height: 34px; }

  /* Video player — 16:9 via padding-top trick (most reliable cross-browser) */
  .player-wrapper {
    flex: none !important;
    position: relative !important;
    width: 100%;
    height: 0 !important;           /* height comes from padding-top */
    padding-top: 56.25%;            /* 9 / 16 = 56.25% → exact 16:9 */
    min-height: unset !important;
    overflow: visible;
  }
  /* player-container fills the padded space absolutely */
  .player-container {
    position: absolute !important;
    top: 0; left: 0;
    width: 100%;
    height: 100% !important;
  }

  /* Autoplay overlay */
  .autoplay-box {
    padding: 20px 16px;
    width: 90%;
  }
  .autoplay-box h3 { font-size: 1rem; }
  .autoplay-actions { flex-direction: column; gap: 8px; }
  .autoplay-actions .btn { width: 100%; }

  /* Sidebar becomes full-width panel below video */
  .lesson-sidebar {
    width: 100%;
    height: auto;
    max-height: none;
    position: static;
    border-left: none;
    border-top: 1px solid #2a2a2a;
    overflow-y: visible;
  }

  /* Sidebar section rows — bigger tap targets */
  .sidebar-section-btn { padding: 14px 16px; font-size: 0.9rem; }
  .sidebar-lesson-item a { padding: 10px 16px 10px 32px; font-size: 0.85rem; }

  /* ── Admin panel ─────────────────────────────────────── */
  .admin-layout { flex-direction: column; }
  .admin-sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 0;
    display: flex;
    flex-wrap: wrap;
  }
  .admin-nav-item {
    border-left: none;
    border-bottom: 3px solid transparent;
    padding: 12px 16px;
    font-size: 0.85rem;
  }
  .admin-nav-item.active {
    border-bottom-color: var(--primary);
    border-left-color: transparent;
  }
  .admin-main { padding: 14px; }

  /* Admin table: allow horizontal scroll */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

  /* ── Modals ─────────────────────────────────────────── */
  .modal-box {
    width: 94%;
    padding: 24px 18px;
    max-height: 90vh;
    overflow-y: auto;
  }

  /* ── Forms ───────────────────────────────────────────── */
  .form-group { margin-bottom: 14px; }
  .form-control { font-size: 1rem; padding: 10px 12px; min-height: 44px; }
  label { font-size: 0.875rem; }

  /* ── Footer ─────────────────────────────────────────── */
  .footer-inner { flex-direction: column; align-items: flex-start; gap: 6px; padding: 0 16px; }
  .access-chip { display: none; } /* hide chip on very small screens, tooltip not usable */
}
