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

:root {
  --primary: #8B1A1A;
  --primary-dark: #6B1414;
  --primary-light: #A52A2A;
  --accent: #D4AF37;
  --accent-light: #E8D48B;
  --bg-body: #0C0C0E;
  --bg-surface: #151517;
  --bg-card: #111113;
  --bg-elevated: #1A1A1C;
  --text-primary: #FFFFFF;
  --text-secondary: #B0B0BA;
  --text-muted: #6B6B72;
  --border: rgba(255, 255, 255, 0.07);
  --border-hover: rgba(212, 175, 55, 0.3);
}

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

/* ─── Login ─────────────────────────────────────────────────────────── */
.login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(139, 26, 26, 0.12) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 80%, rgba(212, 175, 55, 0.04) 0%, transparent 50%),
    var(--bg-body);
}
.login-box {
  background: var(--bg-surface);
  padding: 48px 40px;
  border-radius: 16px;
  width: 400px;
  max-width: 90vw;
  text-align: center;
  box-shadow: 0 8px 40px rgba(0,0,0,0.5);
  border: 1px solid var(--border);
}
.login-box h1 {
  font-size: 26px;
  color: #fff;
  margin-bottom: 4px;
  font-weight: 700;
}
.login-box .subtitle {
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 3px;
  text-transform: uppercase;
  margin-bottom: 8px;
}
.login-box p {
  color: var(--text-muted);
  margin-bottom: 32px;
  font-size: 14px;
}
.login-box input {
  display: block;
  width: 100%;
  padding: 14px 16px;
  margin-bottom: 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-card);
  color: #fff;
  font-size: 15px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.login-box input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(139, 26, 26, 0.15);
}
.login-box input::placeholder { color: var(--text-muted); }
.login-box button {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 4px 16px rgba(139, 26, 26, 0.3);
  margin-top: 4px;
}
.login-box button:hover {
  background: linear-gradient(135deg, var(--primary-light) 0%, var(--primary) 100%);
  box-shadow: 0 6px 24px rgba(139, 26, 26, 0.4);
  transform: translateY(-1px);
}
.login-box button:active { transform: translateY(0); }
.error-msg { color: #FF6B6B; margin-top: 12px; font-size: 14px; }

/* ─── Topbar ────────────────────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 32px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}
.topbar h1 { font-size: 18px; color: #fff; font-weight: 700; }
.topbar h1 span {
  color: var(--accent);
  font-size: 11px;
  font-weight: 500;
  margin-left: 10px;
  letter-spacing: 2px;
  vertical-align: middle;
}
.topbar-actions { display: flex; align-items: center; gap: 10px; }

.btn {
  padding: 9px 18px;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #fff;
  box-shadow: 0 2px 8px rgba(139, 26, 26, 0.25);
}
.btn-primary:hover {
  background: linear-gradient(135deg, var(--primary-light) 0%, var(--primary) 100%);
  box-shadow: 0 4px 12px rgba(139, 26, 26, 0.35);
  transform: translateY(-1px);
}
.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-secondary:hover {
  background: #222224;
  border-color: var(--border-hover);
  color: #fff;
}
.btn-logout {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-logout:hover { color: #FF6B6B; border-color: rgba(255, 107, 107, 0.3); }

.save-status {
  font-size: 13px;
  padding: 6px 12px;
  border-radius: 6px;
  transition: opacity 0.3s;
}
.save-status.saving { color: var(--accent); }
.save-status.saved { color: #51CF66; }
.save-status.error { color: #FF6B6B; }

/* ─── Sections Container ───────────────────────────────────────────── */
.sections-container {
  padding: 24px 32px;
  max-width: 1600px;
  margin: 0 auto;
}
.loading {
  text-align: center;
  padding: 80px;
  color: var(--text-muted);
  font-size: 16px;
}

/* ─── Section ───────────────────────────────────────────────────────── */
.section {
  background: var(--bg-surface);
  border-radius: 12px;
  margin-bottom: 16px;
  border: 1px solid var(--border);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.section:hover {
  border-color: rgba(255, 255, 255, 0.1);
}
.section.sortable-ghost {
  opacity: 0.4;
  border-color: var(--primary);
}
.section.sortable-chosen {
  box-shadow: 0 8px 24px rgba(139, 26, 26, 0.2);
  border-color: rgba(139, 26, 26, 0.4);
}
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  cursor: grab;
  border-bottom: 1px solid var(--border);
  user-select: none;
}
.section-header:active { cursor: grabbing; }
.section-header h2 {
  font-size: 15px;
  color: #fff;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
}
.section-header .drag-handle {
  color: var(--text-muted);
  font-size: 18px;
  line-height: 1;
}
.section-header .badge {
  background: rgba(212, 175, 55, 0.1);
  color: var(--accent);
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
  border: 1px solid rgba(212, 175, 55, 0.12);
}
.section-collapse {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  transition: transform 0.2s;
}
.section-collapse:hover { color: var(--text-secondary); }
.section-collapse.collapsed { transform: rotate(-90deg); }

/* ─── Video Row ─────────────────────────────────────────────────────── */
.video-row {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  padding: 16px 20px;
  min-height: 60px;
}
.video-row.collapsed { display: none; }

/* ─── Video Card ────────────────────────────────────────────────────── */
.video-card {
  width: 210px;
  background: var(--bg-card);
  border-radius: 10px;
  overflow: hidden;
  cursor: grab;
  border: 1px solid var(--border);
  transition: border-color 0.2s, transform 0.2s, box-shadow 0.2s;
  flex-shrink: 0;
}
.video-card:hover {
  border-color: var(--border-hover);
  transform: translateY(-3px);
  box-shadow: 0 8px 20px rgba(0,0,0,0.3);
}
.video-card:active { cursor: grabbing; }
.video-card.sortable-ghost {
  opacity: 0.3;
  border-color: var(--primary);
}
.video-card.sortable-chosen {
  border-color: var(--primary);
  box-shadow: 0 4px 16px rgba(139, 26, 26, 0.3);
}
.video-card .thumb {
  width: 100%;
  height: 120px;
  object-fit: cover;
  display: block;
  background: var(--bg-body);
}
.video-card .thumb-placeholder {
  width: 100%;
  height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-body);
  color: var(--text-muted);
  font-size: 12px;
}
.video-card .card-info {
  padding: 10px 12px;
}
.video-card .card-title {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.video-card .card-pos {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 4px;
  font-weight: 500;
}

/* ─── Drag helpers ──────────────────────────────────────────────────── */
.sortable-drag {
  z-index: 9999;
}
.section .video-row.sortable-drag-over {
  background: rgba(139, 26, 26, 0.04);
  border-radius: 8px;
}

/* ─── Changed indicator ─────────────────────────────────────────────── */
.has-changes .topbar { border-bottom-color: var(--accent); }

.empty-section-msg {
  padding: 24px 20px;
  color: #666;
  font-size: 13px;
  font-style: italic;
  text-align: center;
  border: 2px dashed rgba(255,255,255,.08);
  border-radius: 12px;
  margin: 8px 0;
}

/* ─── Section Actions ───────────────────────────────────────────────── */
.section-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-delete-section {
  background: none;
  border: 1px solid rgba(255,100,100,.2);
  border-radius: 8px;
  color: #FF6B6B;
  cursor: pointer;
  padding: 4px 10px;
  font-size: 16px;
  transition: all .2s;
  line-height: 1;
}

.btn-delete-section:hover {
  background: rgba(255,100,100,.15);
  border-color: rgba(255,100,100,.4);
}

.btn-rename-section {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: 14px;
  padding: 2px 6px;
  border-radius: 4px;
  transition: all .2s;
  opacity: .5;
  vertical-align: middle;
}
.btn-rename-section:hover {
  opacity: 1;
  background: rgba(212,175,55,.15);
}

.save-status.warning {
  color: #f0ad4e;
}

.btn-create {
  background: #25a55f !important;
  color: #fff !important;
  font-weight: 600;
}

.btn-create:hover {
  background: #1e8c50 !important;
}

.btn-danger {
  background: #dc3545 !important;
  color: #fff !important;
}

.btn-danger:hover {
  background: #b02a37 !important;
}

/* ─── Modals ────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,.7);
  backdrop-filter: blur(6px);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px;
  max-width: 480px;
  width: 100%;
  box-shadow: 0 20px 60px rgba(0,0,0,.5);
}

.modal-box h2 {
  font-size: 20px;
  margin-bottom: 8px;
  color: #fff;
}

.modal-desc {
  font-size: 13px;
  color: #999;
  margin-bottom: 20px;
  line-height: 1.5;
}

.modal-warn {
  font-size: 12px;
  color: #FF6B6B;
  margin-bottom: 20px;
  padding: 10px;
  background: rgba(255,100,100,.08);
  border-radius: 8px;
  border: 1px solid rgba(255,100,100,.15);
}

.modal-input {
  width: 100%;
  background: rgba(255,255,255,.06);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 16px;
  color: #fff;
  font-size: 15px;
  font-family: inherit;
  outline: none;
  margin-bottom: 20px;
  transition: border-color .2s;
}

.modal-input:focus {
  border-color: var(--accent);
}

.modal-input::placeholder {
  color: #666;
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* ─── Files Button on Card ─────────────────────────────────────────── */
.card-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 4px;
}

