/* ==========================================================================
   Marmelos Vision - administration screens
   Builds on the shared tokens and components in app.css.
   ========================================================================== */

.admin-section[hidden] {
  display: none;
}

.form-field[hidden],
.checkbox-field[hidden] {
  display: none;
}

.admin-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 24px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.03);
  width: fit-content;
  max-width: 100%;
}

.admin-tab {
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
  transition: background-color 140ms ease, color 140ms ease;
}

.admin-tab:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
}

.admin-tab[aria-current="page"] {
  color: #031018;
  background: linear-gradient(150deg, var(--accent), var(--accent-alt));
}

.section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.section-title {
  font-size: 20px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.section-sub {
  margin-top: 4px;
  max-width: 72ch;
  font-size: 13px;
  color: var(--text-muted);
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}

.stat-card {
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.stat-card .stat-label {
  font-size: 11.5px;
  font-weight: 650;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.stat-card .stat-value {
  margin-top: 8px;
  font-size: 30px;
  font-weight: 680;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.stat-card[data-tone="danger"] .stat-value {
  color: var(--danger);
}

.stat-card[data-tone="ok"] .stat-value {
  color: var(--success);
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.025);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-align: left;
  color: var(--text-dim);
  white-space: nowrap;
}

.data-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  color: var(--text-muted);
}

.data-table tbody tr:last-child td {
  border-bottom: 0;
}

.data-table tbody tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

.cell-main {
  display: block;
  color: var(--text);
  font-weight: 600;
}

.cell-sub {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  color: var(--text-dim);
  word-break: break-word;
}

.mono {
  font-family: var(--mono);
  font-size: 12px;
}

.nowrap {
  white-space: nowrap;
}

.muted {
  color: var(--text-dim);
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.row-actions-end {
  justify-content: flex-end;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}

.badge[data-tone="ok"] {
  border-color: rgba(93, 220, 146, 0.4);
  background: rgba(93, 220, 146, 0.1);
  color: #b6f3ce;
}

.badge[data-tone="warn"] {
  border-color: rgba(1, 212, 253, 0.45);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.badge[data-tone="danger"] {
  border-color: rgba(255, 122, 122, 0.4);
  background: var(--danger-soft);
  color: #ffc9c9;
}

.btn-danger {
  border-color: rgba(255, 122, 122, 0.35);
  background: transparent;
  color: #ffb3b3;
}

.btn-danger:hover {
  border-color: rgba(255, 122, 122, 0.6);
  background: var(--danger-soft);
  color: #ffd6d6;
}

.empty-row {
  padding: 34px 18px;
  text-align: center;
  color: var(--text-dim);
}

/* ---------- Dialogs ---------- */

dialog.dialog {
  width: min(660px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
  overflow: auto;
}

dialog.dialog::backdrop {
  background: rgba(4, 7, 11, 0.72);
  backdrop-filter: blur(3px);
}

.dialog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 22px 0;
}

.dialog-title {
  font-size: 19px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.dialog-sub {
  margin-top: 4px;
  font-size: 12.5px;
  color: var(--text-dim);
}

.dialog-close {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: transparent;
  color: var(--text-muted);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}

.dialog-close:hover {
  color: var(--text);
  border-color: var(--border-strong);
}

.dialog-body {
  padding: 18px 22px 22px;
}

.dialog-form {
  display: grid;
  gap: 14px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.form-grid .span-2 {
  grid-column: 1 / -1;
}

.form-field select,
.form-field textarea {
  height: 42px;
  padding: 0 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(8, 12, 17, 0.7);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  transition: border-color 140ms ease;
}

.form-field select:focus,
.form-field textarea:focus {
  border-color: var(--accent);
  outline: none;
}

.form-field select option {
  background: var(--surface-raised);
  color: var(--text);
}

.checkbox-field {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 13px;
  color: var(--text-muted);
}

.checkbox-field input {
  margin-top: 3px;
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.checkbox-field span {
  display: block;
}

.checkbox-field small {
  display: block;
  margin-top: 2px;
  color: var(--text-dim);
  font-size: 12px;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 4px;
}

.dialog-error {
  margin: 0;
}

.access-list {
  display: grid;
  gap: 10px;
  max-height: 46vh;
  overflow-y: auto;
  padding-right: 4px;
}

.access-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.02);
}

.access-row .access-name {
  min-width: 0;
}

.access-row .access-name strong {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.access-row .access-name span {
  display: block;
  font-size: 12px;
  color: var(--text-dim);
}

.access-row .access-controls {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: 0 0 auto;
}

@media (max-width: 720px) {
  .form-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .section-head {
    align-items: flex-start;
  }

  .data-table th,
  .data-table td {
    padding: 10px 12px;
  }

  .admin-tabs {
    border-radius: var(--radius);
  }
}
