/* ═══════════════════════════════════════════════════════════════════
   VideoUp — Design System
   Dark professional dashboard theme
   ═══════════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

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

:root {
  /* Colors */
  --bg-primary: #0b0d14;
  --bg-secondary: #111320;
  --bg-card: #181b28;
  --bg-card-hover: #1e2235;
  --bg-input: #131520;
  --border: #262a3a;
  --border-hover: #3b4060;

  /* Accents */
  --accent: #6366f1;
  --accent-hover: #818cf8;
  --accent-glow: rgba(99,102,241,.25);
  --success: #22c55e;
  --success-bg: rgba(34,197,94,.12);
  --warning: #f59e0b;
  --warning-bg: rgba(245,158,11,.12);
  --error: #ef4444;
  --error-bg: rgba(239,68,68,.12);
  --info: #3b82f6;

  /* Text */
  --text: #e8eaed;
  --text-secondary: #9ca3b4;
  --text-muted: #6b7280;

  /* Layout */
  --sidebar-w: 270px;
  --header-h: 60px;
  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 14px;

  /* Shadows */
  --shadow: 0 2px 12px rgba(0,0,0,.35);
  --shadow-lg: 0 8px 32px rgba(0,0,0,.5);

  /* Transitions */
  --transition: .2s cubic-bezier(.4,0,.2,1);
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

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

/* ─── Scrollbar ──────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-hover); }

/* ═══════════════════════════════════════════════════════════════════
   LOGIN PAGE
   ═══════════════════════════════════════════════════════════════════ */

.login-page {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #0b0d14 0%, #1a1040 50%, #0b0d14 100%);
  position: relative; overflow: hidden;
}

.login-page::before {
  content: ''; position: absolute; inset: 0;
  background: radial-gradient(ellipse 600px 400px at 50% 40%, rgba(99,102,241,.12), transparent);
  pointer-events: none;
}

.login-container { width: 100%; max-width: 420px; padding: 20px; position: relative; z-index: 1; }

.login-card {
  background: rgba(24,27,40,.85);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  padding: 44px 36px; border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  animation: fadeUp .5s ease-out;
}

@keyframes fadeUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }

.login-card .brand { text-align: center; margin-bottom: 32px; }
.login-card .brand-icon {
  width: 56px; height: 56px; border-radius: 14px;
  background: linear-gradient(135deg, var(--accent), #a78bfa);
  display: inline-flex; align-items: center; justify-content: center;
  margin-bottom: 16px; box-shadow: 0 4px 20px var(--accent-glow);
}
.login-card .brand-icon svg { color: #fff; }
.login-card h1 { font-size: 24px; font-weight: 700; margin-bottom: 6px; }
.login-card .subtitle { color: var(--text-secondary); font-size: 14px; }

.login-card .alert {
  padding: 10px 14px; border-radius: var(--radius-sm); font-size: 13px;
  margin-bottom: 20px; display: flex; align-items: center; gap: 8px;
  background: var(--error-bg); color: var(--error); border: 1px solid rgba(239,68,68,.2);
  animation: shake .4s ease-out;
}
@keyframes shake { 0%,100%{transform:translateX(0)} 25%{transform:translateX(-6px)} 75%{transform:translateX(6px)} }

/* ─── Forms ──────────────────────────────────────────────────────── */

.form-group { margin-bottom: 20px; }
.form-group label { display: block; margin-bottom: 6px; font-size: 13px; font-weight: 500; color: var(--text-secondary); }

.input-wrapper {
  position: relative; display: flex; align-items: center;
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: var(--radius-sm); transition: border-color var(--transition);
}
.input-wrapper:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.input-wrapper svg { position: absolute; left: 12px; color: var(--text-muted); pointer-events: none; }
.input-wrapper input {
  width: 100%; padding: 11px 12px 11px 40px; border: none; background: none;
  color: var(--text); font-size: 14px; font-family: inherit; outline: none;
}
.input-wrapper input::placeholder { color: var(--text-muted); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 20px; border: none; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 500; font-family: inherit;
  cursor: pointer; transition: all var(--transition); text-decoration: none;
  position: relative; overflow: hidden;
}
.btn:active { transform: scale(.97); }

.btn-primary {
  background: linear-gradient(135deg, var(--accent), #818cf8);
  color: #fff; box-shadow: 0 2px 10px var(--accent-glow);
}
.btn-primary:hover { box-shadow: 0 4px 20px var(--accent-glow); filter: brightness(1.1); }

.btn-secondary { background: var(--bg-card); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--bg-card-hover); border-color: var(--border-hover); }

.btn-ghost { background: none; color: var(--text-secondary); padding: 8px; border-radius: var(--radius-sm); }
.btn-ghost:hover { background: var(--bg-card); color: var(--text); }

.btn-danger { background: var(--error-bg); color: var(--error); border: 1px solid rgba(239,68,68,.2); }
.btn-danger:hover { background: rgba(239,68,68,.2); }

.btn-icon { width: 34px; height: 34px; padding: 0; border-radius: var(--radius-sm); background: none; border: 1px solid transparent; color: var(--text-muted); cursor: pointer; transition: all var(--transition); display: inline-flex; align-items: center; justify-content: center; }
.btn-icon:hover { background: var(--bg-card-hover); color: var(--text); border-color: var(--border); }
.btn-icon.danger:hover { color: var(--error); background: var(--error-bg); }

.btn-block { width: 100%; }
.btn-sm { padding: 6px 14px; font-size: 13px; }

/* ═══════════════════════════════════════════════════════════════════
   APP LAYOUT
   ═══════════════════════════════════════════════════════════════════ */

.app-layout { display: flex; min-height: 100vh; }

/* Header */
.app-header {
  position: fixed; top: 0; left: var(--sidebar-w); right: 0;
  height: var(--header-h); z-index: 90;
  background: rgba(11,13,20,.8); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; transition: left var(--transition);
}
.header-left { display: flex; align-items: center; gap: 12px; }
.header-right { display: flex; align-items: center; gap: 12px; }

.sidebar-toggle { display: none; }

/* Sidebar */
.sidebar {
  width: var(--sidebar-w); position: fixed; top: 0; bottom: 0; left: 0;
  background: var(--bg-secondary); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; z-index: 100;
  transition: transform var(--transition);
}

.sidebar-brand {
  height: var(--header-h); display: flex; align-items: center; gap: 10px;
  padding: 0 20px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.sidebar-brand .brand-icon {
  width: 34px; height: 34px; border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), #a78bfa);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.sidebar-brand .brand-icon svg { color: #fff; width: 18px; height: 18px; }
.sidebar-brand h2 { font-size: 16px; font-weight: 700; }

.sidebar-section { padding: 16px; border-bottom: 1px solid var(--border); }
.sidebar-section h3 {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .08em; color: var(--text-muted); margin-bottom: 10px;
}

.folder-form { display: flex; gap: 6px; }
.folder-form input {
  flex: 1; padding: 7px 10px; background: var(--bg-input);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text); font-size: 13px; font-family: inherit; outline: none;
}
.folder-form input:focus { border-color: var(--accent); }
.folder-form .btn { padding: 7px 12px; font-size: 13px; }

.sidebar-folders { flex: 1; overflow-y: auto; padding: 8px; }

.folder-item {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px;
  border-radius: var(--radius-sm); cursor: pointer; font-size: 13px;
  transition: all var(--transition); color: var(--text-secondary);
  margin-bottom: 2px;
}
.folder-item:hover { background: var(--bg-card); color: var(--text); }
.folder-item.active { background: var(--accent-glow); color: var(--accent-hover); font-weight: 500; }
.folder-item svg { flex-shrink: 0; opacity: .6; }
.folder-item .folder-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder-item .folder-actions { display: none; gap: 2px; }
.folder-item:hover .folder-actions { display: flex; }

/* Main */
.main-content {
  flex: 1; margin-left: var(--sidebar-w);
  padding-top: var(--header-h); min-height: 100vh;
  transition: margin-left var(--transition);
}
.main-inner { padding: 24px; max-width: 1400px; }

/* Breadcrumb */
.breadcrumb {
  display: flex; align-items: center; flex-wrap: wrap; gap: 4px;
  font-size: 13px; color: var(--text-muted);
}
.breadcrumb a { color: var(--text-secondary); font-weight: 500; padding: 2px 4px; border-radius: 4px; }
.breadcrumb a:hover { color: var(--accent); background: var(--accent-glow); }
.breadcrumb .separator { color: var(--text-muted); }
.breadcrumb .current { color: var(--text); font-weight: 500; }

/* ═══════════════════════════════════════════════════════════════════
   UPLOAD SECTION
   ═══════════════════════════════════════════════════════════════════ */

.upload-section {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 24px; margin-bottom: 24px;
}

.upload-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; flex-wrap: wrap; gap: 12px; }
.upload-header h2 { font-size: 16px; font-weight: 600; display: flex; align-items: center; gap: 8px; }

.upload-options { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }

/* Toggle switch */
.toggle { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13px; color: var(--text-secondary); }
.toggle input { display: none; }
.toggle-track {
  width: 36px; height: 20px; background: var(--border); border-radius: 10px;
  position: relative; transition: background var(--transition);
}
.toggle input:checked + .toggle-track { background: var(--accent); }
.toggle-track::after {
  content: ''; position: absolute; top: 2px; left: 2px;
  width: 16px; height: 16px; background: #fff; border-radius: 50%;
  transition: transform var(--transition);
}
.toggle input:checked + .toggle-track::after { transform: translateX(16px); }

/* Quality selector */
.quality-selector { display: flex; gap: 4px; }
.quality-option {
  padding: 5px 12px; font-size: 12px; font-weight: 500;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  cursor: pointer; transition: all var(--transition);
  background: none; color: var(--text-secondary); font-family: inherit;
}
.quality-option:hover { border-color: var(--border-hover); color: var(--text); }
.quality-option.active { background: var(--accent-glow); border-color: var(--accent); color: var(--accent-hover); }

/* Dropzone */
.dropzone {
  border: 2px dashed var(--border); border-radius: var(--radius);
  padding: 48px 24px; text-align: center; cursor: pointer;
  transition: all .3s; position: relative;
}
.dropzone:hover, .dropzone.dragover {
  border-color: var(--accent); background: rgba(99,102,241,.05);
}
.dropzone.dragover { animation: pulse 1.5s infinite; }
@keyframes pulse { 0%,100%{box-shadow:0 0 0 0 var(--accent-glow)} 50%{box-shadow:0 0 0 8px transparent} }
.dropzone svg { color: var(--text-muted); margin-bottom: 12px; }
.dropzone p { color: var(--text-secondary); font-size: 14px; margin-bottom: 4px; }
.dropzone .hint { color: var(--text-muted); font-size: 12px; }

/* Upload queue */
.upload-queue { margin-top: 16px; display: flex; flex-direction: column; gap: 8px; }

.upload-item {
  background: var(--bg-secondary); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px 16px;
  animation: fadeUp .3s ease-out;
}
.upload-item-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.upload-item-name { font-size: 13px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 60%; }
.upload-item-status { display: flex; align-items: center; gap: 8px; font-size: 12px; }

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 500;
}
.badge-pending { background: rgba(107,114,128,.15); color: var(--text-muted); }
.badge-optimizing { background: var(--warning-bg); color: var(--warning); }
.badge-uploading { background: rgba(59,130,246,.12); color: var(--info); }
.badge-done { background: var(--success-bg); color: var(--success); }
.badge-error { background: var(--error-bg); color: var(--error); }

