/* Cravia admin — styles.
   Design system: brand.md (Netflix-style, dark cinematic, one red accent).
   Colors: Pure Black canvas, Obsidian/Carbon surfaces, Cravia Red #C1121F
   as the single chromatic accent. Inter font. No shadows, no borders on
   cards — depth comes from surface tones only. */

:root {
  --red: #c1121f;
  --black: #000000;
  --obsidian: #0f0f0f;
  --carbon: #232323;
  --charcoal: #2d2d2d;
  --slate: #393939;
  --ash: #5a5a5a;
  --steel: #808080;
  --fog: #b3b3b3;
  --white: #ffffff;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--black);
  color: var(--white);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

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

h1, h2, h3 { margin: 0; font-weight: 700; }
h1 { font-size: 24px; }
h2 { font-size: 20px; }

.muted { color: var(--fog); }
.small { font-size: 12px; }
.error { color: var(--red); font-size: 14px; margin: 8px 0 0; }

[hidden] { display: none !important; }

/* ---- Top bar ---- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  padding: 0 24px;
  background: var(--obsidian);
  border-bottom: 1px solid var(--carbon);
}

.brand {
  font-size: 20px;
  font-weight: 900;
  letter-spacing: -0.02em;
  color: var(--white);
  line-height: 1;
}
.brand span { color: var(--red); }

.topbar-right { display: flex; align-items: center; gap: 12px; }
.auth-state { color: var(--steel); font-size: 12px; }
.auth-state.on { color: var(--fog); }

/* ---- Layout ---- */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 24px 64px;
}

section { margin-bottom: 64px; }
section:last-child { margin-bottom: 0; }

/* ---- Buttons (brand.md Primary CTA) ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: inherit;
  font-size: 16px;
  font-weight: 500;
  line-height: 1;
  padding: 12px 24px;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  background: none;
  color: var(--white);
  text-decoration: none;
  white-space: nowrap;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary { background: var(--red); color: var(--white); }
.btn-primary:hover { background: #a50e1a; }

.btn-ghost {
  background: transparent;
  color: var(--fog);
  border-color: var(--slate);
  font-size: 14px;
  padding: 10px 16px;
}
.btn-ghost:hover { background: var(--carbon); color: var(--white); }

.btn-danger {
  background: transparent;
  color: var(--red);
  border-color: var(--slate);
  font-size: 14px;
  padding: 8px 12px;
}
.btn-danger:hover { background: var(--carbon); }

.btn-block { width: 100%; }

.btn-sm { font-size: 14px; padding: 8px 12px; }

/* ---- Forms ---- */
label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: var(--fog);
  margin-bottom: 16px;
}
label:last-child { margin-bottom: 0; }

input[type="text"],
input[type="number"],
input[type="url"],
input[type="password"],
input[type="search"],
select,
textarea {
  display: block;
  width: 100%;
  margin-top: 8px;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 14px;
  color: var(--white);
  background: var(--charcoal);
  border: 1px solid var(--slate);
  border-radius: 4px;
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--red); }
textarea { resize: vertical; min-height: 72px; }

input[type="file"] {
  display: block;
  width: 100%;
  margin-top: 8px;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 14px;
  color: var(--fog);
  background: var(--charcoal);
  border: 1px solid var(--slate);
  border-radius: 4px;
  cursor: pointer;
}
input[type="file"]::file-selector-button {
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  color: var(--white);
  background: var(--carbon);
  border: 1px solid var(--slate);
  border-radius: 4px;
  padding: 6px 12px;
  margin-right: 12px;
  cursor: pointer;
}

select { cursor: pointer; }

.file-status { display: block; margin-top: 8px; font-size: 12px; color: var(--steel); }
.file-status.ok { color: var(--fog); }

/* ---- Login ---- */
.login-view {
  display: flex;
  justify-content: center;
  padding-top: 48px;
}
.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--obsidian);
  border-radius: 8px;
  padding: 32px;
}
.login-card h1 { margin-bottom: 8px; }
.login-card > p { margin: 0 0 24px; }
.login-card form { margin-bottom: 24px; }