.btn-files {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px 6px;
  font-size: 14px;
  transition: all .2s;
  line-height: 1;
}
.btn-files:hover {
  color: var(--accent);
  border-color: var(--border-hover);
  background: rgba(212,175,55,.08);
}

/* ─── Files Modal ──────────────────────────────────────────────────── */
.modal-box-wide {
  max-width: 600px;
}

.file-drop-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 28px 20px;
  border: 2px dashed rgba(255,255,255,.1);
  border-radius: 12px;
  cursor: pointer;
  transition: all .2s;
  margin-bottom: 16px;
  color: var(--text-muted);
}
.file-drop-zone span { font-size: 14px; }
.file-drop-zone small { font-size: 11px; color: #555; }
.file-drop-zone:hover,
.file-drop-zone.dragover {
  border-color: var(--accent);
  background: rgba(212,175,55,.04);
  color: var(--accent);
}
.file-drop-zone svg { opacity: .5; }
.file-drop-zone:hover svg,
.file-drop-zone.dragover svg { opacity: 1; stroke: var(--accent); }

.upload-progress {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  margin-bottom: 12px;
}
.upload-progress-bar {
  height: 4px;
  background: var(--accent);
  border-radius: 4px;
  flex: 1;
  transition: width .3s;
}
#uploadProgressText {
  font-size: 12px;
  color: var(--accent);
  white-space: nowrap;
}

.files-list {
  max-height: 300px;
  overflow-y: auto;
}
.files-loading, .files-empty {
  padding: 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

.file-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  margin-bottom: 8px;
  background: rgba(255,255,255,.02);
  transition: all .2s;
}
.file-item:hover {
  border-color: rgba(255,255,255,.1);
  background: rgba(255,255,255,.04);
}
.file-icon { font-size: 22px; flex-shrink: 0; }
.file-info { flex: 1; min-width: 0; }
.file-name {
  font-size: 13px;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.file-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}
.btn-file-delete {
  background: none;
  border: none;
  color: #FF6B6B;
  font-size: 20px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: all .2s;
  line-height: 1;
  flex-shrink: 0;
}
.btn-file-delete:hover {
  background: rgba(255,100,100,.15);
}

/* ─── Responsive ────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .topbar { flex-direction: column; gap: 12px; padding: 12px 16px; }
  .topbar-actions { flex-wrap: wrap; justify-content: center; }
  .sections-container { padding: 16px; }
  .video-card { width: 160px; }
  .video-card .thumb, .video-card .thumb-placeholder { height: 90px; }
}
