/* =====================================================================
   StudyTube — Full theme + components stylesheet
   ===================================================================== */
:root {
  --primary: #2563EB;
  --primary-2: #60A5FA;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.08);
  --shadow-md: 0 6px 24px rgba(0,0,0,.15);
  --shadow-lg: 0 20px 60px rgba(0,0,0,.25);
  --transition: 180ms cubic-bezier(.2,.7,.3,1);
}
html[data-theme="dark"] {
  --bg: #0a0e1a;
  --bg-2: #0f1424;
  --surface: #131a2e;
  --surface-2: #1a2240;
  --border: rgba(255,255,255,.08);
  --text: #e7ecf5;
  --muted: #93a0bd;
  --inv: #0a0e1a;
  --glass: rgba(20,28,48,.55);
  --glass-border: rgba(255,255,255,.08);
  --danger: #ef4444;
  --success: #22c55e;
}
html[data-theme="light"] {
  --bg: #f6f8fc;
  --bg-2: #ffffff;
  --surface: #ffffff;
  --surface-2: #f1f4fa;
  --border: rgba(15,23,42,.08);
  --text: #0f172a;
  --muted: #64748b;
  --inv: #ffffff;
  --glass: rgba(255,255,255,.7);
  --glass-border: rgba(15,23,42,.08);
  --danger: #dc2626;
  --success: #16a34a;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
a { color: var(--primary-2); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }
input, button, textarea, select { font: inherit; color: inherit; }

.icon { width: 20px; height: 20px; fill: none; stroke: currentColor; flex-shrink: 0; }

/* Layout */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 240px; background: var(--bg-2); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 18px 14px; gap: 14px;
  position: sticky; top: 0; height: 100vh; transition: transform var(--transition);
  z-index: 30;
}
.sidebar .brand { display: flex; align-items: center; gap: 10px; padding: 4px 6px; font-weight: 800; font-size: 18px; }
.sidebar .brand-logo { width: 32px; height: 32px; }
.side-nav { display: flex; flex-direction: column; gap: 2px; }
.nav-link {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--radius-sm);
  color: var(--muted); transition: background var(--transition), color var(--transition);
}
.nav-link:hover { background: var(--surface); color: var(--text); text-decoration: none; }
.nav-link.active { background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #fff; }
.nav-link.active .icon { color: #fff; }
.side-foot { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 10px; border-top: 1px solid var(--border); }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: linear-gradient(135deg, var(--primary), var(--primary-2)); display: grid; place-items: center; color: #fff; font-weight: 700; }
.who-name { font-weight: 600; font-size: 14px; }
.who-out { font-size: 12px; color: var(--muted); }
.sidebar-backdrop { display: none; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px;
  padding: 12px 18px; background: var(--glass); backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.topbar-title { margin: 0; font-size: 16px; font-weight: 700; flex: 1; }
.icon-btn { background: transparent; border: 1px solid var(--border); color: var(--text); width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; cursor: pointer; transition: background var(--transition); }
.icon-btn:hover { background: var(--surface); }
.menu-btn { display: none; }
.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: block; }
html[data-theme="light"] .theme-toggle .icon-sun { display: block; }
html[data-theme="light"] .theme-toggle .icon-moon { display: none; }

.page { padding: 22px 24px 120px; max-width: 1200px; width: 100%; margin: 0 auto; }

/* Hero */
.hero { padding: 18px 22px; border-radius: var(--radius); background: linear-gradient(135deg, rgba(37,99,235,.18), rgba(96,165,250,.08)); border: 1px solid var(--border); margin-bottom: 18px; }
.hero h2 { margin: 0 0 4px; font-size: 22px; }
.hero p { margin: 0; color: var(--muted); font-size: 14px; }

/* Stats grid */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 22px; }
.stat { padding: 14px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); display: flex; flex-direction: column; gap: 4px; transition: transform var(--transition); }
.stat:hover { transform: translateY(-2px); }
.stat-icon { width: 36px; height: 36px; border-radius: 10px; background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #fff; display: grid; place-items: center; margin-bottom: 4px; }
.stat-label { font-size: 12px; color: var(--muted); }
.stat-value { font-size: 22px; font-weight: 800; }

.section-head { display: flex; align-items: center; justify-content: space-between; margin: 22px 0 12px; }
.section-head h3 { margin: 0; font-size: 16px; }

.quick-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.quick { padding: 14px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); display: flex; align-items: center; gap: 12px; color: inherit; transition: transform var(--transition), background var(--transition); }
.quick:hover { transform: translateY(-2px); text-decoration: none; background: var(--surface-2); }
.quick-icon { width: 40px; height: 40px; border-radius: 10px; background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #fff; display: grid; place-items: center; }
.quick-title { font-weight: 700; font-size: 14px; }
.quick-sub { font-size: 12px; color: var(--muted); }

/* Cards / video grid */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.video-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.video-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; color: inherit; transition: transform var(--transition); display: flex; flex-direction: column; }
.video-card:hover { transform: translateY(-2px); text-decoration: none; }
.video-thumb { position: relative; aspect-ratio: 16/9; background: #000; }
.video-thumb img { width: 100%; height: 100%; object-fit: cover; }
.video-cat { position: absolute; top: 8px; left: 8px; background: rgba(0,0,0,.6); color: #fff; padding: 2px 8px; border-radius: 999px; font-size: 11px; }
.play-ov { position: absolute; inset: 0; display: grid; place-items: center; color: #fff; opacity: 0; transition: opacity var(--transition); background: rgba(0,0,0,.35); }
.play-ov .icon { width: 48px; height: 48px; }
.video-card:hover .play-ov { opacity: 1; }
.video-info { padding: 10px 12px; }
.video-title { font-weight: 600; font-size: 14px; margin-bottom: 4px; line-height: 1.35; }
.video-meta { font-size: 12px; color: var(--muted); display: flex; gap: 8px; }

/* Notes */
.note-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; color: inherit; display: flex; flex-direction: column; gap: 6px; transition: transform var(--transition); }
.note-card:hover { transform: translateY(-2px); text-decoration: none; }
.note-title { font-weight: 700; font-size: 14px; }
.note-body { color: var(--muted); font-size: 13px; max-height: 4.2em; overflow: hidden; line-height: 1.4; }
.note-meta { font-size: 11px; color: var(--muted); display: flex; gap: 10px; margin-top: 4px; }

/* Forms */
.form-group { margin-bottom: 12px; }
.label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.input, .textarea, .select {
  width: 100%; padding: 10px 12px; border-radius: var(--radius-sm);
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  transition: border var(--transition), box-shadow var(--transition);
}
.input:focus, .textarea:focus, .select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.18); }
.textarea { min-height: 110px; resize: vertical; }
.input-icon { position: relative; }
.input-icon .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.input-icon .input { padding-left: 40px; }

