/* Ziora Metadata Studio — cinematic dark UI */
:root {
  --bg: #0b0c10;
  --bg-2: #101218;
  --panel: #14161e;
  --panel-2: #191c26;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.14);
  --text: #eceef3;
  --muted: #8a90a2;
  --muted-2: #5f6577;
  --gold: #e8c37e;
  --gold-2: #d9a94e;
  --accent: #6ea8fe;
  --green: #57d38c;
  --amber: #f0b862;
  --red: #f0736b;
  --radius: 16px;
  --shadow: 0 24px 60px -20px rgba(0, 0, 0, 0.75);
  --font: 'Inter', system-ui, -apple-system, sans-serif;
  --serif: 'Fraunces', Georgia, serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(110, 168, 254, 0.08), transparent 60%),
    radial-gradient(1000px 500px at 0% 0%, rgba(232, 195, 126, 0.06), transparent 55%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
}
::selection { background: rgba(232, 195, 126, 0.28); }

.app { max-width: 1440px; margin: 0 auto; padding: 0 28px 60px; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 20px;
  padding: 18px 4px;
  background: linear-gradient(180deg, var(--bg) 55%, rgba(11, 12, 16, 0.6) 100%);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  height: 40px; display: grid; place-items: center;
  font-family: var(--serif); font-weight: 600; font-size: 22px; color: var(--gold);
}
.brand-mark img { height: 40px; width: auto; object-fit: contain; display: block; }
.brand-text { display: flex; flex-direction: column; line-height: 1.05; }
.brand-name { font-family: var(--serif); font-size: 20px; font-weight: 600; letter-spacing: 0.2px; }
.brand-sub { font-size: 11px; text-transform: uppercase; letter-spacing: 2px; color: var(--muted); }

.search-wrap { position: relative; max-width: 520px; width: 100%; justify-self: center; }
.search-icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted-2); }
#search {
  width: 100%; padding: 11px 14px 11px 42px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  color: var(--text); font-size: 14px; font-family: var(--font); outline: none; transition: 0.15s;
}
#search:focus { border-color: var(--line-strong); background: var(--panel-2); }
#search::placeholder { color: var(--muted-2); }