/* ---- Stats ---- */
.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 32px;
}
.stat {
  background: var(--obsidian);
  border-radius: 8px;
  padding: 12px;
}
.stat-num {
  display: block;
  font-size: 24px;
  font-weight: 900;
  line-height: 1.2;
}
.stat-label { display: block; font-size: 12px; color: var(--steel); margin-top: 4px; }

/* ---- Toolbar ---- */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.toolbar-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.toolbar-actions input[type="search"] { width: 220px; margin-top: 0; }
.toolbar-actions select { width: 160px; margin-top: 0; }

/* ---- Video table ---- */
.table-wrap {
  background: var(--obsidian);
  border-radius: 8px;
  padding: 12px;
  overflow-x: auto;
  margin-bottom: 64px;
}
.video-table { width: 100%; border-collapse: collapse; }
.video-table th {
  text-align: left;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--steel);
  padding: 8px 12px;
  border-bottom: 1px solid var(--carbon);
  white-space: nowrap;
}
.video-table td {
  padding: 12px;
  border-bottom: 1px solid var(--carbon);
  vertical-align: middle;
}
.video-table tr:last-child td { border-bottom: none; }
.video-table tbody tr:hover { background: var(--carbon); }

.cell-title { display: flex; align-items: center; gap: 12px; min-width: 240px; }
.thumb {
  flex: 0 0 auto;
  width: 64px;
  height: 36px;
  object-fit: cover;
  border-radius: 4px;
  background: var(--carbon);
  display: block;
}
.cell-title .title-text { font-weight: 500; }
.cell-title .title-sub { font-size: 12px; color: var(--steel); margin-top: 2px; }

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--fog);
  background: var(--carbon);
  border-radius: 4px;
  padding: 4px 8px;
  white-space: nowrap;
}
.status-pill::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ash);
}
.status-pill.published::before { background: var(--red); }
.status-pill.published { color: var(--white); }

.row-actions { display: flex; gap: 8px; white-space: nowrap; }

/* ---- Panels (bulk import, categories) ---- */
.panel {
  background: var(--obsidian);
  border-radius: 8px;
  padding: 24px;
  margin-bottom: 64px;
}
.panel h2 { margin-bottom: 8px; }
.panel > p { margin: 0 0 16px; }
.panel > p:last-child { margin-bottom: 0; }

.csv-cols {
  display: block;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 12px;
  color: var(--fog);
  background: var(--carbon);
  border-radius: 4px;
  padding: 12px;
  overflow-x: auto;
  white-space: nowrap;
  margin-bottom: 16px;
}

.bulk-row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.bulk-row input[type="file"] { flex: 1; min-width: 240px; margin-top: 0; }

.bulk-result { margin-top: 16px; font-size: 14px; }
.bulk-result p { margin: 4px 0; }
.bulk-result ul { margin: 8px 0 0; padding-left: 20px; color: var(--red); }
.bulk-result .ok { color: var(--fog); }

.category-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}
.category-list li {
  background: var(--carbon);
  border-radius: 8px;
  padding: 12px;
  min-width: 160px;
}
.category-list .cat-name { font-weight: 700; display: block; }
.category-list .cat-slug { font-size: 12px; color: var(--steel); display: block; margin-top: 2px; }
.category-list .cat-count { font-size: 12px; color: var(--fog); display: block; margin-top: 8px; }

/* ---- Modal ---- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 48px 16px;
  background: rgba(0, 0, 0, 0.7);
  overflow-y: auto;
}
.modal-card {
  width: 100%;
  max-width: 640px;
  background: var(--obsidian);
  border-radius: 8px;
  padding: 24px;
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}
.modal-head h2 { font-size: 20px; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 24px;
}

/* ---- Toast ---- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 100;
  background: var(--carbon);
  border: 1px solid var(--slate);
  border-radius: 8px;
  color: var(--white);
  font-size: 14px;
  padding: 12px 24px;
  max-width: 90vw;
}

/* ---- Responsive ---- */
@media (max-width: 720px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .form-row { grid-template-columns: 1fr; }
  .toolbar-actions input[type="search"],
  .toolbar-actions select { width: 100%; }
  .toolbar-actions { width: 100%; }
  .container { padding: 24px 16px 48px; }
}
