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

:root {
  --sidebar-w: 240px;
  --bg:        #f4f5f7;
  --surface:   #ffffff;
  --sidebar-bg:#1e2230;
  --sidebar-fg:#c8cdd8;
  --sidebar-h: #ffffff;
  --accent:    #4f7cf7;
  --accent-h:  #2f5ce0;
  --border:    #e2e5eb;
  --text:      #1a1d26;
  --muted:     #6b7280;
  --danger:    #ef4444;
  --yes:       #22c55e;
  --row-hover: #f0f4ff;
  --row-error: #fff5f5;
  --radius:    6px;
  --font:      'Segoe UI', system-ui, -apple-system, sans-serif;
  --mono:      'Menlo', 'Consolas', monospace;
}

html, body {
  height: 100%;
  font-family: var(--font);
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
}

/* ── Layout ────────────────────────────────────────────────────────────── */
#app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ── Sidebar ───────────────────────────────────────────────────────────── */
#sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--sidebar-bg);
  color: var(--sidebar-fg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#sidebar-header {
  padding: 18px 16px 14px;
  border-bottom: 1px solid rgba(255,255,255,.07);
}

#sidebar-header h1 {
  font-size: 16px;
  font-weight: 700;
  color: var(--sidebar-h);
  letter-spacing: .3px;
  margin-bottom: 4px;
}

#catalog-meta {
  font-size: 11px;
  color: #5a6480;
}

#filters {
  flex: 1;
  overflow-y: auto;
  padding: 14px 14px 20px;
  scrollbar-width: thin;
  scrollbar-color: #3a4060 transparent;
}

#filters::-webkit-scrollbar { width: 4px; }
#filters::-webkit-scrollbar-thumb { background: #3a4060; border-radius: 2px; }

.filter-group { margin-bottom: 18px; }

.filter-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .6px;
  text-transform: uppercase;
  color: #7f8aaa;
  margin-bottom: 7px;
}

.filter-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.ext-actions { display: flex; align-items: center; gap: 4px; }
.sep { color: #3a4060; }

.link-btn {
  background: none;
  border: none;
  color: #7f8aaa;
  font-size: 11px;
  cursor: pointer;
  padding: 0;
  text-decoration: underline dotted;
  transition: color .15s;
}
.link-btn:hover { color: var(--accent); }

/* Inputs inside sidebar */
#filters input[type=search],
#filters input[type=text],
#filters input[type=number],
#filters select {
  width: 100%;
  background: #16192a;
  border: 1px solid #2d3350;
  border-radius: var(--radius);
  color: #d0d4e8;
  padding: 7px 10px;
  font-size: 13px;
  outline: none;
  transition: border-color .15s;
}
#filters input:focus,
#filters select:focus { border-color: var(--accent); }

#filters select option { background: #1e2230; }

.range-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
.range-input { flex: 1; }
.range-sep { color: #3a4060; font-size: 12px; }

/* Extension checkboxes */
#ext-filters {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 13px;
  color: var(--sidebar-fg);
  user-select: none;
  padding: 2px 0;
  transition: color .15s;
}
.checkbox-label:hover { color: #fff; }

.checkbox-label input[type=checkbox] {
  width: 14px;
  height: 14px;
  accent-color: var(--accent);
  cursor: pointer;
}

.reset-btn {
  width: 100%;
  padding: 8px 12px;
  background: transparent;
  border: 1px solid #2d3350;
  border-radius: var(--radius);
  color: #7f8aaa;
  font-size: 12px;
  cursor: pointer;
  transition: all .15s;
}
.reset-btn:hover {
  background: #2d3350;
  color: #fff;
}

/* ── Main ──────────────────────────────────────────────────────────────── */
#main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* Toolbar */
#toolbar, #toolbar-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  gap: 12px;
}

#toolbar-bottom {
  border-bottom: none;
  border-top: 1px solid var(--border);
}

#stats, #stats-bottom {
  font-size: 13px;
  color: var(--muted);
}

