/* ═══════════════════════════════════════════
   LearnSwipe — App Styles
   Mobile-first · Dark theme · RTL Arabic
   ═══════════════════════════════════════════ */

:root {
  --bg:         #0a0a0f;
  --bg-card:    #141420;
  --bg-glass:   rgba(20, 20, 32, 0.85);
  --surface:    #1c1c2e;
  --border:     rgba(255,255,255,0.08);
  --text:       #f0f0f5;
  --text-dim:   rgba(240,240,245,0.55);
  --accent:     #6C5CE7;
  --accent2:    #00CEC9;
  --danger:     #ff6b6b;
  --success:    #00b894;
  --gradient:   linear-gradient(135deg, #6C5CE7 0%, #00CEC9 100%);
  --radius:     14px;
  --radius-sm:  8px;
  --safe-top:   env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --nav-h:      64px;
}

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

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: 'Tajawal', sans-serif;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

/* ─── SCREENS ──────────────────────────── */
.screen {
  position: fixed; inset: 0;
  display: none;
  flex-direction: column;
}
.screen.active { display: flex; }

/* ─── AUTH SCREEN ──────────────────────── */
.auth-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 40px 24px;
  background: var(--bg);
}

.auth-brand {
  text-align: center;
  margin-bottom: 48px;
}
.brand-icon svg { width: 72px; height: 72px; }
.auth-brand h1 {
  font-size: 32px;
  font-weight: 800;
  margin-top: 16px;
  background: var(--gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.brand-tagline {
  color: var(--text-dim);
  font-size: 15px;
  margin-top: 8px;
}

.auth-form {
  width: 100%;
  max-width: 360px;
}
.auth-form.hidden { display: none; }

.input-group { margin-bottom: 14px; }
.input-group input {
  width: 100%;
  padding: 14px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  outline: none;
  transition: border-color 0.2s;
}
.input-group input:focus {
  border-color: var(--accent);
}
.input-group input::placeholder { color: var(--text-dim); }

.btn-primary {
  width: 100%;
  padding: 14px;
  background: var(--gradient);
  border: none;
  border-radius: var(--radius-sm);
  color: #fff;
  font-family: inherit;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  margin-top: 6px;
  transition: opacity 0.2s;
}
.btn-primary:active { opacity: 0.85; }

.auth-switch {
  text-align: center;
  margin-top: 18px;
  color: var(--text-dim);
  font-size: 14px;
}
.auth-switch a { color: var(--accent2); text-decoration: none; font-weight: 600; }

.btn-ghost {
  margin-top: 24px;
  background: none;
  border: 1px solid var(--border);
  padding: 10px 28px;
  border-radius: 100px;
  color: var(--text-dim);
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
  transition: border-color 0.2s;
}
.btn-ghost:hover { border-color: var(--accent); color: var(--text); }

/* ─── CATEGORY BAR ─────────────────────── */
.category-bar {
  position: fixed;
  top: var(--safe-top);
  left: 0; right: 0;
  z-index: 100;
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  background: linear-gradient(to bottom, rgba(10,10,15,0.95) 0%, transparent 100%);
}
.category-bar::-webkit-scrollbar { display: none; }

.cat-tab {
  flex-shrink: 0;
  padding: 7px 18px;
  border-radius: 100px;
  border: 1px solid var(--border);
  background: var(--bg-glass);
  color: var(--text-dim);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}
.cat-tab.active {
  background: var(--gradient);
  border-color: transparent;
  color: #fff;
  font-weight: 700;
}

/* ─── FEED CONTAINER ───────────────────── */
.feed-container {
  position: fixed;
  inset: 0;
  overflow: hidden;
}

.feed-track {
  height: 100%;
  transition: transform 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

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

.video-card iframe,
.video-card .yt-placeholder {
  width: 100%;
  height: 100%;
  border: none;
}

.yt-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background-size: cover;
  background-position: center;
  cursor: pointer;
}
.yt-placeholder::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.4);
}
.yt-play-btn {
  position: relative;
  z-index: 2;
  width: 64px; height: 64px;
  background: rgba(255,255,255,0.2);
  backdrop-filter: blur(10px);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.yt-play-btn::after {
  content: '';
  display: block;
  width: 0; height: 0;
  border-top: 12px solid transparent;
  border-bottom: 12px solid transparent;
  border-left: 20px solid #fff;
  margin-left: 4px;
}

/* ─── VIDEO OVERLAY ────────────────────── */
.video-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding-bottom: calc(var(--nav-h) + var(--safe-bottom) + 16px);
}

.overlay-actions {
  position: absolute;
  left: 16px;
  bottom: calc(var(--nav-h) + var(--safe-bottom) + 100px);
  display: flex;
  flex-direction: column;
  gap: 20px;
  pointer-events: auto;
}