.status-pills { display: flex; gap: 8px; }
.pill {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 12px; border-radius: 999px; font-size: 12px; font-weight: 500;
  background: var(--panel); border: 1px solid var(--line); color: var(--muted); white-space: nowrap;
}
.pill .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted-2); }
.pill.ok { color: #cfe9d8; border-color: rgba(87, 211, 140, 0.3); }
.pill.ok .dot { background: var(--green); box-shadow: 0 0 8px var(--green); }
.pill.warn { color: #f2ddb5; border-color: rgba(240, 184, 98, 0.3); }
.pill.warn .dot { background: var(--amber); box-shadow: 0 0 8px var(--amber); }
.pill-select {
  background: transparent; border: none; outline: none; cursor: pointer;
  color: inherit; font: inherit; font-weight: 600; padding: 0 2px;
  max-width: 200px; text-overflow: ellipsis;
}
.pill-select:hover { color: #fff; }
.pill-select option { background: var(--panel); color: var(--text); font-weight: 500; }

/* ---------- Toolbar ---------- */
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 26px 4px 20px; flex-wrap: wrap; }
.toolbar-left { display: flex; align-items: baseline; gap: 14px; }
.page-title { font-family: var(--serif); font-size: 30px; font-weight: 600; }
.count-chip { font-size: 12px; color: var(--muted); background: var(--panel); border: 1px solid var(--line); padding: 4px 10px; border-radius: 999px; }
.toolbar-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.segmented { display: inline-flex; background: var(--panel); border: 1px solid var(--line); border-radius: 11px; padding: 3px; }
.seg { border: none; background: transparent; color: var(--muted); font: inherit; font-size: 13px; padding: 7px 13px; border-radius: 8px; cursor: pointer; transition: 0.15s; }
.seg:hover { color: var(--text); }
.seg.active { background: var(--panel-2); color: var(--text); box-shadow: inset 0 0 0 1px var(--line); }
.seg-select {
  background: var(--panel); border: 1px solid var(--line); border-radius: 11px;
  color: var(--text); font: inherit; font-size: 13px; padding: 8px 12px; cursor: pointer;
  outline: none; transition: 0.15s; max-width: 220px;
}
.seg-select:hover { border-color: var(--line-strong); }
.seg-select:focus { border-color: var(--line-strong); background: var(--panel-2); }
.seg-select option { background: var(--panel); color: var(--text); }

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid var(--line); background: var(--panel); color: var(--text);
  font: inherit; font-size: 13.5px; font-weight: 500; padding: 9px 15px; border-radius: 11px; cursor: pointer; transition: 0.15s;
}
.btn:hover { background: var(--panel-2); border-color: var(--line-strong); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.ghost { background: transparent; }
.btn.primary { background: linear-gradient(180deg, #2a2f3d, #20242f); border-color: var(--line-strong); }
.btn.primary:hover { background: linear-gradient(180deg, #323848, #262b37); }
.btn.accent { color: #1a1408; background: linear-gradient(145deg, var(--gold), var(--gold-2)); border-color: transparent; font-weight: 600; }
.btn.accent:hover { filter: brightness(1.06); }
.btn.lg { padding: 12px 22px; font-size: 15px; }

/* ---------- States ---------- */
.state { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 90px 0; text-align: center; color: var(--muted); }
.state h2 { font-family: var(--serif); font-size: 24px; color: var(--text); font-weight: 600; }
.empty-art { font-size: 56px; filter: grayscale(0.2); }
.spinner { width: 34px; height: 34px; border: 3px solid var(--line); border-top-color: var(--gold); border-radius: 50%; animation: spin 0.8s linear infinite; }
.spinner.sm { width: 18px; height: 18px; border-width: 2px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Grid ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 22px; }
.card { position: relative; cursor: pointer; border-radius: var(--radius); background: var(--panel); border: 1px solid var(--line); overflow: hidden; transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s; }
.card:hover { transform: translateY(-4px); border-color: var(--line-strong); box-shadow: var(--shadow); }
.poster { position: relative; aspect-ratio: 2 / 3; background: linear-gradient(160deg, #1b1e28, #0f1118); overflow: hidden; }
.poster img { width: 100%; height: 100%; object-fit: cover; display: block; }
.poster .noart { position: absolute; inset: 0; display: grid; place-items: center; font-size: 40px; color: var(--muted-2); }
.poster-badges { position: absolute; top: 10px; left: 10px; right: 10px; display: flex; justify-content: space-between; pointer-events: none; }
.badge { font-size: 11px; font-weight: 600; padding: 4px 8px; border-radius: 8px; background: rgba(8, 9, 13, 0.72); backdrop-filter: blur(6px); border: 1px solid var(--line); }
.badge.plat { color: var(--gold); }
.badge.warn { color: var(--amber); border-color: rgba(240, 184, 98, 0.35); }
.badge.trailer { color: var(--green); }
.card-grad { position: absolute; inset: 0; background: linear-gradient(180deg, transparent 55%, rgba(8, 9, 13, 0.92)); }
.card-cap { position: absolute; bottom: 0; left: 0; right: 0; padding: 12px 13px 13px; }
.card-title { font-size: 14px; font-weight: 600; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-meta { font-size: 12px; color: var(--muted); margin-top: 3px; display: flex; gap: 6px; align-items: center; }
.card-pushed { position: absolute; top: 10px; right: 10px; }

/* ---------- Drawer ---------- */
.drawer-scrim { position: fixed; inset: 0; background: rgba(4, 5, 8, 0.6); backdrop-filter: blur(3px); opacity: 0; pointer-events: none; transition: 0.25s; z-index: 50; }
.drawer-scrim.show { opacity: 1; pointer-events: auto; }
.drawer { position: fixed; top: 0; right: 0; height: 100%; width: min(560px, 94vw); background: var(--bg-2); border-left: 1px solid var(--line-strong); box-shadow: var(--shadow); transform: translateX(100%); transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1); z-index: 51; overflow-y: auto; }
.drawer.show { transform: translateX(0); }

.d-hero { position: relative; height: 220px; background: #0f1118; }
.d-hero img { width: 100%; height: 100%; object-fit: cover; opacity: 0.55; }
.d-hero-grad { position: absolute; inset: 0; background: linear-gradient(180deg, rgba(16,17,24,0.2), var(--bg-2)); }
.d-close { position: absolute; top: 16px; right: 16px; z-index: 2; }
.d-head { display: flex; gap: 18px; padding: 0 26px; margin-top: -70px; position: relative; z-index: 2; }
.d-poster { width: 118px; flex: none; aspect-ratio: 2/3; border-radius: 12px; overflow: hidden; border: 1px solid var(--line-strong); background: #14161e; box-shadow: var(--shadow); }
.d-poster img { width: 100%; height: 100%; object-fit: cover; }
.d-poster .noart { width: 100%; height: 100%; display: grid; place-items: center; font-size: 32px; color: var(--muted-2); }
.d-title-wrap { padding-top: 76px; }
.d-title { font-family: var(--serif); font-size: 24px; font-weight: 600; line-height: 1.15; }
.d-sub { color: var(--muted); font-size: 13px; margin-top: 6px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.d-body { padding: 22px 26px 40px; }
.d-section { margin-top: 26px; }
.d-section h4 { font-size: 12px; text-transform: uppercase; letter-spacing: 1.5px; color: var(--muted); margin-bottom: 12px; }
.d-synopsis { font-size: 14px; line-height: 1.6; color: #c9cdd8; }

.trailer-frame { position: relative; aspect-ratio: 16/9; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); background: #000; }
.trailer-frame iframe { width: 100%; height: 100%; border: 0; }
.no-trailer { padding: 22px; text-align: center; color: var(--muted); background: var(--panel); border: 1px dashed var(--line-strong); border-radius: 12px; font-size: 13px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 7px; padding: 6px 11px 6px 6px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); font-size: 12.5px; }
.chip img { width: 20px; height: 20px; border-radius: 5px; object-fit: cover; }
.chip .noimg { width: 20px; height: 20px; border-radius: 5px; background: var(--panel-2); display: grid; place-items: center; font-size: 10px; color: var(--muted); }
.chip .ctype { color: var(--muted-2); font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.5px; }
.genre-chip { padding: 5px 11px; border-radius: 999px; background: rgba(232,195,126,0.08); border: 1px solid rgba(232,195,126,0.22); color: var(--gold); font-size: 12px; }

.meta-table { display: grid; grid-template-columns: 130px 1fr; gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.meta-table .k, .meta-table .v { background: var(--panel); padding: 9px 13px; font-size: 13px; }
.meta-table .k { color: var(--muted); }
.meta-table .v { color: var(--text); word-break: break-word; }
.meta-table a { color: var(--accent); text-decoration: none; }
.meta-table a:hover { text-decoration: underline; }

.d-actions { display: flex; gap: 10px; margin-top: 28px; flex-wrap: wrap; }

/* Airtable preview */
.at-preview { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 4px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.at-row { display: grid; grid-template-columns: 160px 1fr; gap: 10px; padding: 7px 10px; border-radius: 8px; }
.at-row:nth-child(odd) { background: rgba(255,255,255,0.02); }
.at-row .fk { color: var(--gold); }
.at-row .fv { color: #c9cdd8; word-break: break-word; }

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; z-index: 60; display: none; }
.modal.show { display: block; }
.modal-scrim { position: absolute; inset: 0; background: rgba(4,5,8,0.62); backdrop-filter: blur(4px); }
.modal-card { position: relative; width: min(520px, 92vw); margin: 12vh auto 0; background: var(--panel); border: 1px solid var(--line-strong); border-radius: 18px; box-shadow: var(--shadow); overflow: hidden; animation: pop 0.2s ease; }
@keyframes pop { from { transform: translateY(10px) scale(0.98); opacity: 0; } }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 20px 22px; border-bottom: 1px solid var(--line); }
.modal-head h3 { font-family: var(--serif); font-size: 19px; font-weight: 600; }
.modal-body { padding: 22px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 22px; border-top: 1px solid var(--line); background: var(--bg-2); }
.icon-btn { width: 32px; height: 32px; border-radius: 9px; border: 1px solid var(--line); background: transparent; color: var(--muted); font-size: 20px; line-height: 1; cursor: pointer; transition: 0.15s; }
.icon-btn:hover { color: var(--text); background: var(--panel-2); }

.dropzone { border: 1.5px dashed var(--line-strong); border-radius: 14px; padding: 34px 20px; text-align: center; cursor: pointer; transition: 0.15s; background: var(--bg-2); }
.dropzone:hover, .dropzone.drag { border-color: var(--gold); background: rgba(232,195,126,0.05); }
.dropzone-icon { font-size: 34px; margin-bottom: 10px; }
.dropzone h4 { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.muted { color: var(--muted); font-size: 13px; }
.field-row { display: flex; align-items: center; justify-content: space-between; margin-top: 18px; }
.field-row label { font-size: 13px; color: var(--muted); }
.field-row select { background: var(--panel-2); color: var(--text); border: 1px solid var(--line); border-radius: 9px; padding: 8px 11px; font: inherit; font-size: 13px; }
.import-progress { display: flex; flex-direction: column; gap: 8px; margin-top: 18px; font-size: 13px; color: var(--muted); }
.ip-top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.ip-word {
  font-family: var(--serif); font-size: 15px; font-weight: 600; color: var(--text);
}
.ip-word::after { content: '…'; animation: ellipsis 1.4s steps(4, end) infinite; }
.ip-count { font-variant-numeric: tabular-nums; color: var(--muted-2); white-space: nowrap; }
.ip-bar { width: 100%; height: 7px; border-radius: 999px; background: var(--panel-2, rgba(255,255,255,0.06)); overflow: hidden; }
.ip-bar-fill {
  height: 100%; width: 0%; border-radius: 999px;
  background: linear-gradient(90deg, var(--gold), var(--gold-2));
  transition: width 0.35s ease;
}
.ip-bar-fill.indeterminate {
  width: 35% !important; animation: ip-slide 1.1s ease-in-out infinite;
}
.ip-sub { font-size: 12px; color: var(--muted-2); min-height: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@keyframes ellipsis { 0% { content: ''; } 25% { content: '.'; } 50% { content: '..'; } 75% { content: '...'; } }
@keyframes ip-slide { 0% { margin-left: -35%; } 100% { margin-left: 100%; } }

/* ---------- IMDb candidate picker ---------- */
.imdb-cands { display: flex; flex-direction: column; gap: 6px; }
.imdb-cand {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  padding: 7px 9px; border-radius: 10px; cursor: pointer;
  background: var(--panel); border: 1px solid var(--line); color: var(--text);
  font: inherit; transition: 0.15s;
}
.imdb-cand:hover { border-color: var(--line-strong); background: var(--panel-2); }
.imdb-cand img, .imdb-cand .ic-noart {
  width: 34px; height: 48px; flex: none; border-radius: 5px; object-fit: cover;
  background: var(--panel-2); display: grid; place-items: center; font-size: 18px;
}
.imdb-cand .ic-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.imdb-cand .ic-title { font-size: 13px; font-weight: 600; }
.imdb-cand .ic-sub { font-size: 11px; color: var(--muted-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Toasts ---------- */
.toasts { position: fixed; bottom: 24px; right: 24px; display: flex; flex-direction: column; gap: 10px; z-index: 80; }
.toast { padding: 13px 17px; border-radius: 12px; background: var(--panel-2); border: 1px solid var(--line-strong); color: var(--text); font-size: 13.5px; box-shadow: var(--shadow); transform: translateX(120%); transition: transform 0.3s cubic-bezier(0.2,0.8,0.2,1); max-width: 360px; }
.toast.show { transform: translateX(0); }
.toast.success { border-left: 3px solid var(--green); }
.toast.error { border-left: 3px solid var(--red); }
.toast.info { border-left: 3px solid var(--accent); }

@media (max-width: 720px) {
  .topbar { grid-template-columns: auto auto; }
  .search-wrap { order: 3; grid-column: 1 / -1; max-width: none; }
  .app { padding: 0 16px 40px; }
}
