/* =============================================================================
   RealEstate.WebAdmin — design system
   - Layout patterns inspired by the Ynex Blazor admin theme
   - Color palette inherited from RealEstate.WebApp (Nerf / RE/MAX brand)
   - Typography: Jost (same as the public website)
   - Icons: RemixIcon outline variants (ri-*-line)
   ========================================================================== */

:root {
  /* Brand palette — single source of truth lives in WebApp main.css */
  --color-accent-1: #AA1120;
  --color-accent-1-hover: #8a0d1a;
  --color-accent-1-soft: rgba(170, 17, 32, 0.08);
  --color-accent-2: #F7F0EC;
  --color-dark-1: #181D24;
  --color-dark-2: #1E242C;
  --color-dark-3: #121418;
  --color-dark-5: #2F3337;
  --color-border: #E5E7EB;
  --color-border-strong: #DDDDDD;
  --color-bg: #F4F5F7;
  --color-surface: #FFFFFF;
  --color-text: #181D24;
  --color-text-muted: #6B7280;
  --color-text-subtle: #9CA3AF;

  /* Shell metrics */
  --sidebar-width: 240px;
  --sidebar-width-collapsed: 72px;
  --header-height: 60px;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.18);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  font-family: "Jost", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
}

/* =============================================================================
   Bootstrap overrides (just enough to follow the brand)
   ========================================================================== */
.btn {
  font-weight: 500;
  border-radius: var(--radius-sm);
  padding: 0.5rem 1rem;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.btn-primary {
  background: var(--color-accent-1);
  border-color: var(--color-accent-1);
  color: #fff;
}
.btn-primary:hover,
.btn-primary:focus,
.btn-primary:active {
  background: var(--color-accent-1-hover);
  border-color: var(--color-accent-1-hover);
  color: #fff;
}

/* In-flight form-submit feedback. Applied by the global submit listener
   in App.razor — replaces the button content with a centered spinner so
   the button width stays stable (no layout jump) and double-clicks are
   blocked via pointer-events: none. */
.btn.is-loading {
  pointer-events: none;
  position: relative;
}
.btn.is-loading > * {
  visibility: hidden;
}
.btn.is-loading::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  width: 18px;
  height: 18px;
  margin-left: -9px;
  margin-top: -9px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: page-loader-spin 0.7s linear infinite;
}

.form-control {
  font-family: inherit;
  font-size: 14px;
  border-radius: var(--radius-sm);
  border-color: var(--color-border-strong);
  padding: 0.5rem 0.75rem;
}
.form-control:focus {
  border-color: var(--color-accent-1);
  box-shadow: 0 0 0 0.2rem var(--color-accent-1-soft);
}

.form-check-input:checked {
  background-color: var(--color-accent-1);
  border-color: var(--color-accent-1);
}
.form-check-input:focus {
  border-color: var(--color-accent-1);
  box-shadow: 0 0 0 0.25rem var(--color-accent-1-soft);
}

.alert-danger {
  background: rgba(170, 17, 32, 0.08);
  border-color: var(--color-accent-1);
  color: var(--color-accent-1-hover);
}

/* =============================================================================
   Snackbar / Toast — fixed-position stack used by ToastHost (interactive
   pages) and by Login (static SSR via CSS-only auto-dismiss). The .snackbar
   class is the single visual contract; variants colour the left rail and
   the icon.
   ========================================================================== */
.toast-stack {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1080;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 380px;
  pointer-events: none;          /* clicks fall through gaps */
}