.action-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  filter: drop-shadow(0 2px 8px rgba(0,0,0,0.5));
}
.action-btn svg { width: 28px; height: 28px; }
.action-btn span { font-size: 12px; font-weight: 600; }
.action-btn.liked svg { fill: var(--danger); stroke: var(--danger); }
.action-btn.bookmarked svg { fill: var(--accent2); stroke: var(--accent2); }

.overlay-info {
  padding: 0 16px;
  pointer-events: auto;
}
.video-title {
  font-size: 17px;
  font-weight: 700;
  text-shadow: 0 2px 12px rgba(0,0,0,0.7);
  line-height: 1.5;
  max-width: calc(100% - 70px);
}
.video-meta {
  font-size: 13px;
  color: rgba(255,255,255,0.7);
  margin-top: 4px;
  text-shadow: 0 1px 6px rgba(0,0,0,0.5);
}

.video-progress {
  width: 100%;
  height: 3px;
  background: rgba(255,255,255,0.15);
  border-radius: 2px;
  margin-top: 12px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--gradient);
  border-radius: 2px;
  transition: width 0.3s linear;
}

/* ─── ATTENTION INDICATOR ──────────────── */
.attention-indicator {
  position: absolute;
  top: calc(var(--safe-top) + 56px);
  right: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}
.attention-indicator.hidden { display: none; }
.attention-eye { font-size: 18px; }
.attention-bar {
  width: 60px; height: 6px;
  background: rgba(255,255,255,0.15);
  border-radius: 3px;
  overflow: hidden;
}
.attention-fill {
  height: 100%;
  width: 80%;
  background: var(--success);
  border-radius: 3px;
  transition: width 0.5s;
}

/* ─── BOTTOM NAV ───────────────────────── */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: calc(var(--nav-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-around;
  align-items: center;
  z-index: 200;
}

.nav-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 4px 12px;
  transition: color 0.2s;
}
.nav-btn svg { width: 22px; height: 22px; }
.nav-btn span { font-size: 11px; font-weight: 500; }
.nav-btn.active { color: var(--accent2); }

/* ─── STATS SCREEN ─────────────────────── */
.stats-container {
  padding: 24px 20px;
  padding-top: calc(var(--safe-top) + 20px);
  overflow-y: auto;
  height: 100%;
  padding-bottom: calc(var(--nav-h) + var(--safe-bottom) + 20px);
}
.stats-container h2 {
  font-size: 22px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}
.stat-card h3 {
  font-size: 14px;
  color: var(--text-dim);
  margin-bottom: 8px;
}
.stat-value {
  font-size: 32px;
  font-weight: 800;
  background: var(--gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.stat-unit { font-size: 14px; color: var(--text-dim); margin-right: 4px; }

.mastery-bar {
  width: 100%; height: 8px;
  background: var(--border);
  border-radius: 4px;
  margin-top: 8px;
  overflow: hidden;
}
.mastery-fill {
  height: 100%;
  background: var(--gradient);
  border-radius: 4px;
  transition: width 0.6s ease;
}

/* ─── CAMERA PREVIEW ───────────────────── */
.camera-preview {
  position: fixed;
  top: calc(var(--safe-top) + 56px);
  left: 16px;
  width: 80px; height: 100px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  border: 2px solid var(--accent);
  z-index: 150;
  transform: scaleX(-1);
}
.camera-preview.hidden { display: none; }

/* ─── LOADING ──────────────────────────── */
.feed-loader {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 300;
  background: var(--bg);
}
.feed-loader.active { display: flex; }
.pulse-ring {
  width: 48px; height: 48px;
  border: 3px solid var(--accent);
  border-radius: 50%;
  animation: pulse 1.2s ease-in-out infinite;
}
@keyframes pulse {
  0% { transform: scale(0.8); opacity: 1; }
  100% { transform: scale(1.6); opacity: 0; }
}

/* ─── TOAST ────────────────────────────── */
.toast {
  position: fixed;
  top: calc(var(--safe-top) + 16px);
  left: 50%;
  transform: translateX(-50%) translateY(-100px);
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 12px 24px;
  border-radius: 100px;
  font-size: 14px;
  font-weight: 500;
  z-index: 999;
  transition: transform 0.3s ease;
  pointer-events: none;
}
.toast.show {
  transform: translateX(-50%) translateY(0);
}

/* ─── UTILITIES ────────────────────────── */
.hidden { display: none !important; }

/* Small screen adjustments */
@media (max-height: 680px) {
  .overlay-actions { bottom: calc(var(--nav-h) + 60px); gap: 14px; }
  .action-btn svg { width: 24px; height: 24px; }
}
