/*
 * Purpose: Management overview — a searchable directory. Header with search,
 * optional quick access, then one panel per area with compact module rows.
 * Each area carries its own tone so the eye finds it again without reading.
 */

/* Area tones: one accent per group, darker variants for the light theme. */
.mgmt-group,
.mgmt-recent-item { --tone: #a78bfa; }
[data-tone="cyan"]   { --tone: #22d3ee; }
[data-tone="orange"] { --tone: #fb923c; }
[data-tone="blue"]   { --tone: #60a5fa; }
[data-tone="rose"]   { --tone: #fb7185; }
body.theme-light :is(.mgmt-group, .mgmt-recent-item) { --tone: #7c3aed; }
body.theme-light [data-tone="cyan"]   { --tone: #0e7490; }
body.theme-light [data-tone="orange"] { --tone: #c2410c; }
body.theme-light [data-tone="blue"]   { --tone: #1d4ed8; }
body.theme-light [data-tone="rose"]   { --tone: #be123c; }

/* ── Header ─────────────────────────────────────────── */
.management-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
}

.management-eyebrow {
  display: inline-flex;
  margin-bottom: 8px;
}

.mgmt-search {
  position: relative;
  display: flex;
  align-items: center;
  flex: 0 1 340px;
  min-width: 0;
}

.mgmt-search[hidden] { display: none; }

.mgmt-search > svg {
  position: absolute;
  z-index: 1;
  left: 16px;
  width: 18px;
  height: 18px;
  color: var(--text-tertiary);
  pointer-events: none;
}

.mgmt-search input {
  width: 100%;
  height: 48px;
  padding: 0 48px 0 46px;
  border-radius: 16px;
  border: 1px solid var(--border-glass-mid);
  background: var(--glass-6);
  font-size: 16px; /* 16px keeps iOS from zooming into the field */
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  -webkit-appearance: none;
  appearance: none;
}

.mgmt-search input::-webkit-search-cancel-button { display: none; }

.mgmt-search kbd {
  position: absolute;
  right: 14px;
  display: grid;
  place-items: center;
  min-width: 24px;
  height: 24px;
  padding: 0 6px;
  border-radius: 7px;
  border: 1px solid var(--border-glass-mid);
  color: var(--text-tertiary);
  font: 600 12px/1 inherit;
  pointer-events: none;
}

.mgmt-search input:focus + kbd,
.mgmt-search input:not(:placeholder-shown) + kbd { opacity: 0; }

.mgmt-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ── Quick access ───────────────────────────────────── */
.mgmt-recent { margin-bottom: 32px; }
.mgmt-recent[hidden],
.mgmt-recent.is-searching { display: none; }

.mgmt-section-label {
  margin: 0 0 14px;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 650;
}

.mgmt-recent-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}

.mgmt-recent-item {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 64px;
  padding: 12px 16px;
  border-radius: 18px;
  background: var(--liquid-fill);
  box-shadow: var(--shadow-card);
  color: var(--text);
  font-size: 14.5px;
  font-weight: 650;
  text-decoration: none;
  transition: transform var(--t-base) var(--ease-smooth), box-shadow var(--t-base) var(--ease-smooth);
}

.mgmt-recent-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Area panels ────────────────────────────────────── */
.mgmt-groups {
  columns: 2 420px;
  column-gap: 24px;
}

.mgmt-group {
  break-inside: avoid;
  margin-bottom: 24px;
  padding: 8px;
  border-radius: 24px;
  background: var(--liquid-fill);
  box-shadow: var(--shadow-card);
}

.mgmt-group[hidden] { display: none; }

.mgmt-group-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 14px 10px;
}

.mgmt-group-icon {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 9px;
  background: color-mix(in srgb, var(--tone) 16%, transparent);
  color: var(--tone);
}

.mgmt-group-icon svg { width: 16px; height: 16px; }

.mgmt-group-title {
  flex: 1;
  margin: 0;
  color: var(--text);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.mgmt-group-count {
  min-width: 26px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--glass-6);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 650;
  text-align: center;
}

.mgmt-list {
  display: grid;
  gap: 2px;
}

.mgmt-row {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 64px;
  padding: 10px 12px;
  border-radius: 16px;
  color: var(--text);
  text-decoration: none;
  transition: background var(--t-fast) ease;
}

.mgmt-row[hidden] { display: none; }

.mgmt-icon {
  display: grid;
  flex-shrink: 0;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--tone) 13%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--tone) 22%, transparent);
  color: var(--tone);
}

.mgmt-icon svg { width: 20px; height: 20px; }

.mgmt-row-text {
  display: grid;
  flex: 1;
  gap: 3px;
  min-width: 0;
}

.mgmt-row-title {
  font-size: 15px;
  font-weight: 650;
  letter-spacing: -0.005em;
}

.mgmt-row-desc {
  overflow: hidden;
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.4;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mgmt-chevron {
  display: grid;
  flex-shrink: 0;
  place-items: center;
  color: var(--text-tertiary);
  opacity: 0.6;
  transition: transform var(--t-base) var(--ease-smooth), color var(--t-fast) ease, opacity var(--t-fast) ease;
}

.mgmt-chevron svg { width: 18px; height: 18px; }

@media (hover: hover) {
  .mgmt-row:hover { background: color-mix(in srgb, var(--tone) 9%, transparent); }
  .mgmt-row:hover .mgmt-chevron { color: var(--tone); opacity: 1; transform: translateX(3px); }
  .mgmt-recent-item:hover { transform: translateY(-2px); box-shadow: var(--shadow-card-hover); }
}

.mgmt-row:active { background: color-mix(in srgb, var(--tone) 14%, transparent); }

.mgmt-row:focus-visible,
.mgmt-recent-item:focus-visible {
  outline: 2px solid var(--tone);
  outline-offset: -2px;
  box-shadow: none;
}

.management-loading,
.management-empty {
  padding: 48px 24px;
  text-align: center;
  color: var(--text-tertiary);
  font-size: 14px;
}

.management-empty strong { color: var(--text); font-weight: 650; }
.management-empty[hidden] { display: none; }

/* ── Light theme ────────────────────────────────────── */
body.theme-light :is(.mgmt-group, .mgmt-recent-item) { background: var(--liquid-fill), #fff; }
body.theme-light .mgmt-search input { background: #fff; border-color: #d6dce6; }
body.theme-light :is(.mgmt-row, .mgmt-recent-item) { color: var(--text); }

/* ── Responsive ─────────────────────────────────────── */
@media (hover: none) {
  .mgmt-search kbd { display: none; }
  .mgmt-search input { padding-right: 16px; }
}

@media (max-width: 700px) {
  .management-header {
    flex-direction: column;
    gap: 20px;
  }
  .mgmt-search { flex-basis: auto; align-self: stretch; }
  .mgmt-recent { margin-bottom: 24px; }
  .mgmt-recent-list { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .mgmt-recent-item { min-height: 56px; padding: 10px 12px; gap: 10px; font-size: 14px; }
  .mgmt-recent-item .mgmt-icon { width: 32px; height: 32px; border-radius: 10px; }
  .mgmt-recent-item .mgmt-icon svg { width: 17px; height: 17px; }
  .mgmt-group { margin-bottom: 16px; padding: 6px; border-radius: 22px; }
  .mgmt-group-head { padding: 12px 12px 8px; }
  .mgmt-row { gap: 12px; min-height: 58px; padding: 9px 10px; }
  .mgmt-row .mgmt-icon { width: 36px; height: 36px; border-radius: 11px; }
  .mgmt-row .mgmt-icon svg { width: 18px; height: 18px; }
  .mgmt-row-desc { font-size: 12.5px; }
}
