/* Admin panel - a separate, simpler layout from the public site's
   3-column reading grid (a post edit form has no use for a marginalia
   column or a table of contents). Reuses the public site's theme
   system as-is: same :root/data-theme CSS custom properties, same
   gear-dropdown theme picker partial (layouts/_theme_picker.html.erb),
   just without the 3-column structure around it. */

.admin-header {
  padding: 0.85rem 2rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 100;
}
/* same reasoning as .site-header-inner in application.css: the bar
   spans full width, only the content is capped/centered, so the gear
   dropdown's flyout submenu never runs off a wide monitor's edge. */
.admin-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem 1.5rem;
  width: 90%;
  max-width: 80rem;
  margin: 0 auto;
}
.admin-header .brand {
  font-weight: bold;
  letter-spacing: 0.02em;
  color: var(--fg);
  text-decoration: none;
  font-size: 1.2rem;
  white-space: nowrap;
}

.admin-nav {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  flex-wrap: wrap;
  /* first item to shrink/wrap when the header runs out of room - brand
     and the theme/sign-out controls matter more to keep in place */
  flex: 1 1 auto;
}
.admin-nav-link {
  color: var(--fg-dim);
  text-decoration: none;
  font-size: 0.98rem;
}
.admin-nav-link:hover { color: var(--fg); }
.admin-nav-link.active { color: var(--accent); font-weight: bold; }

.admin-header-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.admin-signout-form { display: inline-flex; }

/* mobile-only duplicate of the header's icon-only sign-out button,
   living inside #admin-nav-drawer - see the max-width:880px block
   below for why the header's own copy disappears there. */
.admin-drawer-signout-form { display: block; }
.admin-drawer-signout {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  background: none;
  border: none;
  border-top: 1px solid var(--border);
  color: var(--fg-dim);
  padding: 0.6rem 0.2rem 0.2rem;
  margin-top: 0.4rem;
  cursor: pointer;
}
.admin-drawer-signout:hover { color: var(--fg); }
.admin-drawer-signout svg { width: 18px; height: 18px; flex-shrink: 0; }

.admin-main {
  max-width: 68rem;
  margin: 0 auto;
  padding: 2rem;
}

.admin-page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.admin-page-header h1 { margin: 0; font-size: 1.6rem; font-weight: 600; }

/* the featured-post toggle - an outline star that fills solid yellow
   once featured, same "star" affordance as GitHub/most bookmarking
   UIs. fill is controlled here, not in the SVG markup (which stays
   fill="none") - a real CSS class toggling one property, not two
   copies of the icon. */
