/* settings.css — the account Settings page (#454).
 *
 * Layout is a left-nav + content pane inside the shared .container. The
 * library-list styles (us-*) are the same building blocks the section
 * renderers emit; they live here rather than in JS so the page has a real
 * stylesheet like every other page. */

.settings-layout {
  display: grid;
  grid-template-columns: 250px 1fr;
  gap: 2rem;
  align-items: start;
}

/* ── Left nav ─────────────────────────────────────────────────────────── */
.settings-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  position: sticky;
  top: 1.5rem;
}
.settings-nav__item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.7rem;
  border-radius: 9px;
  color: var(--slate);
  text-decoration: none;
  font-size: 0.92rem;
  font-family: var(--font-ui);
  border: 1px solid transparent;
}
.settings-nav__item:hover { background: var(--slate-faint, #f0f0f0); color: var(--ink); }
.settings-nav__item.is-active {
  background: var(--leaf-faint, #eaf3e6);
  color: var(--leaf-deep, #2f6429);
  border-color: var(--leaf, #4a8a3e);
  font-weight: 600;
}
.settings-nav__item .gc-icon { width: 18px; height: 18px; flex: none; }
/* Label takes the width it needs with the badge packed right after it; a long
   translation (e.g. "Estadísticas de administración") wraps within the column
   instead of overflowing into the content pane. min-width:0 lets it shrink so
   the wrap actually happens. */
.settings-nav__label { flex: 0 1 auto; min-width: 0; }
.settings-nav__soon {
  flex: none;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--slate, #888);
  background: var(--slate-faint, #eee);
  border-radius: 999px;
  padding: 0.05rem 0.4rem;
}

/* ── Content pane ─────────────────────────────────────────────────────── */
.settings-content { min-width: 0; }
.settings-content h3 {
  margin: 0 0 0.3rem;
  font-size: 1.1rem;
}
.settings-content h3:first-child { margin-top: 0.2rem; }

.us-intro { font-size: 0.9rem; line-height: 1.5; margin: 0 0 1.2rem; max-width: 44rem; }

.us-group { margin-bottom: 1.6rem; max-width: 44rem; }
/* The section renderers emit each group as a <section class="us-group">, which
   picks up the landing page's global `section { padding: 2rem 0 }` — that 32px
   top+bottom padding stacked on the 1.6rem margin left a huge gap between the
   admin cards (and every other group). The margin alone spaces them. */
.settings-content .us-group { padding: 0; }
.us-group h4 {
  font-size: 1rem;
  margin: 0 0 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.us-count {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--slate, #666);
  background: var(--slate-faint, #eee);
  border-radius: 999px;
  padding: 0.05rem 0.5rem;
}

.us-list {
  border: 1px solid var(--slate-faint, #e6e6e6);
  border-radius: 10px;
  overflow: hidden;
}
.us-list--archived { margin-top: 0.5rem; opacity: 0.9; }

.us-row {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.5rem 0.7rem;
  border-top: 1px solid var(--slate-faint, #eee);
}
.us-row:first-child { border-top: 0; }
.us-swatch {
  width: 16px; height: 16px;
  border-radius: 4px;
  flex: none;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12);
}
.us-icon-emoji { width: 20px; text-align: center; flex: none; font-size: 1.05rem; }
.us-rowmain { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.us-name { font-size: 0.95rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.us-meta { color: var(--slate, #888); font-size: 0.78rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.us-custom { color: var(--flame-deep, #c85a12); font-weight: 600; }

.us-act {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px; height: 32px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: none;
  cursor: pointer;
  color: var(--slate, #888);
}
.us-act .gc-icon { width: 17px; height: 17px; }
.us-act:hover { background: var(--slate-faint, #f0f0f0); color: var(--ink, #1a1a1a); }
.us-act--remove:hover { background: var(--flame-faint, #fdeee2); color: var(--flame-deep, #e66a1a); }
.us-act--restore:hover { background: var(--leaf-faint, #eaf3e6); color: var(--leaf-deep, #2f6429); }

.us-archtoggle {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.6rem;
  border: 0;
  background: none;
  cursor: pointer;
  color: var(--slate, #666);
  font-size: 0.88rem;
  padding: 0.15rem 0;
}
.us-archtoggle .gc-icon { width: 15px; height: 15px; }
.us-empty { padding: 0.6rem 0.7rem; margin: 0; font-size: 0.88rem; }

/* ── Library cards (species / animals) ────────────────────────────────── */
/* Cards pack tighter than the old full-width rows: an auto-fill grid so a wide
   library fills the pane in columns instead of one long list. */
.us-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(13.5rem, 1fr));
  gap: 0.6rem;
  margin-top: 0.2rem;
  max-width: 44rem;
}
.us-cards--archived { margin-top: 0.6rem; opacity: 0.85; }
.us-card {
  display: flex; align-items: center; gap: 0.4rem;
  border: 1px solid var(--slate-faint, #e6e6e6); border-radius: 10px;
  padding: 0.5rem 0.55rem; background: var(--paper, #fff); min-width: 0;
}
.us-card__body { display: flex; align-items: center; gap: 0.5rem; flex: 1 1 auto; min-width: 0; }
.us-card__text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.us-card__name { font-size: 0.92rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.us-card__meta { color: var(--slate, #888); font-size: 0.76rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.us-card__emoji { font-size: 1.15rem; width: 22px; text-align: center; flex: none; }
.us-card__actions { display: flex; gap: 1px; flex: none; }
.us-card__actions .us-act { width: 28px; height: 28px; }
.us-card__actions .us-act .gc-icon { width: 15px; height: 15px; }
/* "Add a species / animal" tile — a dashed call-to-action that sits in the grid. */
.us-card--add {
  justify-content: center; gap: 0.4rem; cursor: pointer;
  border: 1px dashed var(--slate-soft, #b7b7b7); background: none;
  color: var(--slate, #555); font: inherit; font-size: 0.9rem;
}
.us-card--add:hover {
  border-color: var(--leaf, #4a8a3e); color: var(--leaf-deep, #2f6429);
  background: var(--leaf-faint, #eaf3e6);
}
.us-card--add .gc-icon { width: 16px; height: 16px; }
.us-card--archived { opacity: 0.85; }

/* ── Library add / edit form ──────────────────────────────────────────── */
/* The form reuses the shared .field + .gs-grid building blocks; only the
   colour input wants a saner height than the tall default. */
.us-form .field { margin-bottom: 0.7rem; }
.us-form input[type="color"] { height: 38px; padding: 2px; cursor: pointer; }
/* The add/edit form uses the full section width, not the narrow single column
   the Global-settings controls sit in. The `.us-group.us-form` compound beats
   the `.settings-content .us-group .field { max-width: 26rem }` cap, and the
   grids flow into as many ~9rem columns as fit — so the size / conditions
   fields sit a few across on a wide window instead of stacking two-up. */
.settings-content .us-group.us-form { max-width: 46rem; }
.settings-content .us-group.us-form .field { max-width: none; }
.settings-content .us-group.us-form .gs-grid {
  max-width: none;
  grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
}

/* ── Global settings (#454 Phase B) ───────────────────────────────────── */
.gs-help { margin: 0 0 0.9rem; }
.gs-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.gs-loc-label { margin: 0.3rem 0 0.6rem; font-size: 0.85rem; }
.gs-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.gs-status { margin: 0.5rem 0 0; min-height: 1.1em; font-size: 0.85rem; color: var(--slate, #666); }
/* The Global section's controls sit in a comfortable single column. */
.settings-content .us-group .field { max-width: 26rem; }
.settings-content .us-group .gs-grid { max-width: 26rem; }

/* ── Admin statistics (#454 Phase E / #349) ───────────────────────────── */
.settings-content .us-group .gs-bar,
.settings-content .us-group .gs-stat-grid,
.settings-content .us-group .gs-users,
.settings-content .us-group .gs-facts { max-width: 40rem; }

.gs-bar { height: 12px; border-radius: 999px; background: var(--slate-faint, #eee); overflow: hidden; }
.gs-bar__fill { height: 100%; background: var(--leaf, #4a8a3e); border-radius: 999px; transition: width .2s; }
.gs-bar__fill.is-alert { background: var(--flame, #e0662b); }
.gs-bar__label { margin: 0.35rem 0 0; font-size: 0.82rem; color: var(--slate, #666); }

.gs-alert {
  display: flex; align-items: center; gap: 0.4rem; margin: 0 0 0.6rem;
  font-size: 0.86rem; font-weight: 600; color: var(--flame-deep, #c2410c);
}
.gs-alert .gc-icon { width: 16px; height: 16px; flex: none; }

.gs-stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(8.5rem, 1fr)); gap: 0.6rem; }
/* Stat tiles read as cards — same paper fill + border as the library cards. */
.gs-stat {
  display: flex; flex-direction: column; gap: 0.15rem;
  padding: 0.6rem 0.7rem; border: 1px solid var(--slate-faint, #e6e6e6); border-radius: 10px;
  background: var(--paper, #fff);
}
.gs-stat__val { font-size: 1.25rem; font-weight: 700; color: var(--ink, #1a1a1a); }
.gs-stat__lbl { font-size: 0.76rem; color: var(--slate, #777); }

/* Per-user storage cards (reuse .us-card) + cleanup badge + pager. */
.us-cards--users { grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); }
.us-card--user .us-card__name {
  font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 0.82rem; color: var(--ink, #1a1a1a);
}
.us-card--user .us-card__meta { font-variant-numeric: tabular-nums; }
.us-badge {
  display: inline-flex; align-items: center; gap: 0.2rem; flex: none;
  font-size: 0.7rem; padding: 0.1rem 0.4rem; border-radius: 999px;
}
.us-badge .gc-icon { width: 13px; height: 13px; }
.us-badge--warn { color: var(--flame-deep, #c2410c); background: var(--flame-faint, #fbe9e0); }
.gs-pager { display: flex; align-items: center; gap: 0.6rem; margin-top: 0.7rem; }
.gs-pager__label { font-size: 0.82rem; color: var(--slate, #666); }

/* The garden facts read in the normal themed text colour (not the browser's
   default black), matching the rest of the panel in light and dark themes. */
.gs-facts { margin: 0 0 0.6rem; padding-left: 1.1rem; font-size: 0.9rem; line-height: 1.6; color: var(--ink, #1a1a1a); }

/* ── Editor (#454 Phase D) ────────────────────────────────────────────── */
.gs-checks { display: flex; flex-direction: column; gap: 0.55rem; }
.gs-check { display: flex; align-items: center; gap: 0.55rem; font-size: 0.92rem; cursor: pointer; }
.gs-check input { width: 16px; height: 16px; flex: none; accent-color: var(--leaf, #4a8a3e); cursor: pointer; }

/* ── My gardens (#454 Phase C) ────────────────────────────────────────── */
/* The garden grid itself is the shared .garden-card component (css/style.css);
   these cover the settings-only shared-links list below it. */
.settings-content .garden-grid { margin-bottom: 1.6rem; }
.settings-content .us-list { max-width: 44rem; }
.gs-garden-link { color: var(--ink, #1a1a1a); text-decoration: none; }
.gs-garden-link:hover { color: var(--leaf-deep, #2f6429); text-decoration: underline; }
/* Brief confirmation after copying a share link to the clipboard. */
.us-act.is-copied { color: var(--leaf-deep, #2f6429); background: var(--leaf-faint, #eaf3e6); }

/* Placeholder sections (Editor / Admin) until later phases. */
.us-soon {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.9rem;
  padding: 3rem 1rem;
  max-width: 44rem;
}
.us-soon .gc-icon { width: 40px; height: 40px; color: var(--slate-soft, #aaa); }
.us-soon p { max-width: 26rem; line-height: 1.5; font-size: 0.92rem; }

/* ── Narrow screens: nav stacks above content, horizontally scrollable ── */
@media (max-width: 720px) {
  .settings-layout { grid-template-columns: 1fr; gap: 1.2rem; }
  .settings-nav {
    position: static;
    flex-direction: row;
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 4px;
    padding-bottom: 2px;
    -webkit-overflow-scrolling: touch;
  }
  .settings-nav__item { flex: 0 0 auto; }
  /* Pills stay on one line when scrolling horizontally. */
  .settings-nav__label { white-space: nowrap; }
  .settings-nav__soon { display: none; }
}
