/* Infinity Ecosystem — the office side. Plain CSS, no build step: this app has
   one screen that matters and adding a toolchain to it would cost more than it
   saves. */

:root {
  --bg: #f8fafc;
  --card: #ffffff;
  --fg: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --primary: #0f766e;
  --danger: #dc2626;
  --warn: #b45309;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1120; --card: #111827; --fg: #e2e8f0;
    --muted: #94a3b8; --border: #1f2937;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0; background: var(--bg); color: var(--fg);
  font-family: "Cairo", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.7;
}

/* ── chrome ─────────────────────────────────────────────────────────────── */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; padding: 0.7rem 1.1rem;
  background: var(--card); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.logo { display: flex; align-items: center; gap: 0.5rem; font-weight: 700; color: inherit; text-decoration: none; }
.logo-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 1.85rem; height: 1.85rem; border-radius: 50%;
  background: var(--primary); color: #fff; font-size: 1.1rem; font-weight: 700;
}
.logo-mark.big { width: 3rem; height: 3rem; font-size: 1.6rem; margin: 0 auto 0.6rem; }
.topbar-right { display: flex; align-items: center; gap: 0.75rem; }
.topbar-note { color: var(--muted); font-size: 0.85rem; }

.wrap { max-width: 68rem; margin: 0 auto; padding: 1.25rem 1.1rem 4rem; }
.back { color: var(--muted); text-decoration: none; font-size: 0.9rem; }
.back:hover { color: var(--primary); }

.page-head { margin: 0.75rem 0 1.25rem; }
.page-head h1 { margin: 0.15rem 0 0; font-size: 1.6rem; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.on { color: var(--primary); font-weight: 700; }
.err { color: var(--danger); font-weight: 600; }
.warn { color: var(--warn); }
.empty { padding: 1.5rem 0; }

/* ── cards and layout ───────────────────────────────────────────────────── */
.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 10px; padding: 1rem 1.1rem; margin-bottom: 1rem;
}
.card h2 { margin: 0 0 0.25rem; font-size: 1.05rem; }
.cols { display: grid; grid-template-columns: 1fr; gap: 1rem; }
/* A grid track's automatic minimum is min-content, not zero, so ONE unbreakable
   child — a long share URL, a nowrap filename — makes the whole column wider
   than the phone and the entire page scrolls sideways. Measured at 360px: the
   columns were 882px inside a 360px body. */
.cols > * { min-width: 0; }
@media (min-width: 60rem) { .cols { grid-template-columns: 2fr 1fr; align-items: start; } }
.col-side { position: sticky; top: 4.2rem; }
@media (max-width: 60rem) { .col-side { position: static; } }

