/* Styles for the login page and the dashboard. */

:root {
  color-scheme: light dark;
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #eef0f4;
  --border: #dde1e7;
  --text: #171a1f;
  --muted: #5f6775;
  --accent: #2d6cdf;
  --accent-hover: #2459bb;
  --accent-text: #ffffff;
  --danger: #c43d3d;
  --success: #23864b;
  --shadow: 0 1px 2px rgb(0 0 0 / 6%), 0 6px 16px rgb(0 0 0 / 5%);
  --radius: 10px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --surface: #181b21;
    --surface-2: #21252d;
    --border: #2c313a;
    --text: #e7e9ee;
    --muted: #98a1b0;
    --accent: #5b8def;
    --accent-hover: #7da5f3;
    --accent-text: #0b1020;
    --danger: #ef7070;
    --success: #4cc27f;
    --shadow: none;
  }
}

* { box-sizing: border-box; }

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

h1, h2 { margin: 0; line-height: 1.2; }
a { color: var(--accent); }
code, pre { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: 13px; }
.muted { color: var(--muted); }
[hidden] { display: none !important; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Buttons */

.button {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 14px;
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}
.button:hover { border-color: var(--muted); }
.button:disabled { opacity: 0.6; cursor: default; }
.button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.button.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.button.small { padding: 4px 10px; font-size: 13px; }
.button.danger { color: var(--danger); }
.button.danger:hover { border-color: var(--danger); }

/* Login */

.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }

.login-card {
  width: min(100%, 340px);
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px;
  box-shadow: var(--shadow);
}
.login-card .logo { align-self: center; }
.login-card h1 { font-size: 20px; text-align: center; margin-bottom: 8px; }
.login-card label { font-weight: 500; font-size: 14px; }
.login-card input {
  font: inherit;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
}
.login-card .button { margin-top: 6px; padding: 10px; }
.error { color: var(--danger); margin: 0; font-size: 14px; }

/* Dashboard header */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px max(16px, calc((100% - 1200px) / 2 + 16px));
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand h1 { font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display: flex; align-items: center; gap: 14px; font-size: 14px; }
.topbar-actions form { margin: 0; }

.page { max-width: 1200px; margin: 0 auto; padding: 24px 16px 64px; }

/* Upload area */

.drop-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 36px 16px;
  text-align: center;
  background: var(--surface);
  border: 2px dashed var(--border);
  border-radius: 14px;
  cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s;
}
.drop-zone:hover, .drop-zone.active {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 7%, var(--surface));
}
.drop-zone p { margin: 0; }
.drop-title { font-size: 17px; font-weight: 600; }
.drop-icon {
  width: 36px;
  height: 36px;
  margin-bottom: 6px;
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.link-text { color: var(--accent); text-decoration: underline; }

.upload-options {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 20px;
  margin-top: 12px;
  font-size: 14px;
}
.option { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.option input[type="checkbox"] { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); }
.option input[type="text"] { width: 14em; max-width: 60vw; }
.option select, .option input[type="text"] {
  font: inherit;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
}
.option-help { margin: 0; font-size: 13px; }

/* A frame around the whole window while a file is dragged over it. */
body.dragging::after {
  content: "Drop to upload";
  position: fixed;
  inset: 12px;
  display: grid;
  place-items: center;
  border: 3px dashed var(--accent);
  border-radius: 16px;
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  color: var(--accent);
  font-size: 24px;
  font-weight: 600;
  pointer-events: none;
  z-index: 20;
}

/* Upload queue */

.queue { list-style: none; margin: 16px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }

.upload {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  padding: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.upload-preview {
  width: 48px;
  height: 48px;
  border-radius: 6px;
  object-fit: cover;
  background: var(--surface-2);
}
.upload-preview.icon { display: grid; place-items: center; color: var(--muted); font-size: 18px; }
.upload-body { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.upload-name { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.upload-status { font-size: 13px; color: var(--muted); }
.progress { height: 4px; border-radius: 2px; background: var(--surface-2); overflow: hidden; }
.progress-bar { width: 0; height: 100%; background: var(--accent); transition: width 0.15s; }
.upload.done .progress-bar { background: var(--success); }
.upload.done .progress, .upload.failed .progress { display: none; }
.upload.failed .upload-status { color: var(--danger); }

.link-row { display: flex; gap: 6px; align-items: center; }
.link-field {
  flex: 1;
  min-width: 0;
  font: 13px ui-monospace, "Cascadia Code", Consolas, monospace;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
}

/* File grid */

.section-title { font-size: 16px; margin: 32px 0 12px; }
.empty { margin: 0; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 150px), 1fr));
  gap: 12px;
}

.card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.card-thumb {
  position: relative;
  display: block;
  aspect-ratio: 1;
  overflow: hidden;
  background: var(--surface-2);
}
.card-thumb img, .card-thumb video { width: 100%; height: 100%; object-fit: cover; display: block; }
.badges { position: absolute; top: 8px; left: 8px; display: flex; gap: 4px; }
.badge {
  padding: 1px 8px;
  border-radius: 999px;
  background: rgb(0 0 0 / 65%);
  color: #fff;
  font-size: 12px;
  font-weight: 500;
}
.card-body { padding: 10px; display: flex; flex-direction: column; gap: 2px; }
.card-title { display: flex; align-items: center; gap: 4px; }
.card-name { flex: 1; min-width: 0; font-weight: 500; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rename-button {
  flex: none;
  display: grid;
  place-items: center;
  padding: 3px;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--muted);
  cursor: pointer;
}
.rename-button:hover { color: var(--text); background: var(--surface-2); }
.card-meta { font-size: 12px; color: var(--muted); }
.card-actions { display: flex; gap: 4px; margin-top: 8px; }
.card-actions .button { padding: 4px 7px; }
.card-actions .icon-button { margin-left: auto; display: grid; place-items: center; padding: 4px 6px; }
.icon-button svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.more { display: flex; justify-content: center; margin-top: 20px; }

/* API help */

.api-help {
  margin-top: 40px;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
}
.api-help summary { cursor: pointer; font-weight: 500; }
.api-help pre {
  overflow-x: auto;
  padding: 10px 12px;
  background: var(--surface-2);
  border-radius: 6px;
}

/* Toast message */

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  max-width: calc(100% - 32px);
  padding: 10px 16px;
  border-radius: 8px;
  background: var(--text);
  color: var(--bg);
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 6px 20px rgb(0 0 0 / 25%);
  z-index: 30;
}
.toast.error { background: var(--danger); color: #fff; }

.offscreen { position: fixed; top: -1000px; left: -1000px; opacity: 0; }

@media (max-width: 520px) {
  #stats { display: none; }
  .drop-zone { padding: 28px 16px; }
  .grid { gap: 10px; }
  .card-body { padding: 8px; }
}