.snackbar {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  border-left: 4px solid var(--color-text-muted);
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.18);
  padding: 14px 16px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  pointer-events: auto;
  animation: snackbar-in 0.25s ease-out;
}
.snackbar--info    { border-left-color: #3B82F6; }
.snackbar--success { border-left-color: #16A34A; }
.snackbar--warning { border-left-color: #F59E0B; }
.snackbar--error   { border-left-color: var(--color-accent-1); }

.snackbar__icon {
  font-size: 20px;
  flex-shrink: 0;
  line-height: 1;
  margin-top: 1px;
}
.snackbar--info    .snackbar__icon { color: #3B82F6; }
.snackbar--success .snackbar__icon { color: #16A34A; }
.snackbar--warning .snackbar__icon { color: #F59E0B; }
.snackbar--error   .snackbar__icon { color: var(--color-accent-1); }

.snackbar__body {
  flex: 1;
  min-width: 0;
}
.snackbar__message {
  font-size: 14px;
  line-height: 1.4;
  color: var(--color-text);
  word-break: break-word;
}
.snackbar__close {
  background: transparent;
  border: none;
  color: var(--color-text-muted);
  cursor: pointer;
  padding: 0;
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  font-size: 16px;
  line-height: 1;
  flex-shrink: 0;
  transition: background-color 0.15s ease, color 0.15s ease;
}
.snackbar__close:hover {
  background: var(--color-bg);
  color: var(--color-text);
}

/* Interactive pages — ToastHost manipulates this class to play the exit
   animation before removing the node from the DOM. */
.snackbar.is-leaving {
  animation: snackbar-out 0.25s ease-in forwards;
}

/* Login page — pure CSS lifecycle since the page is static SSR.
   ONE animation with all keyframes inline. Two parallel animations
   with `forwards` on both could ghost in some browsers when the second
   one started after the first held its final state; a single timeline
   removes the ambiguity. */
.snackbar--auto-dismiss {
  animation: snackbar-cycle 5.5s ease forwards;
  pointer-events: none;
}

@keyframes snackbar-in {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes snackbar-out {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(20px); }
}
@keyframes snackbar-cycle {
  0%    { opacity: 0; transform: translateX(20px); }
  5%    { opacity: 1; transform: translateX(0); }    /* slide-in finished at ~0.275s */
  91%   { opacity: 1; transform: translateX(0); }    /* hold until ~5.0s */
  100%  { opacity: 0; transform: translateX(20px); } /* slide-out by 5.5s */
}

/* =============================================================================
   Empty layout (login + error)
   ========================================================================== */
.empty-layout {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--color-dark-1) 0%, var(--color-dark-3) 100%);
  padding: 24px;
}

.login-shell {
  width: 100%;
  max-width: 440px;
}
.login-card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: 40px 36px;
  box-shadow: var(--shadow-lg);
}
.login-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 28px;
}
.login-brand__mark {
  color: var(--color-accent-1);
  font-weight: 700;
  font-size: 30px;
  letter-spacing: 0.04em;
}
.login-brand__suffix {
  color: var(--color-text-muted);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-top: 2px;
}
.login-title {
  font-size: 22px;
  font-weight: 600;
  text-align: center;
  margin: 0 0 6px;
  color: var(--color-text);
}
.login-subtitle {
  font-size: 13px;
  color: var(--color-text-muted);
  text-align: center;
  margin: 0 0 24px;
}
.login-form {
  display: flex;
  flex-direction: column;
}
.login-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 16px 0 6px;
}
.login-input {
  position: relative;
}
.login-input__icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-text-subtle);
  font-size: 16px;
  pointer-events: none;
}
.login-input .form-control {
  padding-left: 40px;
}
.login-submit {
  margin-top: 28px;
  padding: 10px 16px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.login-submit i {
  font-size: 16px;
}
.login-submit__spin {
  animation: login-spin 0.9s linear infinite;
}
@keyframes login-spin {
  to { transform: rotate(360deg); }
}

/* =============================================================================
   App shell — sidebar + header + content
   ========================================================================== */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* ----- Sidebar ----- */
.app-sidebar {
  width: var(--sidebar-width);
  background: var(--color-dark-1);
  color: #fff;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: width 0.2s ease;
  overflow: hidden;
}
.app-sidebar__brand {
  display: flex;
  flex-direction: column;
  height: var(--header-height);
  padding: 0 20px;
  justify-content: center;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.app-sidebar__brand-mark {
  color: var(--color-accent-1);
  font-weight: 700;
  font-size: 20px;
  letter-spacing: 0.04em;
  line-height: 1;
}
.app-sidebar__brand-suffix {
  color: rgba(255,255,255,0.5);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-top: 4px;
}

.app-nav {
  display: flex;
  flex-direction: column;
  padding: 16px 12px;
  gap: 2px;
}
.app-nav__item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,0.7);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  transition: background-color 0.15s ease, color 0.15s ease;
}
.app-nav__item:hover {
  background: rgba(255,255,255,0.05);
  color: #fff;
}
.app-nav__item.active {
  background: var(--color-accent-1);
  color: #fff;
}
.app-nav__item.active:hover {
  background: var(--color-accent-1-hover);
}
.app-nav__icon {
  font-size: 18px;
  flex-shrink: 0;
}
.app-nav__label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Collapsed sidebar — icon-only mode */
.app-shell.is-collapsed .app-sidebar {
  width: var(--sidebar-width-collapsed);
}
.app-shell.is-collapsed .app-sidebar__brand-suffix {
  display: none;
}
.app-shell.is-collapsed .app-sidebar__brand {
  padding: 0;
  align-items: center;
  justify-content: center;
}
.app-shell.is-collapsed .app-sidebar__brand-mark {
  font-size: 16px;
}
.app-shell.is-collapsed .app-nav__item {
  justify-content: center;
  padding: 10px 0;
}
.app-shell.is-collapsed .app-nav__label {
  display: none;
}

/* ----- Main panel ----- */
.app-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;            /* prevent table overflow from pushing the sidebar */
}