.progress-track { height: 4px; background: var(--border); border-radius: 2px; overflow: hidden; }
.progress-bar { height: 100%; border-radius: 2px; transition: width .2s linear; background: var(--accent); }
.progress-bar.optimizing { background: var(--warning); }
.progress-bar.done { background: var(--success); }
.progress-bar.error { background: var(--error); }

.upload-item-url {
  margin-top: 8px; display: flex; align-items: center; gap: 8px;
  background: var(--bg-input); padding: 6px 10px; border-radius: var(--radius-sm);
  font-size: 12px; border: 1px solid var(--border);
}
.upload-item-url input {
  flex: 1; background: none; border: none; color: var(--accent);
  font-size: 12px; font-family: 'Inter',monospace; outline: none;
}
.upload-item-url .btn-copy { flex-shrink: 0; }

/* ═══════════════════════════════════════════════════════════════════
   FILES TABLE
   ═══════════════════════════════════════════════════════════════════ */

.files-section {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); overflow: hidden;
}
.files-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.files-header h2 { font-size: 16px; font-weight: 600; }
.files-count { font-size: 12px; color: var(--text-muted); }

.files-table { width: 100%; border-collapse: collapse; }
.files-table th {
  padding: 10px 16px; text-align: left; font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted);
  background: var(--bg-secondary); border-bottom: 1px solid var(--border);
}
.files-table td {
  padding: 10px 16px; font-size: 13px; border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.files-table tr:last-child td { border-bottom: none; }
.files-table tbody tr { transition: background var(--transition); }
.files-table tbody tr:hover { background: var(--bg-card-hover); }

.file-name-cell { display: flex; align-items: center; gap: 10px; }
.file-name-cell svg { flex-shrink: 0; color: var(--text-muted); }
.file-name-cell .name { font-weight: 500; word-break: break-word; }
.file-name-cell .name.folder { color: var(--accent); cursor: pointer; }
.file-name-cell .name.folder:hover { text-decoration: underline; }

.file-size { color: var(--text-secondary); white-space: nowrap; }
.file-date { color: var(--text-muted); white-space: nowrap; font-size: 12px; }
.file-actions { display: flex; gap: 4px; justify-content: flex-end; }

/* Empty state */
.empty-state {
  padding: 60px 20px; text-align: center; color: var(--text-muted);
}
.empty-state svg { margin-bottom: 16px; opacity: .4; }
.empty-state p { font-size: 14px; }

/* Loading */
.loading-state {
  padding: 40px 20px; text-align: center; color: var(--text-muted); font-size: 14px;
}
.spinner {
  width: 24px; height: 24px; border: 2px solid var(--border);
  border-top-color: var(--accent); border-radius: 50%;
  animation: spin .8s linear infinite; display: inline-block; margin-bottom: 8px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ═══════════════════════════════════════════════════════════════════
   MODALS
   ═══════════════════════════════════════════════════════════════════ */

.modal-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,.6); backdrop-filter: blur(4px);
  display: none; align-items: center; justify-content: center;
  padding: 20px; animation: fadeIn .2s ease-out;
}
.modal-overlay.active { display: flex; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); width: 100%; max-width: 440px;
  box-shadow: var(--shadow-lg); animation: modalIn .25s ease-out;
}
@keyframes modalIn { from { opacity: 0; transform: scale(.95) translateY(10px); } to { opacity: 1; transform: none; } }

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 15px; font-weight: 600; }
.modal-body { padding: 20px; }
.modal-body p { font-size: 14px; color: var(--text-secondary); margin-bottom: 16px; }
.modal-body input {
  width: 100%; padding: 9px 12px; background: var(--bg-input);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text); font-size: 14px; font-family: inherit; outline: none;
}
.modal-body input:focus { border-color: var(--accent); }
.modal-footer {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 12px 20px; border-top: 1px solid var(--border);
}

