/* Appmaker Studio — admin styling.
   Deliberately plain and dense: this is a tool, not a landing page. */

:root {
  --bg: #0f1117;
  --panel: #171a23;
  --panel-2: #1e222d;
  --line: #2a2f3d;
  --text: #e6e8ee;
  --muted: #98a0b3;
  --accent: #f0b429;
  --accent-ink: #2a1f00;
  --danger: #ef4444;
  --ok: #22c55e;
  --radius: 8px;
}

* { box-sizing: border-box; }

/* Must outrank the `display` rules below (.modal, .banner, .card-body), which
   are more specific than the user-agent's [hidden] { display: none } and would
   otherwise keep hidden elements on screen. */
[hidden] { display: none !important; }

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

button, input, select, textarea { font: inherit; color: inherit; }

/* ------------------------------------------------------------------ login */

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

.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 32px;
  display: flex;
  flex-direction: column;
}

.login-mark, .brand-mark {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 800;
  letter-spacing: .5px;
}

.login-card h1 { margin: 16px 0 2px; font-size: 20px; }
.login-sub { margin: 0 0 22px; color: var(--muted); font-size: 13px; }
.login-card label { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.login-card input { margin-bottom: 16px; }
.login-error {
  margin: 14px 0 0;
  padding: 10px 12px;
  border-radius: var(--radius);
  background: rgba(239, 68, 68, .12);
  border: 1px solid rgba(239, 68, 68, .4);
  color: #fca5a5;
  font-size: 13px;
}

/* ----------------------------------------------------------------- shell */

.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 20px;
  height: 56px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { width: 30px; height: 30px; border-radius: 8px; font-size: 12px; }
.brand-name { font-weight: 650; }

.tabs { display: flex; gap: 4px; }
.tabs button {
  background: none;
  border: 0;
  padding: 8px 14px;
  border-radius: var(--radius);
  color: var(--muted);
  cursor: pointer;
}
.tabs button:hover { background: var(--panel-2); color: var(--text); }
.tabs button.active { background: var(--panel-2); color: var(--text); font-weight: 600; }

.who { margin-left: auto; display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 13px; }

main { padding: 20px; max-width: 1100px; margin: 0 auto; }

/* ---------------------------------------------------------------- banners */

.banner {
  margin: 12px 20px 0;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.banner-warn {
  background: rgba(240, 180, 41, .12);
  border: 1px solid rgba(240, 180, 41, .45);
  color: #fcd996;
}

/* --------------------------------------------------------------- controls */

input, select, textarea {
  width: 100%;
  padding: 9px 11px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
textarea { min-height: 130px; resize: vertical; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; }

button.primary, button.ghost, button.danger {
  padding: 9px 15px;
  border-radius: var(--radius);
  cursor: pointer;
  border: 1px solid var(--line);
  background: var(--panel-2);
  white-space: nowrap;
}
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 650; }
button.primary:disabled { opacity: .45; cursor: not-allowed; }
button.ghost:hover { border-color: var(--muted); }
button.danger { color: #fca5a5; border-color: rgba(239,68,68,.4); }
button.link {
  background: none; border: 0; color: var(--accent);
  cursor: pointer; padding: 0; text-decoration: underline;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  flex-wrap: wrap;
}
.toolbar-bottom { padding-top: 4px; }
.toolbar label { color: var(--muted); font-size: 13px; }
.toolbar select { width: auto; min-width: 220px; }
.grow { flex: 1; }

.dirty-flag { color: var(--accent); font-size: 13px; font-weight: 600; }
.muted { color: var(--muted); }
.pad { padding: 0 2px 12px; }

/* ---------------------------------------------------------------- widgets */

.editor { display: flex; flex-direction: column; gap: 10px; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  background: var(--panel-2);
  cursor: pointer;
}
.card-head .idx {
  min-width: 24px; height: 24px;
  display: grid; place-items: center;
  border-radius: 6px;
  background: var(--bg);
  color: var(--muted);
  font-size: 12px;
}
.card-head .type { font-weight: 640; }
.card-head .sub { color: var(--muted); font-size: 12.5px; }
.card-head .spacer { flex: 1; }
.card-head button {
  background: none; border: 1px solid var(--line);
  border-radius: 6px; width: 28px; height: 28px;
  cursor: pointer; color: var(--muted);
}
.card-head button:hover { color: var(--text); border-color: var(--muted); }
.card-head button:disabled { opacity: .3; cursor: not-allowed; }

.card-body { padding: 14px; display: flex; flex-direction: column; gap: 14px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > label { font-size: 12px; color: var(--muted); }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 720px) { .row { grid-template-columns: 1fr; } }

.item {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--bg);
}
.item-head { display: flex; align-items: center; gap: 8px; }
.item-head .label { font-size: 12px; color: var(--muted); flex: 1; }

.thumb-row { display: flex; align-items: center; gap: 12px; }
.thumb {
  width: 110px; height: 62px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  flex: none;
}
.thumb-meta { font-size: 12px; color: var(--muted); word-break: break-all; }

.form-card { max-width: 420px; padding: 18px; display: flex; flex-direction: column; gap: 6px; }
.form-card h3 { margin: 0 0 8px; font-size: 15px; }
.form-card label { font-size: 12px; color: var(--muted); margin-top: 8px; }
.form-card button { margin-top: 16px; }
.form-msg { margin: 12px 0 0; font-size: 13px; }
.form-msg.ok { color: var(--ok); }
.form-msg.bad { color: #fca5a5; }

/* --------------------------------------------------------------- restore */

.snap {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.snap .meta { flex: 1; }
.snap .meta strong { font-weight: 600; }
.snap .meta div { color: var(--muted); font-size: 12.5px; }

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

.modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.66);
  display: grid; place-items: center;
  padding: 24px; z-index: 50;
}
.modal-card {
  width: 100%; max-width: 860px; max-height: 84vh;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  display: flex; flex-direction: column;
}
.modal-head, .modal-tools {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}
.modal-head strong { flex: 1; }
.media-grid {
  padding: 14px 16px;
  overflow: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  gap: 12px;
}
.media-tile { cursor: pointer; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); background: var(--bg); }
.media-tile:hover { border-color: var(--accent); }
.media-tile img { width: 100%; height: 92px; object-fit: cover; display: block; }
.media-tile span { display: block; padding: 6px 8px; font-size: 11.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ----------------------------------------------------------------- toast */

.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-left: 4px solid var(--ok);
  border-radius: var(--radius);
  padding: 12px 18px;
  max-width: 620px;
  box-shadow: 0 10px 30px rgba(0,0,0,.5);
  z-index: 80;
}
.toast.bad { border-left-color: var(--danger); }