.btn { display: inline-flex; align-items: center; gap: 8px; padding: 10px 16px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; font-weight: 600; transition: background var(--transition), transform var(--transition); }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn-primary { background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #fff; border: none; }
.btn-primary:hover { transform: translateY(-1px); }
.btn-danger { background: var(--danger); color: #fff; border: none; }
.btn-block { width: 100%; justify-content: center; }
.btn-sm { padding: 6px 10px; font-size: 13px; }

.alert { padding: 10px 14px; border-radius: var(--radius-sm); margin-bottom: 12px; font-size: 14px; border: 1px solid var(--border); }
.alert-error { background: rgba(239,68,68,.12); color: #fca5a5; border-color: rgba(239,68,68,.3); }
.alert-success { background: rgba(34,197,94,.12); color: #86efac; border-color: rgba(34,197,94,.3); }

/* Auth */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(circle at 20% 10%, rgba(37,99,235,.18), transparent 40%), radial-gradient(circle at 80% 80%, rgba(96,165,250,.12), transparent 50%), var(--bg); }
.auth-card { width: 100%; max-width: 420px; padding: 28px; }
.auth-card h1 { margin: 6px 0 4px; font-size: 22px; }
.auth-card .sub { margin: 0 0 16px; color: var(--muted); font-size: 14px; }
.auth-brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 18px; margin-bottom: 14px; }
.auth-brand img { width: 36px; height: 36px; }
.auth-foot { margin-top: 14px; text-align: center; color: var(--muted); font-size: 13px; }
.glass { background: var(--glass); backdrop-filter: blur(14px); border: 1px solid var(--glass-border); border-radius: var(--radius); }

/* Empty state */
.empty { padding: 30px; text-align: center; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 8px; border: 1px dashed var(--border); border-radius: var(--radius); }
.empty .icon { width: 36px; height: 36px; opacity: .6; }
.empty h4 { margin: 0; color: var(--text); }

/* Bottom nav (mobile) */
.bottom-nav { display: none; }

/* Player */
.player-wrap { position: relative; aspect-ratio: 16/9; background: #000; border-radius: var(--radius); overflow: hidden; margin-bottom: 14px; }
.player-wrap iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.player-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }
.player-meta h2 { margin: 0; font-size: 18px; flex: 1 1 auto; min-width: 200px; }
.cat { background: var(--surface-2); padding: 3px 10px; border-radius: 999px; font-size: 12px; color: var(--muted); }

/* Video info panel */
.info-panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.info-row { display: grid; grid-template-columns: 130px 1fr; gap: 10px; font-size: 14px; padding: 6px 0; border-top: 1px solid var(--border); }
.info-row:first-of-type { border-top: 0; }
.info-row .k { color: var(--muted); }

/* Description panel */
.desc-panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 16px; overflow: hidden; }
.desc-head { padding: 12px 16px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--border); }
.desc-head h3 { margin: 0; font-size: 14px; }
.desc-body { padding: 14px 16px; max-height: 140px; overflow: hidden; position: relative; transition: max-height var(--transition); white-space: pre-wrap; font-size: 14px; line-height: 1.55; color: var(--text); }
.desc-body.expanded { max-height: 4000px; }
.desc-body::after { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 40px; background: linear-gradient(to bottom, transparent, var(--surface)); pointer-events: none; }
.desc-body.expanded::after { display: none; }
.desc-body a { color: var(--primary-2); word-break: break-all; }
.desc-body .drive-link { display: inline-flex; align-items: center; gap: 6px; padding: 2px 8px; border-radius: 6px; background: rgba(37,99,235,.12); border: 1px solid rgba(37,99,235,.25); color: var(--primary-2); }
.desc-foot { padding: 10px 16px; display: flex; gap: 8px; flex-wrap: wrap; border-top: 1px solid var(--border); }

