/* ==========================================================================
   Walnut Grove Admin UI — Base Stylesheet (Admin-only)
   Goals:
   - Professional back-office look (not public marketing)
   - Consistent surfaces, typography, spacing, tables, forms, modals
   - No dependency changes; pure CSS
   ========================================================================== */

/* Admin palette + typography overrides (scoped via :root since this stylesheet
   is only loaded by the admin app entry). */
:root {
  /* Typography: admin uses clean sans for headings too */
  --font-heading: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  --font-body: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;

  /* Admin colors (neutral + blue accent) */
  --admin-bg: #0b1220;              /* sidebar background */
  --admin-bg-2: #0f1a2e;            /* sidebar hover */
  --admin-surface: #ffffff;         /* card/surface */
  --admin-surface-2: #f7f8fb;       /* subtle fill */
  --admin-border: #e4e7ee;
  --admin-text: #0e1726;
  --admin-muted: #5b667a;
  --admin-muted-2: #7a869b;

  --admin-accent: #2563eb;          /* blue */
  --admin-accent-2: #1d4ed8;
  --admin-success: #16a34a;
  --admin-warning: #f59e0b;
  --admin-danger: #dc2626;

  --admin-radius: 12px;
  --admin-radius-sm: 10px;
  --admin-shadow: 0 10px 28px rgba(2, 6, 23, 0.08);
  --admin-shadow-sm: 0 2px 10px rgba(2, 6, 23, 0.08);

  /* Re-map existing design tokens used across pages */
  --color-background: var(--admin-surface-2);
  --color-border: var(--admin-border);
  --color-text: var(--admin-text);
  --color-text-secondary: var(--admin-muted);
  --color-gray-dark: var(--admin-muted);

  --color-primary: var(--admin-accent);
  --color-primary-dark: var(--admin-accent-2);
  --color-primary-lightest: rgba(37, 99, 235, 0.12);

  --color-success: var(--admin-success);
  --color-warning: var(--admin-warning);
  --color-error: var(--admin-danger);
  --color-error-light: rgba(220, 38, 38, 0.1);
  --color-info: #0ea5e9;

  --shadow-sm: var(--admin-shadow-sm);
  --shadow-md: var(--admin-shadow);
  --shadow-lg: var(--admin-shadow);

  --radius: var(--admin-radius-sm);
  --radius-sm: 10px;
  --radius-lg: var(--admin-radius);
}

body {
  background: var(--admin-surface-2);
  color: var(--admin-text);
}

/* ==========================================================================
   Admin Shell Layout
   ========================================================================== */

.admin-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px 1fr;
}

.admin-sidebar {
  background: var(--admin-bg);
  color: rgba(255, 255, 255, 0.92);
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
}

.admin-brand {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 10px 14px 10px;
}

.admin-brand__title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.admin-brand__subtitle {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.72);
}

.admin-nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.admin-nav__sectionLabel {
  margin: 14px 10px 6px 10px;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.6);
}

.admin-nav__link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 10px;
  border-radius: 10px;
  color: rgba(255, 255, 255, 0.9);
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease;
}

.admin-nav__link:hover {
  background: rgba(255, 255, 255, 0.08);
}

.admin-nav__link.is-active {
  background: rgba(37, 99, 235, 0.22);
  outline: 1px solid rgba(37, 99, 235, 0.35);
}

.admin-nav__icon {
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  opacity: 0.95;
}

.admin-sidebar__footer {
  margin-top: auto;
  padding: 12px 10px 6px 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.admin-sidebar__smallLink {
  color: rgba(255, 255, 255, 0.72);
  text-decoration: underline;
  font-size: 12px;
}

.admin-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.admin-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(247, 248, 251, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--admin-border);
}

.admin-header__inner {
  padding: 18px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.admin-header__titleBlock {
  min-width: 0;
}

.admin-header__title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  color: var(--admin-text);
}

.admin-header__subtitle {
  margin: 4px 0 0 0;
  font-size: 13px;
  color: var(--admin-muted);
}

.admin-header__right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.admin-user {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  max-width: 360px;
}

.admin-user__line1 {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.admin-user__email {
  font-size: 13px;
  color: var(--admin-text);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 260px;
}

.admin-roleBadge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  border: 1px solid var(--admin-border);
  background: #fff;
  color: var(--admin-muted);
}

