/* ===== VideoEmbed - Stylesheet utama ===== */

:root {
  --bg: #090b12;
  --secondary: #151827;
  --card: #1b2030;
  --primary: #8b5cf6;
  --accent: #6366f1;
  --text: #e8eaf2;
  --muted: #8d93a8;
  --border: #272c42;
  --success: #22c55e;
  --danger: #ef4444;
  --warning: #f59e0b;
  --radius: 14px;
  --radius-sm: 10px;
  --sidebar-w: 240px;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
  --gradient: linear-gradient(135deg, var(--primary), var(--accent));
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: #a78bfa; }
img, video { max-width: 100%; display: block; }
h1, h2, h3 { margin: 0 0 8px; line-height: 1.25; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 12px; }
.muted { color: var(--muted); }
.hidden { display: none !important; }
.icon { width: 20px; height: 20px; flex-shrink: 0; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ===== Layout aplikasi ===== */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  background: var(--secondary);
  border-right: 1px solid var(--border);
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 50;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 1.2rem;
  color: var(--text);
  padding: 4px 8px 18px;
}
.brand:hover { color: var(--text); }
.brand-logo {
  width: 34px; height: 34px;
  border-radius: 10px;
  background: var(--gradient);
  display: grid; place-items: center;
  color: #fff;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-weight: 500;
  transition: background .2s, color .2s;
}
.nav-link:hover { background: rgba(139, 92, 246, 0.1); color: var(--text); }
.nav-link.active { background: rgba(139, 92, 246, 0.18); color: #fff; }
.nav-spacer { flex: 1; }

.main {
  flex: 1;
  margin-left: var(--sidebar-w);
  padding: 28px 32px 40px;
  min-width: 0;
}
.container { max-width: 1100px; margin: 0 auto; }

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}
.page-header p { margin: 0; color: var(--muted); }

.bottom-nav {
  display: none;
  position: fixed;
  inset: auto 0 0 0;
  background: var(--secondary);
  border-top: 1px solid var(--border);
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  z-index: 50;
  justify-content: space-around;
}
.bottom-nav a {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  font-size: .7rem;
  color: var(--muted);
  padding: 4px 12px;
  border-radius: 10px;
}
.bottom-nav a.active { color: var(--primary); }

/* ===== Tombol ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 20px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font: inherit;
  font-weight: 600;
  font-size: .92rem;
  cursor: pointer;
  color: #fff;
  background: var(--gradient);
  transition: transform .15s, opacity .2s, box-shadow .2s;
  text-decoration: none;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(139, 92, 246, 0.35); color: #fff; }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-secondary { background: var(--card); border-color: var(--border); color: var(--text); }
.btn-secondary:hover { box-shadow: none; border-color: var(--primary); color: var(--text); }
.btn-danger { background: rgba(239, 68, 68, 0.12); border-color: rgba(239, 68, 68, 0.4); color: #f87171; }
.btn-danger:hover { background: var(--danger); color: #fff; box-shadow: none; }
.btn-sm { padding: 7px 12px; font-size: .8rem; }
.btn-block { width: 100%; }
.btn:focus-visible, .ctrl-btn:focus-visible, .nav-link:focus-visible, .bottom-nav a:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* ===== Card & statistik ===== */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.card + .card { margin-top: 20px; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 28px;
}
.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.stat-icon {
  width: 46px; height: 46px;
  border-radius: 12px;
  background: rgba(139, 92, 246, 0.15);
  color: var(--primary);
  display: grid; place-items: center;
}
.stat-value { font-size: 1.5rem; font-weight: 800; line-height: 1.1; }
.stat-label { color: var(--muted); font-size: .85rem; }

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.section-head h2 { margin: 0; }

/* ===== Form ===== */
.form-group { margin-bottom: 16px; }
label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: 6px; color: var(--text); }
input[type="text"], input[type="password"], input[type="search"], input[type="number"], textarea, select {
  width: 100%;
  padding: 11px 14px;
  background: var(--secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font: inherit;
  font-size: .92rem;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.2);
}
textarea { resize: vertical; min-height: 80px; }

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  cursor: pointer;
  font-weight: 500;
}
.check-row input { width: 18px; height: 18px; accent-color: var(--primary); }

/* ===== Upload ===== */
.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  background: var(--secondary);
  padding: 44px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color .2s, background .2s;
}
.dropzone:hover, .dropzone.dragover { border-color: var(--primary); background: rgba(139, 92, 246, 0.08); }
.dropzone .icon { width: 44px; height: 44px; color: var(--primary); margin: 0 auto 12px; }
.dropzone p { margin: 0 0 4px; }