/* ----- Header ----- */
.app-header {
  background: var(--color-surface);
  height: var(--header-height);
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  border-bottom: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
}
.app-header__toggle {
  background: transparent;
  border: none;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--color-text);
  font-size: 20px;
  cursor: pointer;
  transition: background-color 0.15s ease;
}
.app-header__toggle:hover {
  background: var(--color-bg);
}
.app-header__spacer { flex: 1; }
.app-header__user {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--color-text-muted);
  font-weight: 500;
}
.app-header__user i {
  font-size: 18px;
}
.app-header__logout {
  margin: 0;
}
.app-header__logout-btn {
  background: transparent;
  border: 1px solid var(--color-border-strong);
  color: var(--color-text);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.app-header__logout-btn:hover {
  background: var(--color-accent-1);
  border-color: var(--color-accent-1);
  color: #fff;
}

/* ----- Content ----- */
.app-content {
  padding: 24px 28px 40px;
  flex: 1;
}

.page-header {
  margin-bottom: 24px;
}
.page-title {
  font-size: 22px;
  font-weight: 600;
  color: var(--color-text);
  margin: 0;
}
.page-subtitle {
  font-size: 13px;
  color: var(--color-text-muted);
  margin: 4px 0 0;
}

/* ----- Page loader ----- */
.page-loader {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 80px 24px;
  color: var(--color-text-muted);
}
.page-loader__icon {
  font-size: 36px;
  color: var(--color-accent-1);
  animation: page-loader-spin 0.9s linear infinite;
}
.page-loader__icon--inline {
  font-size: 18px;
  color: var(--color-accent-1);
  animation: page-loader-spin 0.9s linear infinite;
}
.page-loader__label {
  font-size: 13px;
  letter-spacing: 0.04em;
}
@keyframes page-loader-spin {
  to { transform: rotate(360deg); }
}

/* ----- Validation message under login inputs ----- */
.login-validation {
  display: block;
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--color-accent-1);
  font-weight: 500;
}

/* =============================================================================
   Dashboard
   ========================================================================== */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}
.stat-card {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-sm);
}
.stat-card__icon {
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
}
.stat-card__icon--neutral {
  background: rgba(24, 29, 36, 0.06);
  color: var(--color-dark-1);
}
.stat-card__icon--accent {
  background: var(--color-accent-1-soft);
  color: var(--color-accent-1);
}
.stat-card__icon--muted {
  background: rgba(107, 114, 128, 0.10);
  color: var(--color-text-muted);
}
.stat-card__body {
  display: flex;
  flex-direction: column;
}
.stat-card__label {
  font-size: 12px;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 4px;
}
.stat-card__value {
  font-size: 26px;
  font-weight: 700;
  color: var(--color-text);
  line-height: 1.1;
}

/* =============================================================================
   Data card / table
   ========================================================================== */
.card-shell {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.card-shell__toolbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--color-border);
  background: #FAFBFC;
}
.search-input {
  position: relative;
  flex: 1;
  max-width: 380px;
}
.search-input__icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-text-subtle);
  font-size: 16px;
  pointer-events: none;
}
.search-input .form-control {
  padding-left: 36px;
}
.card-shell__count {
  color: var(--color-text-muted);
  font-size: 13px;
}

.data-table {
  margin: 0;
}
.data-table thead th {
  background: var(--color-bg);
  color: var(--color-text);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-border);
}
.data-table tbody td {
  font-size: 14px;
  padding: 12px 16px;
  vertical-align: middle;
  border-bottom: 1px solid var(--color-border);
  font-family: inherit;
}
.data-table tbody tr:last-child td {
  border-bottom: none;
}
.data-table tbody tr:hover {
  background: rgba(170, 17, 32, 0.02);
}

/* ----- Sortable column headers ----- */
.data-table thead th.sortable {
  cursor: pointer;
  user-select: none;
  transition: background-color 0.15s ease, color 0.15s ease;
}
.data-table thead th.sortable:hover {
  background: #ECEEF1;
  color: var(--color-accent-1);
}
.data-table thead th.sortable.is-active {
  color: var(--color-accent-1);
}
.sortable__inner {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
/* Center-aligned and end-aligned sortable headers keep the icon next to
   the label rather than letting it drift to the opposite edge. */
.data-table thead th.sortable.text-center .sortable__inner {
  justify-content: center;
}
.data-table thead th.sortable.text-end .sortable__inner {
  justify-content: flex-end;
}
.sortable__icon {
  font-size: 14px;
  opacity: 0.5;
  transition: opacity 0.15s ease;
}
.data-table thead th.sortable.is-active .sortable__icon,
.data-table thead th.sortable:hover .sortable__icon {
  opacity: 1;
}

/* =============================================================================
   Empty state + pagination
   ========================================================================== */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 56px 24px;
  color: var(--color-text-muted);
  text-align: center;
}
.empty-state__icon {
  font-size: 40px;
  color: var(--color-text-subtle);
}

.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-top: 1px solid var(--color-border);
  background: #FAFBFC;
}
.pagination-bar__btn {
  background: var(--color-surface);
  border: 1px solid var(--color-border-strong);
  color: var(--color-text);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.pagination-bar__btn:hover:not(:disabled) {
  background: var(--color-accent-1);
  border-color: var(--color-accent-1);
  color: #fff;
}
.pagination-bar__btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.pagination-bar__status {
  font-size: 13px;
  color: var(--color-text-muted);
}

/* =============================================================================
   Responsive — collapse sidebar to bottom drawer on small screens
   ========================================================================== */
@media (max-width: 768px) {
  .app-shell {
    flex-direction: column;
  }
  .app-sidebar {
    width: 100%;
    height: auto;
    position: relative;
  }
  .app-shell.is-collapsed .app-sidebar {
    width: 100%;
  }
  .app-content {
    padding: 16px;
  }
  .app-header {
    padding: 0 16px;
  }
}