.star-toggle-form { display: inline; }
.star-toggle {
  display: inline-flex;
  vertical-align: middle;
  margin-left: 0.4rem;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.2rem;
  color: var(--fg-dim);
}
.star-toggle svg { width: 22px; height: 22px; }
.star-toggle:hover { color: #e6b800; }
.star-toggle.featured { color: #e6b800; }
.star-toggle.featured svg { fill: #e6b800; }
.admin-page-actions { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.admin-import-form { display: flex; align-items: center; gap: 0.5rem; }
.admin-import-form input[type="file"] {
  font: inherit;
  font-size: 0.85rem;
  color: var(--fg-dim);
  max-width: 12rem;
}

.admin-filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}
.admin-filter-bar input[type="search"], .admin-filter-bar select {
  font: inherit;
  font-size: 0.9rem;
  background: var(--bg-raised);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.45rem 0.7rem;
}
.admin-filter-bar input[type="search"] { flex: 1 1 12rem; }
.admin-filter-bar input:focus, .admin-filter-bar select:focus { outline: none; border-color: var(--accent); }

/* horizontal scroll on narrow viewports instead of the table itself
   trying (and failing) to reflow - the same "contain overflow instead
   of letting the page overflow" instinct as .code-block's <pre> */
.admin-table-wrap { overflow-x: auto; }

.admin-post-list {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}
.admin-post-list th, .admin-post-list td {
  text-align: left;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.admin-post-list th {
  color: var(--fg-dim);
  font-weight: 600;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.admin-post-list tbody tr:hover { background: var(--bg-raised); }
.admin-post-list a { color: var(--fg); text-decoration: none; }
.admin-post-list a:hover { color: var(--accent); }
.admin-row-actions { text-align: right; }
.admin-row-actions form { display: inline; }

.admin-image-filename { display: flex; align-items: center; gap: 0.4rem; }
.admin-copy-path-btn svg { width: 14px; height: 14px; }
.admin-copy-path-btn.copied { color: var(--accent); }

.status-pill {
  display: inline-block;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--fg-dim);
}
.status-pill.status-published { color: var(--accent); border-color: var(--accent); }

.button {
  display: inline-flex;
  align-items: center;
  font: inherit;
  font-size: 0.92rem;
  background: var(--accent);
  color: var(--bg);
  border: 1px solid var(--accent);
  border-radius: 6px;
  padding: 0.5rem 1rem;
  cursor: pointer;
  text-decoration: none;
}
.button:hover { opacity: 0.85; }
.button-ghost {
  background: none;
  color: var(--fg);
  border-color: var(--border);
}
.button-ghost:hover { border-color: var(--accent); color: var(--accent); opacity: 1; }
.button-danger {
  background: none;
  color: #e0546b;
  border-color: #e0546b;
}
.button-danger:hover { background: #e0546b; color: var(--bg); opacity: 1; }

.admin-post-form, .admin-tag-form {
  max-width: 42rem;
}
.admin-post-form .field { margin-bottom: 1.25rem; }
.admin-post-form label {
  display: block;
  margin-bottom: 0.35rem;
  color: var(--fg-dim);
  font-size: 0.9rem;
}
.admin-post-form input[type="text"],
.admin-post-form input[type="search"],
.admin-post-form textarea,
.admin-post-form select {
  width: 100%;
  font: inherit;
  font-size: 0.95rem;
  background: var(--bg-raised);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.55rem 0.75rem;
}
.admin-post-form textarea { font-family: var(--font-code); resize: vertical; }
.admin-post-form input:focus, .admin-post-form textarea:focus, .admin-post-form select:focus {
  outline: none;
  border-color: var(--accent);
}
.admin-post-form [data-image-upload-field], .admin-post-form [data-preview-field] {
  position: relative;
}
.admin-post-form [data-image-upload-trigger], .admin-post-form [data-preview-trigger] {
  font: inherit;
  font-size: 0.85rem;
  background: var(--bg-raised);
  color: var(--fg-dim);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.3rem 0.7rem;
  margin: 0.5rem 0.5rem 0.5rem 0;
  cursor: pointer;
}
.admin-post-form [data-image-upload-trigger]:hover, .admin-post-form [data-preview-trigger]:hover {
  color: var(--fg);
  border-color: var(--accent);
}
.admin-post-form input[type="submit"] {
  width: auto;
  background: var(--accent);
  color: var(--bg);
  border: 1px solid var(--accent);
  border-radius: 6px;
  padding: 0.6rem 1.4rem;
  cursor: pointer;
  font-weight: 600;
}
.admin-post-form input[type="submit"]:hover { opacity: 0.85; }

/* the sign-in page - not part of the admin panel proper (no session
   yet to have a nav for), kept on its own minimal "plain" layout, but
   themed and centered rather than unstyled browser defaults */
.session-form {
  max-width: 24rem;
  margin: 15vh auto 0;
  padding: 2rem;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}
.session-form input {
  font: inherit;
  font-size: 0.95rem;
  background: var(--bg-raised);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.6rem 0.8rem;
}
.session-form input:focus { outline: none; border-color: var(--accent); }
.session-form input[type="submit"] {
  background: var(--accent);
  color: var(--bg);
  border: 1px solid var(--accent);
  font-weight: 600;
  cursor: pointer;
}
.session-form input[type="submit"]:hover { opacity: 0.85; }

@media (max-width: 640px) {
  .admin-header { padding: 0.75rem 1.25rem; }
  .admin-main { padding: 1.25rem; }
  .admin-page-header { align-items: flex-start; }
}

/* same breakpoint the public header's .menu-button already shows/hides
   at (see application.css) - Posts/Tags/Marginalia/About folds into
   the shared hamburger-triggered drawer instead of wrapping across
   multiple lines, which is what was actually overflowing on mobile. */
@media (max-width: 880px) {
  .admin-nav { display: none; }
  /* the header's own sign-out icon goes with it - .admin-drawer-signout
     inside #admin-nav-drawer is the mobile path to the same action */
  .admin-signout-form { display: none; }
}