.upload-grid { display: grid; grid-template-columns: 1.2fr 1fr; gap: 20px; align-items: start; }
.preview-box { background: #000; border-radius: var(--radius-sm); overflow: hidden; aspect-ratio: 16 / 9; }
.preview-box video { width: 100%; height: 100%; object-fit: contain; }

.file-info { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 16px; }
.file-info div { background: var(--secondary); border-radius: var(--radius-sm); padding: 10px 14px; min-width: 0; }
.file-info span { display: block; font-size: .75rem; color: var(--muted); }
.file-info strong { display: block; font-size: .9rem; overflow-wrap: anywhere; }

.progress { height: 10px; background: var(--secondary); border-radius: 99px; overflow: hidden; }
.progress-bar { height: 100%; width: 0; background: var(--gradient); border-radius: 99px; transition: width .2s; }
.progress-text { display: flex; justify-content: space-between; font-size: .8rem; color: var(--muted); margin-top: 6px; }

/* ===== Library ===== */
.toolbar { display: flex; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.toolbar input { flex: 1; min-width: 200px; }
.toolbar select { width: auto; min-width: 150px; }

.video-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 18px; }

.video-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform .2s, border-color .2s;
}
.video-card:hover { transform: translateY(-3px); border-color: var(--primary); }

.video-thumb { position: relative; aspect-ratio: 16 / 9; background: #000; display: block; }
.video-thumb img { width: 100%; height: 100%; object-fit: cover; }
.video-duration {
  position: absolute;
  right: 8px; bottom: 8px;
  background: rgba(0, 0, 0, 0.75);
  color: #fff;
  font-size: .72rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 6px;
}
.video-info { padding: 14px; flex: 1; }
.video-title { font-weight: 600; font-size: .95rem; margin: 0 0 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.video-meta { font-size: .78rem; color: var(--muted); display: flex; gap: 10px; flex-wrap: wrap; }
.video-actions { display: flex; gap: 6px; flex-wrap: wrap; padding: 0 14px 14px; }

.empty-state { text-align: center; padding: 50px 20px; color: var(--muted); }
.empty-state .icon { width: 48px; height: 48px; margin: 0 auto 12px; opacity: .6; }

/* ===== Embed generator ===== */
.embed-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
.code-block { margin-bottom: 18px; }
.code-block-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.code-block-head strong { font-size: .88rem; }
.code-block textarea {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .78rem;
  min-height: 90px;
  color: #c4b5fd;
}
.size-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.embed-preview { background: #000; border-radius: var(--radius-sm); overflow: hidden; border: 1px solid var(--border); }
.embed-preview iframe { display: block; border: 0; width: 100%; }

/* ===== Modal ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 6, 12, 0.8);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 100;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  width: 100%;
  max-width: 640px;
  max-height: 92vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
  animation: pop .2s ease;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.modal-head h2 { margin: 0; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 8px; flex-wrap: wrap; }

/* ===== Toast ===== */
.toast-container {
  position: fixed;
  top: 16px; right: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 200;
  max-width: calc(100vw - 32px);
}
.toast {
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: .88rem;
  box-shadow: var(--shadow);
  animation: slideIn .25s ease;
}
.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }

/* ===== Spinner ===== */
.spinner {
  width: 36px; height: 36px;
  border: 3px solid rgba(255, 255, 255, 0.15);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
.loading-center { display: flex; justify-content: center; padding: 40px; }

/* ===== Login ===== */
.login-wrapper { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(circle at 50% 0%, rgba(139, 92, 246, 0.18), transparent 60%), var(--bg); }
.login-card { width: 100%; max-width: 400px; background: var(--card); border: 1px solid var(--border); border-radius: 18px; padding: 32px 26px; box-shadow: var(--shadow); }
.login-card .brand { justify-content: center; padding-bottom: 6px; }
.login-card p.muted { text-align: center; margin-bottom: 22px; }
.error-text { color: #f87171; font-size: .85rem; margin-bottom: 12px; min-height: 1.2em; }

/* ===== Landing (index.html) ===== */
.landing-nav { display: flex; align-items: center; justify-content: space-between; padding: 18px 24px; max-width: 1100px; margin: 0 auto; }
.hero { text-align: center; padding: 70px 20px 50px; max-width: 760px; margin: 0 auto; }
.hero h1 { font-size: clamp(2rem, 6vw, 3.2rem); font-weight: 800; }
.hero h1 span { background: var(--gradient); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero p { color: var(--muted); font-size: 1.05rem; }
.hero-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 24px; }
.feature-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; max-width: 1100px; margin: 0 auto; padding: 0 20px 60px; }
.feature { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; }
.feature .stat-icon { margin-bottom: 12px; }

/* ===== Halaman player (iframe) ===== */
.player-body { margin: 0; background: #000; height: 100vh; overflow: hidden; }
.player-container { position: relative; width: 100%; height: 100%; background: #000; overflow: hidden; user-select: none; -webkit-user-select: none; }
.player-container video { width: 100%; height: 100%; object-fit: contain; background: #000; }

.player-overlay { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(0, 0, 0, 0.35); pointer-events: none; }
.player-overlay.hidden { display: none; }
.player-message { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 20px; background: var(--bg); color: var(--muted); }
.player-message.hidden { display: none; }

.big-play {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 72px; height: 72px;
  border-radius: 50%;
  border: 0;
  background: var(--gradient);
  color: #fff;
  display: grid; place-items: center;
  cursor: pointer;
  box-shadow: 0 8px 30px rgba(139, 92, 246, 0.5);
}
.big-play .icon { width: 30px; height: 30px; fill: #fff; }
.big-play.hidden { display: none; }

.player-controls {
  position: absolute;
  inset: auto 0 0 0;
  padding: 28px 14px 10px;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.85));
  transition: opacity .25s;
}
.player-container.idle.playing .player-controls { opacity: 0; pointer-events: none; }
.player-container.idle.playing { cursor: none; }

.seek-bar { width: 100%; height: 5px; background: rgba(255, 255, 255, 0.25); border-radius: 99px; cursor: pointer; position: relative; margin-bottom: 10px; touch-action: none; }
.seek-bar:hover { height: 7px; }
.seek-buffer { position: absolute; inset: 0 auto 0 0; background: rgba(255, 255, 255, 0.3); border-radius: 99px; width: 0; }
.seek-fill { position: absolute; inset: 0 auto 0 0; background: var(--gradient); border-radius: 99px; width: 0; }

.controls-row { display: flex; align-items: center; gap: 6px; }
.ctrl-btn { background: none; border: 0; color: #fff; cursor: pointer; padding: 6px; border-radius: 8px; display: grid; place-items: center; }
.ctrl-btn:hover { background: rgba(255, 255, 255, 0.15); }
.ctrl-btn .icon { width: 22px; height: 22px; }
.time-label { font-size: .78rem; color: #e5e7eb; white-space: nowrap; padding: 0 6px; font-variant-numeric: tabular-nums; }
.controls-spacer { flex: 1; }

.volume-slider { width: 80px; accent-color: var(--primary); cursor: pointer; }

.quality-wrap { position: relative; }
.quality-menu {
  position: absolute;
  right: 0; bottom: 42px;
  background: rgba(21, 24, 39, 0.96);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px;
  min-width: 110px;
  display: none;
}
.quality-menu.open { display: block; }
.quality-option { display: block; width: 100%; text-align: left; background: none; border: 0; color: #fff; padding: 8px 12px; border-radius: 8px; cursor: pointer; font: inherit; font-size: .85rem; }
.quality-option:hover { background: rgba(255, 255, 255, 0.12); }
.quality-option.active { color: var(--primary); font-weight: 700; }

.player-spinner { position: absolute; top: 50%; left: 50%; margin: -18px 0 0 -18px; display: none; }
.player-container.buffering .player-spinner { display: block; }

/* ===== Animasi ===== */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pop { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: scale(1); } }
@keyframes slideIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.fade-up { animation: fadeUp .35s ease both; }

/* ===== Responsif ===== */
@media (max-width: 960px) {
  .sidebar { display: none; }
  .bottom-nav { display: flex; }
  .main { margin-left: 0; padding: 20px 16px calc(90px + env(safe-area-inset-bottom)); }
  .upload-grid, .embed-layout { grid-template-columns: 1fr; }
  .feature-grid { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
  h1 { font-size: 1.35rem; }
  .stats-grid { grid-template-columns: 1fr; gap: 12px; }
  .video-grid { grid-template-columns: 1fr; }
  .toolbar select { width: 100%; }
  .volume-slider { display: none; }
  .modal { padding: 18px; }
  .toast-container { left: 16px; right: 16px; }
}

@media (max-width: 400px) {
  .bottom-nav a { padding: 4px 6px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .spinner { animation: spin 1.6s linear infinite !important; }
}