.link-list { display: flex; flex-direction: column; gap: 8px; padding: 12px 16px; }
.link-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; background: var(--surface-2); border-radius: var(--radius-sm); font-size: 13px; }
.link-row a { color: var(--primary-2); flex: 1; min-width: 0; word-break: break-all; }
.link-row .icon-btn { width: 30px; height: 30px; }

/* Floating mini player */
.floating-player {
  position: fixed; bottom: 16px; right: 16px; width: 320px; max-width: calc(100% - 24px);
  background: #000; border-radius: 12px; overflow: hidden; box-shadow: var(--shadow-lg);
  z-index: 80; display: none; user-select: none; touch-action: none;
}
.floating-player.active { display: block; }
.floating-player .fp-head { display: flex; align-items: center; gap: 6px; padding: 6px 8px; background: rgba(0,0,0,.85); cursor: grab; }
.floating-player .fp-head:active { cursor: grabbing; }
.floating-player .fp-title { color: #fff; font-size: 12px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.floating-player .fp-btn { background: transparent; border: 0; color: #fff; width: 26px; height: 26px; border-radius: 6px; cursor: pointer; display: grid; place-items: center; }
.floating-player .fp-btn:hover { background: rgba(255,255,255,.15); }
.floating-player .fp-video { aspect-ratio: 16/9; }
.floating-player .fp-video iframe { width: 100%; height: 100%; border: 0; display: block; }
.floating-player.minimized .fp-video { display: none; }

.player-actions { display: flex; gap: 8px; margin-left: auto; flex-wrap: wrap; }

/* Tables (admin) */
.table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.table th, .table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); font-size: 14px; vertical-align: middle; }
.table th { background: var(--surface-2); font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.table tr:last-child td { border-bottom: 0; }
.table .row-actions { display: flex; gap: 6px; }
.badge { display: inline-flex; padding: 2px 8px; border-radius: 999px; font-size: 11px; background: var(--surface-2); color: var(--muted); }
.badge.ok { background: rgba(34,197,94,.12); color: #86efac; }
.badge.no { background: rgba(239,68,68,.12); color: #fca5a5; }

/* Admin sidebar accent */
.sidebar.admin .brand { color: var(--primary-2); }
.sidebar.admin .brand-logo { filter: drop-shadow(0 0 12px rgba(37,99,235,.5)); }

/* Developer footer */
.dev-footer { padding: 24px 16px 100px; display: grid; place-items: center; }
.dev-foot-inner { padding: 14px 18px; max-width: 720px; width: 100%; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; justify-content: center; text-align: center; }
.dev-brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 14px; }
.dev-brand img { width: 22px; height: 22px; }
.dev-info { display: flex; flex-direction: column; gap: 6px; align-items: center; flex: 1; min-width: 200px; }
.dev-name { font-size: 13px; color: var(--muted); }
.dev-name strong { color: var(--text); }
.dev-links { display: flex; gap: 8px; }
.dev-links a { width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; color: var(--muted); border: 1px solid var(--border); transition: all var(--transition); }
.dev-links a:hover { color: #fff; background: linear-gradient(135deg, var(--primary), var(--primary-2)); border-color: transparent; transform: translateY(-2px); }
.dev-copy { font-size: 11px; color: var(--muted); width: 100%; }

/* Responsive */
@media (max-width: 900px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .quick-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 760px) {
  .sidebar { position: fixed; left: 0; top: 0; transform: translateX(-100%); box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 25; opacity: 0; pointer-events: none; transition: opacity var(--transition); }
  .sidebar.open + .sidebar-backdrop { opacity: 1; pointer-events: auto; }
  .menu-btn { display: grid; }
  .page { padding: 16px 14px 140px; }
  .bottom-nav {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
    background: var(--glass); backdrop-filter: blur(14px); border-top: 1px solid var(--border);
    padding: 6px 4px 10px;
  }
  .bn-item { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 4px; color: var(--muted); font-size: 11px; border-radius: 8px; }
  .bn-item.active { color: var(--primary-2); }
  .bn-item:hover { text-decoration: none; }
  .dev-footer { padding: 18px 12px 110px; }
}
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .info-row { grid-template-columns: 100px 1fr; }
}

/* Loading skeleton */
.skeleton { background: linear-gradient(90deg, var(--surface), var(--surface-2), var(--surface)); background-size: 200% 100%; animation: skel 1.4s infinite; border-radius: var(--radius-sm); }
@keyframes skel { 0%{background-position: 200% 0;} 100%{background-position: -200% 0;} }

/* Toast */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--surface); border: 1px solid var(--border); padding: 10px 16px; border-radius: 999px; font-size: 13px; opacity: 0; pointer-events: none; transition: all var(--transition); z-index: 200; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Toolbar / chips / modal / fab — used by notes, driving, dua, history */
.toolbar { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.toolbar .input-icon { flex: 1; min-width: 200px; }
.chip-row { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; overflow-x: auto; }
.chip { padding: 6px 12px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); font-size: 13px; color: var(--muted); white-space: nowrap; }
.chip:hover { text-decoration: none; background: var(--surface-2); }
.chip.active { background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #fff; border-color: transparent; }
.fab { position: fixed; right: 18px; bottom: 90px; width: 56px; height: 56px; border-radius: 50%; background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #fff; display: grid; place-items: center; border: 0; box-shadow: var(--shadow-md); z-index: 50; cursor: pointer; }
.fab .icon { width: 24px; height: 24px; color: #fff; }
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: none; align-items: center; justify-content: center; padding: 20px; z-index: 100; }
.modal-bg.open { display: flex; }
.modal { background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; width: 100%; max-width: 480px; max-height: 90vh; overflow-y: auto; }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.modal-head h3 { margin: 0; }
.video-actions { display: inline-flex; gap: 4px; margin-left: auto; }
.video-actions button { background: transparent; border: 0; color: var(--muted); cursor: pointer; padding: 4px; border-radius: 6px; }
.video-actions button:hover { color: var(--text); background: var(--surface-2); }
.fav.on .icon { fill: #fbbf24; color: #fbbf24; }
.video-meta { align-items: center; }

/* ===== App Splash ===== */
.app-splash{position:fixed;inset:0;z-index:9999;display:grid;place-items:center;background:radial-gradient(ellipse at center,#1E3A8A 0%,#0F172A 70%);transition:opacity .45s ease,visibility .45s ease}
.app-splash.hide{opacity:0;visibility:hidden;pointer-events:none}
.splash-card{display:flex;flex-direction:column;align-items:center;gap:14px;animation:splashIn .6s ease both}
.splash-icon{width:96px;height:96px;border-radius:24px;box-shadow:0 20px 60px rgba(37,99,235,.45)}
.splash-name{color:#fff;font:800 26px/1.1 Inter,system-ui,sans-serif;letter-spacing:-.02em}
.splash-tag{color:#93C5FD;font:500 14px/1 Inter,system-ui,sans-serif}
.splash-bar{margin-top:12px;width:160px;height:3px;border-radius:99px;background:rgba(255,255,255,.12);overflow:hidden}
.splash-bar span{display:block;height:100%;width:40%;background:linear-gradient(90deg,#2563EB,#60A5FA);border-radius:99px;animation:splashBar 1.2s ease-in-out infinite}
@keyframes splashIn{from{opacity:0;transform:translateY(8px)}to{opacity:1;transform:none}}
@keyframes splashBar{0%{transform:translateX(-100%)}100%{transform:translateX(300%)}}
@media (prefers-reduced-motion:reduce){.splash-bar span{animation:none}}

/* ===== Skeleton ===== */
.skeleton{background:linear-gradient(90deg,rgba(255,255,255,.04),rgba(255,255,255,.10),rgba(255,255,255,.04));background-size:200% 100%;animation:sk 1.2s ease-in-out infinite;border-radius:12px}
[data-theme="light"] .skeleton{background:linear-gradient(90deg,#eef0f4,#f6f7fa,#eef0f4);background-size:200% 100%}
@keyframes sk{0%{background-position:200% 0}100%{background-position:-200% 0}}
