/* uploadtin dashboard - dark, no framework. */

:root {
  --bg: #0f1115;
  --surface: #15181f;
  --surface-2: #1b1f28;
  --border: #262c38;
  --text: #e6e9ef;
  --muted: #8b93a3;
  --accent: #4f8cff;
  --danger: #ff5d5d;
  --ok: #4cd08f;
  --radius: 12px;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.hidden { display: none !important; }

/* ------------------------------------------------------------------ topbar */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand { font-size: 18px; font-weight: 700; letter-spacing: -0.02em; }
.brand .dot { color: var(--accent); }

.topbar-actions { display: flex; gap: 8px; align-items: center; }
.last-updated { color: var(--muted); font-size: 12px; }

.btn {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 12px;
  cursor: pointer;
  font-size: 13px;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.btn.danger { color: var(--danger); }
.btn.danger:hover { border-color: var(--danger); }

.muted { color: var(--muted); }

/* -------------------------------------------------------------------- tabs */

.tabs {
  display: flex;
  gap: 6px;
  padding: 12px 20px 0;
  flex-wrap: wrap;
}

.tab {
  background: transparent;
  color: var(--muted);
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 6px 14px;
  cursor: pointer;
  font-size: 13px;
}
.tab .count { opacity: 0.6; margin-left: 4px; }
.tab:hover { color: var(--text); }
.tab.active {
  color: var(--text);
  background: var(--accent-soft);
  border-color: var(--accent);
}

/* --------------------------------------------------------------- main area */

.wrap { padding: 16px 20px 48px; max-width: 1200px; margin: 0 auto; }

.banner {
  background: rgba(255, 93, 93, 0.12);
  border: 1px solid var(--danger);
  color: #ffb3b3;
  border-radius: var(--radius);
  padding: 10px 14px;
  margin-bottom: 16px;
}
.banner[data-kind="ok"] {
  background: rgba(76, 208, 143, 0.12);
  border-color: var(--ok);
  color: #b5f0d2;
}

/* ------------------------------------------------------------------- grid */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 14px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s;
}
.card:hover { border-color: var(--accent); transform: translateY(-2px); }

.thumb {
  aspect-ratio: 16 / 9;
  background: var(--surface-2);
  position: relative;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

.thumb-fallback {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
  font-weight: 800;
  color: rgba(255, 255, 255, 0.45);
  background: linear-gradient(135deg, #1b1f28, #242b3a);
}

.card-body { padding: 10px 12px 12px; }

.card-badges { display: flex; gap: 6px; margin-bottom: 6px; flex-wrap: wrap; }
.card-title {
  margin: 0 0 4px;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-meta { margin: 0; color: var(--muted); font-size: 12px; }

/* ---------------------------------------------------------------- badges */

.badge, .status {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
}
.badge-x         { background: #3a4048;  color: #eef1f5; }
.badge-instagram { background: rgba(225, 48, 108, 0.2); color: #ff7ab5; }
.badge-tiktok    { background: rgba(0, 224, 255, 0.14); color: #6ff0ff; }
.badge-facebook  { background: rgba(66, 103, 178, 0.25); color: #9db8ff; }

.status-pending    { background: var(--accent-soft); color: #a9c8ff; }
.status-publishing { background: rgba(245, 166, 35, 0.16); color: #ffce7d; }
.status-published  { background: rgba(76, 208, 143, 0.15); color: #8cecba; }
.status-failed     { background: rgba(255, 93, 93, 0.15); color: #ff9d9d; }

/* ------------------------------------------------------------- accounts */

.accounts {
  margin-top: 40px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.accounts-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}
.accounts-head h2 { margin: 0 0 2px; font-size: 15px; }
.accounts-head .hint { margin: 0; }
.accounts-actions { display: flex; gap: 8px; }
.accounts-actions .btn { text-decoration: none; white-space: nowrap; }
.hint { color: var(--muted); font-size: 12px; margin: 4px 0 10px; }

.account {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.account:last-child { border-bottom: none; }
.account-label { flex: 1; min-width: 0; }
.account-label strong { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.switch { position: relative; width: 38px; height: 22px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute;
  inset: 0;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  transition: 0.2s;
}
.slider::before {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  left: 2px;
  top: 2px;
  background: var(--muted);
  border-radius: 50%;
  transition: 0.2s;
}
.switch input:checked + .slider { background: var(--accent); border-color: var(--accent); }
.switch input:checked + .slider::before { transform: translateX(16px); background: #fff; }

/* ----------------------------------------------------------------- dialog */

.dialog {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 0;
  width: min(560px, 92vw);
  max-height: 90vh;
  overflow: auto;
}
.dialog::backdrop { background: rgba(0, 0, 0, 0.6); }

.dialog-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.dialog-thumb img { width: 100%; display: block; aspect-ratio: 16/9; object-fit: cover; }

.dialog h2 { margin: 16px 16px 4px; font-size: 16px; }
.dialog .card-meta { padding: 0 16px; }
.dialog a { margin: 0 16px; color: var(--accent); text-decoration: none; display: inline-block; }
.dialog a:hover { text-decoration: underline; }

.field-label { display: block; margin: 12px 16px 4px; font-size: 12px; color: var(--muted); }
#caption {
  display: block;
  width: calc(100% - 32px);
  margin: 0 16px;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font: inherit;
  resize: vertical;
}
#caption:focus { outline: none; border-color: var(--accent); }

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 16px 16px;
}

/* ---------------------------------------------------------------- empty */

.empty { color: var(--muted); text-align: center; padding: 60px 20px; font-size: 14px; }

/* ------------------------------------------------------------ publish modal */

.dialog-publish { width: min(680px, 94vw); }

.publish-body {
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-height: 52vh;
  overflow: auto;
}

.pub-group h4 {
  margin: 0 0 8px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.pub-account {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  margin-bottom: 8px;
}
.pub-account .switch { margin-top: 2px; }
.pub-account-main { flex: 1; min-width: 0; }
.pub-account textarea {
  width: 100%;
  margin-top: 6px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 8px;
  font: inherit;
  font-size: 12px;
  resize: vertical;
}
.pub-account textarea:focus { outline: none; border-color: var(--accent); }

/* ------------------------------------------------------------ job history */

.jobs { padding: 0 16px; margin-top: 10px; }
.jobs-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin: 14px 0 6px;
}
.job {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 6px;
  background: var(--surface-2);
  font-size: 13px;
}
.job-label { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.job-link { color: var(--muted); font-size: 12px; }
.job-link a { color: var(--accent); text-decoration: none; }
.job-error { color: var(--danger); font-size: 12px; }
@media (max-width: 560px) {
  .job { flex-wrap: wrap; }
}