/* Find a Gem News admin. Loaded after /assets/site.css and reuses its variables. */

/* The hidden attribute must win over display rules such as .btn { display: inline-flex }. */
.admin [hidden] { display: none !important; }
.admin-top { justify-content: space-between; }
.admin-title {
  font-size: 22px; margin: 0; display: inline-flex; align-items: center; gap: var(--s3);
}
.admin-links { display: flex; gap: var(--s2); flex-wrap: wrap; }

.admin .btn {
  font-family: inherit; font-size: 16px; cursor: pointer; min-height: 44px; line-height: 1.3;
}
.admin .btn[disabled] { opacity: 0.55; cursor: wait; transform: none; box-shadow: var(--lip); }
.btn-small { min-height: 36px !important; padding: var(--s1) var(--s3); font-size: 15px !important; }
.btn-mint { background: var(--mint); }
.btn-coral { background: var(--coral); }
.btn-grape { background: var(--grape); color: var(--cream); }
.btn-grape:hover { color: var(--ink); }
.btn.copied { background: var(--mint); }

/* Status line */
.status {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s3);
  margin-top: var(--s4); padding: var(--s2) var(--s3);
  border: var(--stroke); border-radius: var(--r-button); box-shadow: var(--lip);
  background: var(--cream-deep);
}
.status[hidden] { display: none; }
.status-ok { background: var(--mint); }
.status-error { background: var(--coral); }
.status-info { background: var(--sun); }
.status-close {
  font: inherit; font-weight: 800; background: transparent; border: 2px solid var(--ink);
  border-radius: var(--r-pill); padding: 0 var(--s3); cursor: pointer; color: var(--ink); flex: 0 0 auto;
}

/* Layout: one column on phones, list and tools left with the editor right on desktop. */
.admin-grid {
  display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s4);
  padding-top: var(--s4); padding-bottom: var(--s5); flex: 1 0 auto;
}
.admin-grid .panel { margin-bottom: 0; min-width: 0; }
@media (min-width: 900px) {
  .admin-grid {
    grid-template-columns: minmax(260px, 320px) minmax(0, 1fr);
    grid-template-areas: "list editor" "images editor" "help editor";
    grid-template-rows: auto auto 1fr;
    align-items: start;
  }
  .area-list { grid-area: list; }
  .area-images { grid-area: images; }
  .area-help { grid-area: help; }
  .area-editor { grid-area: editor; }
}

.panel-head { display: flex; align-items: center; flex-wrap: wrap; gap: var(--s2) var(--s3); margin-bottom: var(--s3); }
.panel-head h2 { margin: 0; flex: 1 1 auto; }
.admin h2 { margin-top: 0; }
.muted { opacity: 0.7; }
.hint { font-weight: 700; opacity: 0.7; font-size: 14px; }

/* Badges */
.badge {
  display: inline-block; font-size: 13px; font-weight: 800; border: 2px solid var(--ink);
  border-radius: var(--r-pill); padding: 0 var(--s2); white-space: nowrap;
}
.badge-draft { background: var(--cream-deep); }
.badge-published { background: var(--mint); }
.badge-dirty { background: var(--sun); }
.badge[hidden] { display: none; }

/* Post list */
.post-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s2); max-height: 50vh; overflow-y: auto; }
.post-item {
  width: 100%; text-align: left; font: inherit; color: var(--ink); cursor: pointer;
  background: var(--cream); border: 2px solid var(--ink); border-radius: var(--r-card);
  padding: var(--s2) var(--s3); display: grid; gap: var(--s1);
}
.post-item:hover { background: var(--cream-deep); }
.post-item.active { background: var(--sun); box-shadow: 0 3px 0 var(--ink); }
.post-title { font-weight: 800; }
.post-meta { display: flex; gap: var(--s2); align-items: center; font-size: 13px; }

/* Forms */
.editor { display: grid; gap: var(--s3); }
.field { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s1); }
.label { font-weight: 800; }
.admin input[type="text"], .admin input[type="email"], .admin textarea {
  width: 100%; font: inherit; font-weight: 700; color: var(--ink); background: var(--cream);
  border: var(--stroke); border-radius: var(--r-button); padding: var(--s2) var(--s3); min-height: 44px;
}
.admin textarea { resize: vertical; line-height: 1.45; }

/* Sign-in page (login.html) */
.login-panel { max-width: 440px; margin: var(--s5) auto; }
.login-panel .status { margin-bottom: var(--s3); }
#code { font-size: 22px; letter-spacing: 0.3em; max-width: 12em; }
.link-btn {
  background: none; border: 0; padding: var(--s1) 0; font: inherit; font-weight: 800; color: var(--ink);
  text-decoration: underline; cursor: pointer; min-height: 44px;
}
.link-btn[disabled] { opacity: 0.55; cursor: wait; }
#f-body { font-family: ui-monospace, Consolas, monospace; font-size: 15px; min-height: 260px; }
.admin input:focus, .admin textarea:focus { outline: 3px solid var(--sky); outline-offset: 2px; }
.admin input[type="file"] { font: inherit; max-width: 100%; }
.field-error { border-color: var(--coral) !important; outline: 3px solid var(--coral) !important; outline-offset: 2px; }

.actions { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; }
.actions .btn { margin-bottom: var(--s1); }

.confirm {
  background: var(--cream-deep); border: var(--stroke); border-radius: var(--r-card);
  padding: var(--s3); margin: var(--s2) 0;
}
.confirm[hidden] { display: none; }
.confirm p { margin-bottom: var(--s2); }

/* Preview */
.preview-heading { margin-top: var(--s5); }
.preview {
  border: 2px dashed var(--ink); border-radius: var(--r-card); padding: var(--s3);
  background: var(--cream); min-height: 80px;
}
.preview:empty { display: none; }
.preview img { max-width: 100%; height: auto; border-radius: var(--r-card); }
.preview figure { margin: 0 0 var(--s3); }
.preview ul, .preview ol { padding-left: var(--s5); }

/* Images */
.upload { display: grid; gap: var(--s3); margin-bottom: var(--s4); }
.upload .btn { justify-self: start; }
.image-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s3); }
.image-item {
  display: grid; grid-template-columns: 64px minmax(0, 1fr); gap: var(--s2) var(--s3); align-items: center;
  border: 2px solid var(--ink); border-radius: var(--r-card); padding: var(--s2); background: var(--cream);
}
.thumb {
  width: 64px; height: 64px; object-fit: cover; border-radius: 8px; border: 2px solid var(--ink);
  background: var(--cream-deep);
}
.image-info { display: grid; min-width: 0; }
.image-info code { overflow-wrap: anywhere; font-size: 14px; }
.image-info small { opacity: 0.7; }
.image-item .actions, .image-item .confirm { grid-column: 1 / -1; }
.image-item .btn { font-size: 14px; padding: var(--s1) var(--s2); min-height: 38px; }

/* Help */
.help { margin: 0; padding-left: var(--s4); display: grid; gap: var(--s2); }
.admin code {
  background: var(--cream-deep); border-radius: 6px; padding: 0 var(--s1);
  font-family: ui-monospace, Consolas, monospace; font-size: 0.92em;
}

@media (max-width: 480px) {
  .admin-title { font-size: 19px; }
  .actions .btn { flex: 1 1 auto; text-align: center; }
}