/* ── forms ──────────────────────────────────────────────────────────────── */
.grid-form {
  display: grid; gap: 0.75rem; margin-top: 0.75rem;
  grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
}
.grid-form .span-2 { grid-column: 1 / -1; }
label { display: block; font-size: 0.85rem; color: var(--muted); font-weight: 600; }
input, textarea, select {
  width: 100%; margin-top: 0.25rem; padding: 0.5rem 0.6rem;
  border: 1px solid var(--border); border-radius: 6px;
  background: var(--bg); color: var(--fg);
  font: inherit; font-size: 0.95rem;
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--primary); outline-offset: 1px; }
textarea { resize: vertical; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  padding: 0.5rem 1rem; border: 1px solid transparent; border-radius: 6px;
  background: var(--primary); color: #fff; font: inherit; font-weight: 600;
  cursor: pointer; text-decoration: none;
}
.btn:hover { opacity: 0.9; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-ghost { background: transparent; color: var(--fg); border-color: var(--border); }
.btn-danger { background: var(--danger); }
.btn-sm { padding: 0.32rem 0.7rem; font-size: 0.85rem; }
.full { width: 100%; }

.icon {
  background: none; border: 1px solid var(--border); border-radius: 5px;
  padding: 0.2rem 0.45rem; cursor: pointer; color: var(--muted);
  font: inherit; font-size: 0.8rem; line-height: 1.2;
}
.icon:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.icon:disabled { opacity: 0.3; cursor: not-allowed; }
.icon-danger:hover { border-color: var(--danger); color: var(--danger); }
.icon-xs { padding: 0.1rem 0.35rem; font-size: 0.7rem; }

/* ── unit list ──────────────────────────────────────────────────────────── */
.unit-grid { display: grid; gap: 0.75rem; grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr)); margin-bottom: 1.5rem; }
.unit-card {
  display: block; background: var(--card); border: 1px solid var(--border);
  border-radius: 10px; padding: 0.9rem 1rem; text-decoration: none; color: inherit;
}
.unit-card:hover { border-color: var(--primary); }
.unit-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 0.6rem; }
.unit-code { font-size: 0.78rem; color: var(--muted); font-family: ui-monospace, monospace; }
.unit-name { font-weight: 700; }
.unit-meta { color: var(--muted); font-size: 0.85rem; margin-top: 0.4rem; }
.pill {
  font-size: 0.72rem; padding: 0.1rem 0.55rem; border-radius: 999px;
  border: 1px solid var(--border); color: var(--muted); white-space: nowrap;
}
.pill-on { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ── media rows ─────────────────────────────────────────────────────────── */
.media-list { display: flex; flex-direction: column; gap: 0.5rem; margin: 0.85rem 0; }
.media-row {
  display: flex; align-items: center; gap: 0.75rem;
  border: 1px solid var(--border); border-radius: 8px; padding: 0.5rem;
}
.media-row-warn { border-color: var(--warn); }
.thumb {
  width: 4rem; height: 4rem; flex: 0 0 auto; border-radius: 6px; overflow: hidden;
  background: var(--bg); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb-video { font-size: 0.72rem; color: var(--muted); }
.media-info { min-width: 0; flex: 1 1 auto; }
.media-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cover-tag { color: var(--primary); }
.media-actions { display: flex; gap: 0.25rem; flex: 0 0 auto; }
.media-actions form { display: inline; }
.upload { border-top: 1px solid var(--border); padding-top: 0.9rem; }

/* ── rooms ──────────────────────────────────────────────────────────────── */
.room-block { border: 1px solid var(--border); border-radius: 8px; padding: 0.75rem 0.85rem; margin: 0.6rem 0; background: var(--bg); }
.room-head { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; }
.finish-list { list-style: none; margin: 0.6rem 0 0; padding: 0; display: flex; flex-direction: column; gap: 0.2rem; }
.finish-list li {
  display: flex; align-items: baseline; justify-content: space-between; gap: 0.75rem;
  border-top: 1px solid var(--border); padding-top: 0.25rem; font-size: 0.92rem;
}
.finish-form, .room-form { display: flex; gap: 0.4rem; margin-top: 0.6rem; flex-wrap: wrap; }
.finish-form input, .room-form input { flex: 1 1 9rem; margin-top: 0; width: auto; }
.room-form { border-top: 1px solid var(--border); padding-top: 0.85rem; margin-top: 0.85rem; }

/* ── publish panel ──────────────────────────────────────────────────────── */
.link-box {
  margin: 0.75rem 0 0.5rem; padding: 0.5rem 0.6rem;
  background: var(--bg); border: 1px solid var(--border); border-radius: 6px;
  font-size: 0.75rem; word-break: break-all; font-family: ui-monospace, monospace;
}
.link-actions { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.danger-details { margin-top: 0.9rem; border-top: 1px solid var(--border); padding-top: 0.7rem; }
.danger-details summary { cursor: pointer; color: var(--muted); font-size: 0.82rem; }
.danger-details summary:hover { color: var(--danger); }

/* ── login ──────────────────────────────────────────────────────────────── */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 1rem; }
.login-box {
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  padding: 2rem 1.75rem; width: 22rem; max-width: 100%; text-align: center;
}
.login-box h1 { margin: 0; font-size: 1.2rem; }
.login-box label { text-align: start; margin-top: 0.9rem; }
.login-box .btn { margin-top: 1.1rem; }

/* ---- Mobile: the office opens this on a phone on site --------------------- */
/* Measured, not guessed: the icon buttons in the media and finishes rows were
   under 40px, and a mis-tap there deletes a photo. */
@media (max-width: 34rem) {
  /* 40px everywhere, including the small variant: these buttons DELETE things,
     and 36px was measurably under the threshold on a 360px phone. */
  .icon, .icon-xs { min-height: 2.5rem; min-width: 2.5rem; }
  .back, .logo, .topbar-right .btn { min-height: 2.75rem; display: inline-flex; align-items: center; }
  .btn-sm { padding: 0.55rem 0.9rem; }
  .link-actions .btn { flex: 1 1 auto; min-height: 2.5rem; }
  .media-actions { flex-wrap: wrap; justify-content: flex-end; gap: 0.35rem; }
  .thumb { width: 3.25rem; height: 3.25rem; }
  /* Stacked, because side-by-side inputs at 360px leave no room to type. */
  .finish-form, .room-form { flex-direction: column; align-items: stretch; }
  .finish-form input, .room-form input { flex: 1 1 auto; }
  .topbar { flex-wrap: wrap; gap: 0.5rem; }
  .link-box { font-size: 0.7rem; }
}
