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

:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface2: #222536;
  --border: #2d3148;
  --text: #e8eaf0;
  --text-muted: #8b90a8;
  --accent: #5c6df0;
  --accent-hover: #4a5bd4;
  --danger: #e05252;
  --success: #3cbb6c;
  --radius: 8px;
  --sidebar-w: 220px;
}

html { font-size: 15px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

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

input, select, textarea, button {
  font-family: inherit;
  font-size: inherit;
}

/* ── Navbar ── */
.navbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}
.nav-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 1.5rem;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.nav-logo {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -.3px;
}
.nav-logo:hover { text-decoration: none; color: var(--text); }
.nav-links {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}
.nav-links a { color: var(--text-muted); font-size: .9rem; }
.nav-links a:hover { color: var(--text); text-decoration: none; }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  background: var(--accent);
  color: #fff;
  padding: .45rem 1rem;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-size: .9rem;
  font-weight: 500;
  cursor: pointer;
  line-height: 1.4;
  white-space: nowrap;
  transition: background .15s, opacity .15s;
}
.btn:hover { background: var(--accent-hover); text-decoration: none; color: #fff; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-sm { padding: .3rem .75rem; font-size: .82rem; }
.btn-lg { padding: .65rem 1.5rem; font-size: 1rem; }
.btn-full { width: 100%; justify-content: center; }

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

.btn-danger {
  background: var(--danger);
}
.btn-danger:hover { background: #c43e3e; }

/* ── App layout ── */
.app-layout {
  display: flex;
  flex: 1;
  min-height: calc(100vh - 56px - 48px);
}

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 1.25rem 0;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 56px;
  height: calc(100vh - 56px);
  overflow-y: auto;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0 .75rem;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .5rem .75rem;
  color: var(--text-muted);
  border-radius: 6px;
  font-size: .88rem;
  transition: background .12s, color .12s;
}
.sidebar-nav a svg { width: 16px; height: 16px; flex-shrink: 0; }
.sidebar-nav a:hover { background: var(--surface2); color: var(--text); text-decoration: none; }
.sidebar-nav a.active { background: var(--surface2); color: var(--text); font-weight: 500; }

.sidebar-section-label {
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  padding: .5rem .75rem .25rem;
}

.sidebar-divider {
  height: 1px;
  background: var(--border);
  margin: .5rem .75rem;
}

.sidebar-storage {
  margin-top: auto;
  padding: 1rem .75rem;
  border-top: 1px solid var(--border);
}
.storage-label { font-size: .78rem; color: var(--text-muted); margin-bottom: .4rem; }
.storage-bar {
  height: 4px;
  background: var(--surface2);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: .35rem;
}
.storage-fill { height: 100%; background: var(--accent); border-radius: 2px; }
.storage-text { font-size: .75rem; color: var(--text-muted); }

/* ── Main content ── */
.main-content {
  flex: 1;
  padding: 2rem;
  min-width: 0;
}

.page-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}
.page-header h1 {
  font-size: 1.5rem;
  font-weight: 600;
  flex: 1;
}

/* ── Cards ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}
.card h3 { font-size: 1rem; font-weight: 600; margin-bottom: .5rem; }

/* ── Stats row ── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  text-align: center;
}
.stat-num { font-size: 1.75rem; font-weight: 700; color: var(--text); }
.stat-label { font-size: .8rem; color: var(--text-muted); margin-top: .2rem; }

/* ── Tables ── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .88rem;
}
.data-table th {
  text-align: left;
  padding: .6rem 1rem;
  font-weight: 600;
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.data-table td {
  padding: .65rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--surface2); }
.video-table-wrap { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }

/* ── Badges ── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: .73rem;
  font-weight: 600;
  background: var(--surface2);
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.badge-green { background: rgba(60,187,108,.15); color: #3cbb6c; border-color: rgba(60,187,108,.3); }
.badge-red { background: rgba(224,82,82,.15); color: #e05252; border-color: rgba(224,82,82,.3); }
.badge-blue { background: rgba(92,109,240,.15); color: #7d8ffa; border-color: rgba(92,109,240,.3); }

/* ── Forms ── */
.form-group { margin-bottom: 1rem; }
.form-group label {
  display: block;
  font-size: .85rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: .35rem;
}
.form-group small { color: var(--text-muted); font-size: .78rem; }

input[type="text"],
input[type="email"],
input[type="password"],
input[type="url"],
input[type="number"],
select,
textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: .5rem .75rem;
  outline: none;
  transition: border-color .15s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
}
textarea { resize: vertical; min-height: 80px; }
select { cursor: pointer; }

.required { color: var(--danger); }

