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

:root {
  --bg: #0f0f13;
  --surface: #1a1a24;
  --surface2: #24243a;
  --border: #2e2e44;
  --accent: #6c5ce7;
  --accent-hover: #5a4bd1;
  --danger: #e74c3c;
  --danger-hover: #c0392b;
  --success: #27ae60;
  --text: #e8e8f0;
  --text-muted: #888;
  --radius: 8px;
}

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

/* ===== Utility ===== */
.hidden { display: none !important; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  transition: background 0.15s, opacity 0.15s;
  white-space: nowrap;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary  { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-secondary { background: var(--surface2); color: var(--text); }
.btn-secondary:hover:not(:disabled) { background: var(--border); }
.btn-ghost { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }
.btn-ghost:hover:not(:disabled) { background: var(--surface2); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: var(--danger-hover); }
.btn-full { width: 100%; justify-content: center; }
.btn-sm { padding: 5px 10px; font-size: 12px; }

/* ===== Forms ===== */
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: 13px; color: var(--text-muted); font-weight: 500; }
.form-group input[type="text"],
.form-group input[type="number"],
.form-group input[type="password"],
.form-group input[type="file"] {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 9px 12px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s;
}
.form-group input:focus { border-color: var(--accent); }
.form-group input[type="file"] { padding: 6px 12px; cursor: pointer; }

/* ===== Alert ===== */
.alert { padding: 10px 14px; border-radius: var(--radius); font-size: 14px; margin-bottom: 16px; }
.alert-error { background: rgba(231,76,60,0.15); border: 1px solid var(--danger); color: #ff8a80; }

/* ===== Cards ===== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
}

/* ===== Badge ===== */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  background: var(--surface2);
  color: var(--text-muted);
}
.meta-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
}
.duration-badge { background: rgba(108,92,231,0.2); color: var(--accent); }
.active-badge { background: rgba(39,174,96,0.2); color: #5dba7e; }
.inactive-badge { background: rgba(120,120,120,0.2); color: var(--text-muted); }

/* ===========================
   LOGIN PAGE
=========================== */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: radial-gradient(ellipse at top, #1a1040 0%, var(--bg) 70%);
}

.login-container { width: 100%; max-width: 380px; padding: 16px; }

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px 36px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.login-card h1 { font-size: 24px; text-align: center; }
.login-subtitle { text-align: center; color: var(--text-muted); font-size: 14px; margin-top: -12px; }

/* ===========================
   DASHBOARD
=========================== */
.dashboard-page { display: flex; flex-direction: column; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 600;
}
.brand-icon {
  width: 32px;
  height: 32px;
  background: var(--accent);
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
}
.topbar-actions { display: flex; gap: 10px; align-items: center; }

.dashboard-main {
  padding: 24px;
  max-width: 960px;
  margin: 0 auto;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* Upload grid */
.upload-section h2, .playlist-section h2 { font-size: 16px; margin-bottom: 16px; }
.upload-grid {
  display: grid;
  grid-template-columns: 2fr 2fr 1fr auto;
  gap: 14px;
  align-items: end;
}
.form-group-action { justify-content: flex-end; }

/* Duration h/m inputs */
.duration-inputs {
  display: flex;
  align-items: center;
  gap: 6px;
}
.duration-inputs input[type="number"] {
  width: 64px;
  text-align: center;
}
.duration-unit {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 600;
}

@media (max-width: 700px) {
  .upload-grid { grid-template-columns: 1fr; }
}

/* Upload progress */
.upload-progress { margin-top: 14px; display: flex; flex-direction: column; gap: 6px; }
.progress-bar { height: 6px; background: var(--surface2); border-radius: 3px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--accent); width: 0%; transition: width 0.3s; border-radius: 3px; }
#progress-text { font-size: 12px; color: var(--text-muted); }

/* Playlist */
.section-header { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.section-header h2 { margin-bottom: 0; }

.empty-state { padding: 40px; text-align: center; color: var(--text-muted); }

.video-list { list-style: none; display: flex; flex-direction: column; gap: 10px; }

.video-item {
  display: grid;
  grid-template-columns: 48px 100px 1fr auto;
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
  background: var(--surface2);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  transition: opacity 0.2s;
}
.video-item.inactive { opacity: 0.5; }

.video-order {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.order-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  line-height: 1;
  transition: color 0.15s, background 0.15s;
}
.order-btn:hover:not(:disabled) { color: var(--text); background: var(--border); }
.order-btn:disabled { opacity: 0.2; cursor: default; }
.order-num { font-size: 12px; color: var(--text-muted); font-weight: 600; }

.video-thumb {
  width: 100px;
  height: 56px;
  border-radius: 6px;
  overflow: hidden;
  background: var(--bg);
  flex-shrink: 0;
}
.video-thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.video-info { min-width: 0; }
.video-title { font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.video-meta { display: flex; gap: 8px; margin-top: 6px; flex-wrap: wrap; }

.video-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.6);
}
.modal-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px;
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.modal-card h3 { font-size: 16px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 8px; }

/* ===========================
   PLAYER PAGE
=========================== */
.player-page {
  background: #000;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

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

#main-video {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.player-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--text-muted);
}
.player-empty a { color: var(--accent); }

/* Fullscreen button */
.fullscreen-btn {
  position: absolute;
  bottom: 20px;
  right: 20px;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  border: none;
  background: rgba(0,0,0,0.5);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s;
  z-index: 10;
}
.fullscreen-btn svg { width: 18px; height: 18px; }
.player-container:hover .fullscreen-btn { opacity: 1; }
.fullscreen-btn:hover { background: rgba(108,92,231,0.7); }