/* ═══════════════════════════════════════════════════════════════════
   TOASTS
   ═══════════════════════════════════════════════════════════════════ */

.toast-container {
  position: fixed; bottom: 20px; right: 20px; z-index: 300;
  display: flex; flex-direction: column-reverse; gap: 8px;
}

.toast {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px 16px;
  font-size: 13px; min-width: 280px; max-width: 400px;
  box-shadow: var(--shadow-lg); display: flex; align-items: center; gap: 10px;
  animation: toastIn .3s ease-out;
}
@keyframes toastIn { from { opacity: 0; transform: translateX(30px); } to { opacity: 1; transform: none; } }
.toast.removing { animation: toastOut .25s ease-in forwards; }
@keyframes toastOut { to { opacity: 0; transform: translateX(30px); } }

.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--error); }
.toast.info { border-left: 3px solid var(--info); }
.toast.warning { border-left: 3px solid var(--warning); }

/* ═══════════════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }

  .sidebar-toggle { display: flex; }

  .app-header { left: 0; }
  .main-content { margin-left: 0; }
  .main-inner { padding: 16px; }

  .upload-header { flex-direction: column; align-items: flex-start; }
  .upload-options { width: 100%; }

  .files-table th:nth-child(3),
  .files-table td:nth-child(3),
  .files-table th:nth-child(4),
  .files-table td:nth-child(4) { display: none; }

  .modal { max-width: 100%; margin: 0 10px; }
}

.mobile-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 99;
  display: none;
}
.mobile-overlay.active { display: block; }