/* ── Alerts ── */
.alert {
  padding: .75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: .9rem;
}
.alert-error { background: rgba(224,82,82,.12); border: 1px solid rgba(224,82,82,.3); color: #e88; }
.alert-success { background: rgba(60,187,108,.12); border: 1px solid rgba(60,187,108,.3); color: #7dcc9a; }

/* ── Auth pages ── */
.auth-page {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
}
.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  width: 100%;
  max-width: 400px;
}
.auth-card h1 { font-size: 1.4rem; margin-bottom: 1.25rem; }
.auth-switch { margin-top: 1rem; text-align: center; color: var(--text-muted); font-size: .88rem; }

/* ── Homepage ── */
.hero {
  background: linear-gradient(160deg, #0f1117 0%, #151829 50%, #0f1117 100%);
  border-bottom: 1px solid var(--border);
  padding: 5rem 1.5rem;
  text-align: center;
}
.hero-inner { max-width: 680px; margin: 0 auto; }
.hero h1 {
  font-size: clamp(1.8rem, 5vw, 3rem);
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -.5px;
  margin-bottom: 1rem;
}
.hero-sub {
  font-size: 1.1rem;
  color: var(--text-muted);
  margin-bottom: 2rem;
}
.hero-cta { display: flex; gap: 1rem; justify-content: center; flex-wrap: wrap; }

.features {
  padding: 4rem 1.5rem;
  background: var(--bg);
}
.features-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.5rem;
}
.feature-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem;
}
.feature-icon {
  width: 44px;
  height: 44px;
  background: rgba(92,109,240,.12);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1rem;
}
.feature-icon svg { width: 22px; height: 22px; color: var(--accent); }
.feature-card h3 { font-size: 1rem; font-weight: 600; margin-bottom: .4rem; }
.feature-card p { font-size: .88rem; color: var(--text-muted); line-height: 1.6; }

.how-it-works {
  padding: 4rem 1.5rem;
  background: var(--surface);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.hiw-inner { max-width: 640px; margin: 0 auto; text-align: center; }
.hiw-inner h2 { font-size: 1.6rem; font-weight: 700; margin-bottom: 2rem; }
.hiw-steps {
  list-style: none;
  display: flex;
  justify-content: center;
  gap: 2.5rem;
  flex-wrap: wrap;
}
.hiw-steps li {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .5rem;
  font-size: .9rem;
  color: var(--text-muted);
}
.hiw-steps span {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: .9rem;
}

/* ── Footer ── */
.footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 1rem 1.5rem;
  margin-top: auto;
}
.footer-inner {
  max-width: 1280px;
  margin: 0 auto;
  text-align: center;
  color: var(--text-muted);
  font-size: .82rem;
}

/* ── Upload ── */
.file-drop {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 2.5rem 1rem;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  color: var(--text-muted);
}
.file-drop:hover, .file-drop.drag-over { border-color: var(--accent); background: rgba(92,109,240,.05); }
.file-drop svg { width: 40px; height: 40px; margin-bottom: .75rem; color: var(--text-muted); }
.file-drop p { margin-bottom: .4rem; }
.file-drop small { font-size: .8rem; }
.file-chosen { margin-top: .5rem; font-size: .85rem; color: var(--text); font-weight: 500; }
.link { color: var(--accent); cursor: pointer; }

.progress-bar { height: 6px; background: var(--surface2); border-radius: 3px; margin: 1rem 0 .4rem; overflow: hidden; }
.progress-fill { height: 100%; background: var(--accent); border-radius: 3px; width: 0; animation: progress-anim 3s ease-in-out infinite; }
@keyframes progress-anim { 0%{width:0} 50%{width:70%} 100%{width:95%} }
.progress-text { font-size: .83rem; color: var(--text-muted); text-align: center; }

/* ── Video manage ── */
.video-manage-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  align-items: start;
}
.video-preview { background: #000; border-radius: 6px; overflow: hidden; margin-bottom: 1rem; }
.video-meta { display: flex; flex-direction: column; gap: .4rem; }
.meta-row {
  display: flex;
  justify-content: space-between;
  font-size: .85rem;
  padding: .3rem 0;
  border-bottom: 1px solid var(--border);
}
.meta-row:last-child { border-bottom: none; }
.meta-row > span:first-child { color: var(--text-muted); }

.embed-box { position: relative; }
.embed-box textarea {
  font-family: 'Courier New', monospace;
  font-size: .78rem;
  background: var(--bg);
  min-height: 80px;
  resize: none;
  padding-bottom: 2.5rem;
}
.embed-box .btn { position: absolute; bottom: .5rem; right: .5rem; }
.embed-preview-url { margin-top: .75rem; font-size: .85rem; }

/* ── Search bar ── */
.search-bar {
  display: flex;
  gap: .5rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}
.search-bar input { max-width: 320px; flex: 1; }

/* ── Pagination ── */
.pagination {
  display: flex;
  gap: .4rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}
.pagination a {
  padding: .3rem .7rem;
  border: 1px solid var(--border);
  border-radius: 5px;
  font-size: .85rem;
  color: var(--text-muted);
}
.pagination a.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.pagination a:hover { background: var(--surface2); text-decoration: none; }

/* ── Empty state ── */
.empty-state {
  text-align: center;
  padding: 4rem 1rem;
  color: var(--text-muted);
}
.empty-state svg { width: 56px; height: 56px; margin-bottom: 1rem; opacity: .4; }
.empty-state h3 { font-size: 1.1rem; color: var(--text); margin-bottom: .5rem; }
.empty-state p { margin-bottom: 1.25rem; font-size: .9rem; }

/* ── Misc ── */
.text-muted { color: var(--text-muted); }

@media (max-width: 768px) {
  .app-layout { flex-direction: column; }
  .sidebar { width: 100%; min-width: unset; height: auto; position: static; flex-direction: row; overflow-x: auto; padding: .5rem; }
  .sidebar-nav { flex-direction: row; flex-wrap: wrap; }
  .sidebar-storage { display: none; }
  .video-manage-grid { grid-template-columns: 1fr; }
  .main-content { padding: 1rem; }
}