.admin-roleBadge.role-President {
  color: #0b3b2a;
  border-color: rgba(22, 163, 74, 0.28);
  background: rgba(22, 163, 74, 0.12);
}

.admin-roleBadge.role-VicePresident {
  color: #102a67;
  border-color: rgba(37, 99, 235, 0.28);
  background: rgba(37, 99, 235, 0.14);
}

.admin-roleBadge.role-BoardMember {
  color: #4a3411;
  border-color: rgba(245, 158, 11, 0.28);
  background: rgba(245, 158, 11, 0.14);
}

.admin-user__line2 {
  font-size: 12px;
  color: var(--admin-muted);
}

.admin-content {
  padding: 18px;
  min-width: 0;
}

@media (max-width: 640px) {
  .admin-content {
    padding: 16px;
  }
}

@media (max-width: 1024px) {
  .admin-shell {
    grid-template-columns: 1fr;
  }
  .admin-sidebar {
    position: sticky;
    top: 0;
    z-index: 60;
    flex-direction: row;
    align-items: center;
    overflow-x: auto;
  }
  .admin-brand {
    padding: 6px 10px;
    min-width: 220px;
  }
  .admin-nav {
    flex-direction: row;
    gap: 8px;
    padding-bottom: 2px;
  }
  .admin-nav__sectionLabel {
    display: none;
  }
  .admin-sidebar__footer {
    display: none;
  }
}

/* ==========================================================================
   Professional components (override existing shared classes)
   ========================================================================== */

/* Buttons */
.btn {
  border-radius: 10px;
  font-weight: 700;
  letter-spacing: 0.01em;
  box-shadow: none;
}
.btn-primary {
  background: var(--admin-accent);
  border-color: var(--admin-accent);
}
.btn-primary:hover {
  background: var(--admin-accent-2);
  border-color: var(--admin-accent-2);
}
.btn-secondary {
  background: #fff;
  color: var(--admin-text);
  border-color: var(--admin-border);
}
.btn-secondary:hover {
  background: #f2f5fb;
  color: var(--admin-text);
}
.btn-danger,
.btn-danger:hover {
  background: var(--admin-danger);
  border-color: var(--admin-danger);
}

/* Page header + surfaces */
.page-header {
  border-bottom: 1px solid var(--admin-border);
  padding-bottom: 14px;
}
.page-title {
  font-size: 22px;
}

.search-section,
.table-container,
.stat-card,
.content-card {
  border: 1px solid var(--admin-border);
  box-shadow: var(--admin-shadow-sm);
}

/* Tables */
.table-container {
  overflow: auto;
  border-radius: 14px;
}
.data-table {
  min-width: 860px; /* keeps columns readable */
}
.data-table thead {
  background: #0f172a;
  color: #fff;
}
.data-table th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #0f172a;
  padding: 14px 16px;
}
.data-table td {
  padding: 14px 16px;
}

/* Compact SaaS tables (admin)
   - Members + Plots should stay readable but not "giant mobile" tall.
   - Keep layout intact; reduce padding/line-height and prevent long fields from
     expanding row height uncontrollably. */
.admin-shell .members-table th,
.admin-shell .members-table td,
.admin-shell .plots-page .data-table th,
.admin-shell .plots-page .data-table td {
  padding: 8px 14px;
  line-height: 1.25;
  vertical-align: middle;
}

/* Ensure `.btn-sm` works in admin (App.css is not loaded) */
.btn-sm {
  padding: 6px 10px;
  font-size: 0.875rem;
  min-height: 32px;
}

/* Actions column: compact inline buttons (no giant stacking) */
.admin-shell .members-table .action-buttons,
.admin-shell .plots-page .data-table .action-buttons {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: nowrap;
}
.admin-shell .members-table .action-buttons .btn,
.admin-shell .plots-page .data-table .action-buttons .btn {
  white-space: nowrap;
}