#pagination, #pagination-bottom {
  display: flex;
  align-items: center;
  gap: 10px;
}

#pagination button, #pagination-bottom button {
  padding: 5px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  cursor: pointer;
  color: var(--text);
  transition: all .15s;
}
#pagination button:hover:not(:disabled),
#pagination-bottom button:hover:not(:disabled) {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
#pagination button:disabled,
#pagination-bottom button:disabled { opacity: .4; cursor: default; }

#page-info, #page-info-b {
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
}

/* Table wrapper */
#table-wrapper {
  flex: 1;
  overflow: auto;
  background: var(--surface);
  scrollbar-width: thin;
  scrollbar-color: #d0d4e8 transparent;
}

#table-wrapper::-webkit-scrollbar { width: 6px; height: 6px; }
#table-wrapper::-webkit-scrollbar-thumb { background: #c5c9d4; border-radius: 3px; }

/* Table */
#files-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  white-space: nowrap;
}

#files-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #f8f9fc;
  border-bottom: 2px solid var(--border);
  padding: 9px 12px;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .3px;
  color: var(--muted);
  user-select: none;
  cursor: pointer;
  white-space: nowrap;
  transition: color .15s;
}
#files-table thead th:hover { color: var(--text); }
#files-table thead th.sort-asc,
#files-table thead th.sort-desc { color: var(--accent); }

#files-table thead th.col-dl { cursor: default; }

.sort-icon { font-size: 10px; }

#files-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background .1s;
}
#files-table tbody tr:hover { background: var(--row-hover); }
#files-table tbody tr.row-error { background: var(--row-error); }
#files-table tbody tr:last-child { border-bottom: none; }

#files-table td {
  padding: 8px 12px;
  vertical-align: middle;
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Column widths */
.col-name     { font-weight: 500; min-width: 160px; max-width: 220px; }
.col-path     { color: var(--muted); font-family: var(--mono); font-size: 11px; min-width: 140px; }
.col-size     { text-align: right; white-space: nowrap; min-width: 80px; color: var(--muted); }
.col-ext      { text-align: center; min-width: 54px; }
.col-mime     { color: var(--muted); font-size: 11px; min-width: 110px; }
.col-duration { text-align: right; min-width: 70px; font-variant-numeric: tabular-nums; }
.col-title    { min-width: 120px; max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
.col-cover    { text-align: center; min-width: 52px; }
.col-bitrate  { text-align: right; min-width: 80px; color: var(--muted); }
.col-sr       { text-align: right; min-width: 70px; color: var(--muted); }
.col-ch       { text-align: center; min-width: 36px; color: var(--muted); }
.col-dl       { text-align: center; width: 40px; padding: 4px 6px; }

/* Path text truncation */
.path-text {
  display: block;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Badge */
.badge {
  display: inline-block;
  background: #eef2ff;
  color: #4f7cf7;
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .3px;
  font-family: var(--mono);
}

/* Icons */
.icon-yes { color: var(--yes); font-weight: 700; }
.icon-no  { color: #c9cdd8; }

.has-tag { color: var(--yes); font-weight: 700; }
.no-tag  { color: #c9cdd8; }

/* Download button */
.dl-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius);
  text-decoration: none;
  font-size: 14px;
  color: var(--muted);
  background: transparent;
  transition: all .15s;
}
.dl-btn:hover {
  background: var(--accent);
  color: #fff;
}

/* Empty state */
.empty-row {
  text-align: center;
  color: var(--muted);
  padding: 48px 20px !important;
  font-size: 14px;
}

/* ── Responsive ────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  :root { --sidebar-w: 200px; }
  #files-table { font-size: 12px; }
}

@media (max-width: 640px) {
  #app { flex-direction: column; height: auto; overflow: auto; }
  #sidebar { width: 100%; max-height: 55vh; }
  #main { height: auto; overflow: visible; }
  #table-wrapper { overflow-x: auto; }
}