/* Members: keep name meta from wrapping */
.admin-shell .members-table__namePrimary,
.admin-shell .members-table__nameMeta {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Plots: prevent most cells from wrapping (keeps rows compact) */
.admin-shell .plots-page .data-table td {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* Allow owners + notes to show up to 2 lines (clamped) */
.admin-shell .plots-page .data-table td:nth-child(6),
.admin-shell .plots-page .data-table td:nth-child(7) {
  white-space: normal;
}
.admin-shell .plots-page .owners-list {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  gap: 0;
}
.admin-shell .plots-page .table-cell-notes {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  color: var(--admin-muted);
}
.admin-shell .plots-page .data-table .badge {
  padding: 4px 10px;
}

.data-table tbody tr:nth-child(even) {
  background: #fafbff;
}
.data-table tbody tr:hover {
  background: #f1f5ff;
}
.empty-state {
  color: var(--admin-muted);
  font-style: normal;
}

/* Forms */
.form-group label,
.filter-label {
  color: var(--admin-muted);
}
.form-group input,
.form-group select,
.form-group textarea,
.search-input,
.filter-select {
  border-color: var(--admin-border);
  background: #fff;
}

/* Search + filters (admin-wide)
   - Admin pages often rely on App.css for search sizing/layout, but the admin
     app does not load App.css. These rules make all admin search inputs
     full-width, readable, and touch-friendly by default. */
.search-input-wrapper {
  width: 100%;
  min-width: 0;
}

.search-input {
  width: 100%;
  min-height: 48px;
  padding: 12px 16px;
  font-size: 16px;
  line-height: 1.2;
  font-family: var(--font-body);
  border: 1px solid var(--admin-border);
  border-radius: var(--radius-lg);
  color: var(--admin-text);
  background: #fff;
}

/* Filter panel layout: keep search full-width, let selects wrap cleanly */
.search-section .search-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  align-items: end;
}

.search-section .search-input-wrapper {
  grid-column: 1 / -1;
}

.search-section .filter-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.search-section .filter-select {
  width: 100%;
  min-height: 48px;
  padding: 12px 16px;
  font-size: 16px;
  line-height: 1.2;
  font-family: var(--font-body);
  border: 1px solid var(--admin-border);
  border-radius: var(--radius);
  color: var(--admin-text);
  background: #fff;
}

.search-section input[type="search"],
.search-section input[type="text"] {
  font-size: 16px;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus,
.search-input:focus,
.filter-select:focus {
  border-color: rgba(37, 99, 235, 0.8);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}
.form-group input:disabled,
.form-group select:disabled,
.form-group textarea:disabled {
  background: #f3f4f6;
  color: #6b7280;
  cursor: not-allowed;
}

/* Modals */
.modal-overlay {
  background: rgba(2, 6, 23, 0.62);
}
.modal {
  border-radius: 16px;
  border: 1px solid var(--admin-border);
}
.modal-header {
  border-bottom: 1px solid var(--admin-border);
}
.modal-footer {
  border-top: 1px solid var(--admin-border);
}

/* Banners / messages */
.form-message.error {
  border-color: rgba(220, 38, 38, 0.35);
}
.form-message.success {
  border-color: rgba(22, 163, 74, 0.35);
}

/* ==========================================================================
   Admin Auth (Login)
   ========================================================================== */

.admin-auth {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.admin-auth__card {
  width: 100%;
  max-width: 520px;
  background: var(--admin-surface);
  border: 1px solid var(--admin-border);
  border-radius: 18px;
  box-shadow: var(--admin-shadow);
  padding: 22px;
}

.admin-auth__title {
  margin: 0;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 0.01em;
  color: var(--admin-text);
}

.admin-auth__subtitle {
  margin: 6px 0 0 0;
  color: var(--admin-muted);
  font-size: 13px;
  line-height: 1.5;
}

.admin-auth__form {
  margin-top: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.admin-auth__footerNote {
  margin-top: 16px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--admin-surface-2);
  border: 1px solid var(--admin-border);
  color: var(--admin-muted);
  font-size: 12px;
  line-height: 1.55;
}

/* ==========================================================================
   UI primitives (shared ui.css) — admin polish
   ========================================================================== */

.ui-table-scroll {
  border: 1px solid var(--admin-border);
  box-shadow: var(--admin-shadow-sm);
}

.ui-table {
  min-width: 860px;
}

.ui-table thead {
  background: #0f172a;
  color: #fff;
}

.ui-table th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #0f172a;
}

.ui-table tbody tr:nth-child(even) {
  background: #fafbff;
}

.ui-table tbody tr:hover {
  background: #f1f5ff;
}

