/* ===================================
   UI COMPONENTS
   Consolidates: nav-styles.css, loading.css, toast.css
   Plus: Modern component enhancements
   =================================== */

/* ===================================
   MODAL COMPONENTS
   =================================== */

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes scaleIn {
  from {
    transform: scale(0.9);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

/* ===================================
   LOADING COMPONENTS
   =================================== */

.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
}

.loading-overlay.active {
  display: flex;
}

.loading-spinner {
  border: 4px solid rgba(255, 255, 255, 0.3);
  border-top: 4px solid var(--primary-color);
  border-radius: 50%;
  width: 50px;
  height: 50px;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

.btn-loading {
  position: relative;
  pointer-events: none;
  opacity: 0.6;
}

.btn-loading::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  top: 50%;
  left: 50%;
  margin-left: -8px;
  margin-top: -8px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top: 2px solid #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.loading-text::after {
  content: '';
  animation: loading-dots 1.5s infinite;
}

@keyframes loading-dots {
  0%,
  20% {
    content: '.';
  }
  40% {
    content: '..';
  }
  60%,
  100% {
    content: '...';
  }
}

/* Skeleton Loading */
.skeleton {
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.1) 25%,
    rgba(255, 255, 255, 0.2) 50%,
    rgba(255, 255, 255, 0.1) 75%
  );
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s infinite;
  border-radius: var(--radius-md);
}

@keyframes skeleton-loading {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

.skeleton-text {
  height: 16px;
  margin-bottom: 8px;
}

.skeleton-title {
  height: 24px;
  width: 60%;
  margin-bottom: 16px;
}

.skeleton-avatar {
  width: 120px;
  height: 120px;
  border-radius: 50%;
}

button:disabled,
input:disabled,
select:disabled,
textarea:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.pulse {
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

.spinner-small {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(0, 0, 0, 0.1);
  border-top: 2px solid var(--primary-color);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-left: 8px;
  vertical-align: middle;
}

.loading-message {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 15px;
  background-color: rgba(221, 114, 0, 0.1);
  border-left: 3px solid var(--primary-color);
  border-radius: var(--radius-md);
  margin: 10px 0;
}

.loading-message .spinner-small {
  margin-left: 0;
}

/* ===================================
   RESPONSIVE DESIGN
   =================================== */

/* Content spacing for fixed nav */
body {
  padding-top: 70px;
}

@media (max-width: 768px) {
  /* Loading overlay mobile improvements */
  .loading-spinner {
    width: 40px;
    height: 40px;
  }
}

/* ===================================
   REDESIGN FOUNDATION (v2)
   Additive shared classes for the visual redesign (design_handoff).
   Unused by current pages; later phases opt in per page.
   =================================== */

/* --- Buttons: one hierarchy --- */

.btn-primary-v2 {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border: none;
  border-radius: 8px;
  background: var(--brand);
  color: var(--on-brand, #ffffff);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  transition: background-color 150ms ease-out;
}

.btn-primary-v2:hover {
  background: var(--brand-hover);
}

.btn-primary-v2:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.btn-primary-v2:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-ghost-v2 {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border: 1.5px solid var(--input-border);
  border-radius: 8px;
  background: transparent;
  color: var(--text-color);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  transition:
    background-color 150ms ease-out,
    border-color 150ms ease-out;
}

.btn-ghost-v2:hover {
  background: var(--hover-bg);
  border-color: var(--text-faint);
}

.btn-ghost-v2:focus-visible {
  outline: none;
  border-color: var(--brand);
  box-shadow: var(--focus-ring);
}

.btn-ghost-v2:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-danger-ghost-v2 {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border: 1.5px solid var(--danger-border);
  border-radius: 8px;
  background: transparent;
  color: var(--danger-text);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  transition:
    background-color 150ms ease-out,
    border-color 150ms ease-out;
}

.btn-danger-ghost-v2:hover {
  background: var(--danger-bg);
  border-color: var(--danger-text);
}

.btn-danger-ghost-v2:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(209, 36, 47, 0.18);
}

.btn-danger-ghost-v2:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* --- Status badges: one system (pill 11.5px/600, 3px 10px, radius 99px) --- */

.badge-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.5;
  white-space: nowrap;
}

.badge-member {
  background: #e3f2e5;
  color: #1a7f37;
}

.badge-staff {
  background: #e3ecfa;
  color: #1f5fbf;
}

.badge-client {
  background: #efe7f8;
  color: #6f42c1;
}

.badge-guest {
  background: #fcf0d8;
  color: #9a6700;
}

.badge-daypass {
  background: #dff3f6;
  color: #0e7a8a;
}

.badge-danger {
  background: #fde8e8;
  color: #b42318;
}

/* Deep-ink status pairs shared with the Dashboard/census badge set.
   Bright --success-color/--warning-color are icon/chart colors, never
   badge text — these use the deep-ink pairs from the design handoff. */
.badge-promotional {
  background: #e3f2e5;
  color: #1a7f37;
}

.badge-summer-hold {
  background: #fcf0d8;
  color: #9a6700;
}

.badge-neutral {
  background: #f4f1ec;
  color: #57534e;
}

/* Parent portal accounts — neutral purple, deliberately muted next to the
   saturated client purple (parents are never lounge attendees). */
.badge-parent {
  background: #ece9f4;
  color: #5e548e;
}

/* Dark-mode badge values (per design handoff badge table).
   Keyed on the -dark suffix so thehouse-dark AND all accent-dark
   themes get the same semantic badge treatment. */
[data-theme$='-dark'] .badge-member,
[data-theme='custom'] .badge-member {
  background: rgba(87, 196, 106, 0.16);
  color: #57c46a;
}

[data-theme$='-dark'] .badge-staff,
[data-theme='custom'] .badge-staff {
  background: rgba(121, 174, 242, 0.16);
  color: #79aef2;
}

[data-theme$='-dark'] .badge-client,
[data-theme='custom'] .badge-client {
  background: rgba(183, 148, 240, 0.18);
  color: #b794f0;
}

[data-theme$='-dark'] .badge-guest,
[data-theme='custom'] .badge-guest {
  background: rgba(227, 179, 65, 0.16);
  color: #e3b341;
}

[data-theme$='-dark'] .badge-daypass,
[data-theme='custom'] .badge-daypass {
  background: rgba(94, 200, 216, 0.16);
  color: #5ec8d8;
}

[data-theme$='-dark'] .badge-danger,
[data-theme='custom'] .badge-danger {
  background: rgba(244, 112, 103, 0.16);
  color: #f47067;
}

[data-theme$='-dark'] .badge-promotional,
[data-theme='custom'] .badge-promotional {
  background: rgba(87, 196, 106, 0.16);
  color: #57c46a;
}

[data-theme$='-dark'] .badge-summer-hold,
[data-theme='custom'] .badge-summer-hold {
  background: rgba(227, 179, 65, 0.16);
  color: #e3b341;
}

[data-theme$='-dark'] .badge-neutral,
[data-theme='custom'] .badge-neutral {
  background: rgba(179, 172, 164, 0.16);
  color: #b3aca4;
}

[data-theme$='-dark'] .badge-parent,
[data-theme='custom'] .badge-parent {
  background: rgba(158, 148, 196, 0.16);
  color: #9e94c4;
}

/* --- Cards: borders at rest, shadow only on hover-lift --- */

.card-v2 {
  background: var(--surface);
  border: 1px solid var(--border-color-soft);
  border-radius: 12px;
  box-shadow: none;
  transition:
    transform 150ms ease-out,
    border-color 150ms ease-out,
    box-shadow 150ms ease-out;
}

.card-v2:hover {
  transform: translateY(-2px);
  border-color: var(--input-border);
  box-shadow: 0 6px 16px rgba(41, 37, 36, 0.08);
}

/* --- Section label --- */

.section-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

/* --- Toasts (v2): bottom-left stack, dark surface in both modes.
       CSS only for now; the toast queue JS lands in a later phase. --- */

.toast-stack-v2 {
  position: fixed;
  left: 24px;
  bottom: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: var(--z-toast);
  pointer-events: none;
}

.toast-v2 {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 360px;
  padding: 12px 16px;
  border: 1px solid #35302b;
  border-radius: 12px;
  background: #262220;
  color: #f4f1ec;
  font-size: 14px;
  box-shadow: 0 12px 32px rgba(41, 37, 36, 0.14);
  pointer-events: auto;
}

.toast-v2-action {
  padding: 4px 8px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: #f5a04c;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.toast-v2-action:hover {
  background: rgba(245, 160, 76, 0.12);
}

/* --- Inputs & focus ring utility --- */

.input-v2 {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--input-border);
  border-radius: 8px;
  background: var(--canvas);
  color: var(--text-color);
  font-family: inherit;
  font-size: 14px;
  box-sizing: border-box;
  transition:
    border-color 150ms ease-out,
    box-shadow 150ms ease-out;
}

.input-v2::placeholder {
  color: var(--text-faint);
}

.input-v2:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: var(--focus-ring);
}

/* --- Closed-day banner (maintenance.js) — warning surface, left-aligned
       row with a 34px icon chip; sentence-case title + secondary body. --- */

.closed-day-banner {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  background: var(--warning-bg);
  border: 1px solid var(--warning-color);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 20px;
}

.closed-day-banner__chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--warning-color) 18%, transparent);
  color: #9a6700;
  font-size: 16px;
}

[data-theme$='-dark'] .closed-day-banner__chip,
[data-theme='custom'] .closed-day-banner__chip {
  color: #e3b341;
}

.closed-day-banner__title {
  margin: 0 0 3px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-color);
}

.closed-day-banner__body {
  margin: 0;
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-secondary);
}

/* ===================================================================
   Wave 3 — shared modal shell (.modal-v2), confirm dialog (.confirm-v2),
   and toast additions. Additive only; recreates the design_handoff shared
   modal shell WITHOUT touching existing .modal / .modal-content rules.
   Pages opt in by adding the v2 classes. Theme-aware via tokens (works
   under every accent + light/dark); toasts are intentionally always-dark.
   =================================================================== */

/* --- Modal shell (per Modals Light.dc.html) --- */

@keyframes modal-v2-overlay-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes modal-v2-pop-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.modal-v2-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  box-sizing: border-box;
  /* Dim backdrop — no token for this exact scrim, matches the design. */
  background: rgba(0, 0, 0, 0.5);
  z-index: var(--z-modal);
  animation: modal-v2-overlay-in 160ms ease-out;
}

/* Confirm dialogs (and any drop-in overlay) sit above page-level modals. */
.modal-v2-overlay.is-top {
  z-index: 100000;
}

.modal-v2 {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow: hidden;
  border: 1px solid var(--border-color-soft);
  border-radius: var(--radius-xl);
  background: var(--surface);
  color: var(--text-color);
  box-shadow: var(--shadow-xl);
  animation: modal-v2-pop-in 220ms var(--spring);
}

.modal-v2-header {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  padding: 18px 24px;
  border-bottom: 1px solid var(--hairline);
}

.modal-v2-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  /* Brand tint that follows the active accent. */
  background: color-mix(in srgb, var(--brand) 12%, transparent);
  color: var(--brand);
  font-size: 15px;
}

.modal-v2-icon.is-danger {
  background: var(--danger-bg);
  color: var(--danger-text);
}

.modal-v2-titles {
  flex: 1;
  min-width: 0;
}

.modal-v2-title {
  font-size: 18px;
  font-weight: 700;
  line-height: 1.25;
  color: var(--text-color);
}

.modal-v2-subtitle {
  margin-top: 2px;
  font-size: 13px;
  color: var(--text-secondary);
}

.modal-v2-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  font-size: 15px;
  cursor: pointer;
  transition:
    background-color 150ms ease-out,
    color 150ms ease-out;
}

.modal-v2-close:hover {
  background: var(--hover-bg);
  color: var(--text-color);
}

.modal-v2-close:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.modal-v2-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 20px 24px;
  color: var(--text-color);
}

.modal-v2-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-shrink: 0;
  padding: 16px 24px;
  border-top: 1px solid var(--hairline);
  background: var(--canvas);
}

/* Push a secondary/left-aligned footer action to the left edge. */
.modal-v2-footer-lead {
  margin-right: auto;
}

/* Form helpers for the design's form modals (inputs reuse .input-v2). */
.modal-v2-label {
  display: block;
  margin-bottom: 5px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-color);
}

.modal-v2-section-label {
  margin-bottom: 10px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* --- Solid destructive button (design's confirm uses a solid red) --- */

.btn-danger-v2 {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border: none;
  border-radius: 8px;
  background: var(--danger-solid);
  color: #ffffff;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  transition: background-color 150ms ease-out;
}

.btn-danger-v2:hover {
  background: color-mix(in srgb, var(--danger-solid) 85%, #000);
}

.btn-danger-v2:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(209, 36, 47, 0.3);
}

.btn-danger-v2:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* --- Confirm dialog (per Interactions.dc.html) — compact modal-v2 variant
       for destructive confirmation; replaces window.confirm. --- */

.confirm-v2 {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 400px;
  overflow: hidden;
  border: 1px solid var(--border-color-soft);
  border-radius: var(--radius-xl);
  background: var(--surface);
  color: var(--text-color);
  box-shadow: var(--shadow-xl);
  animation: modal-v2-pop-in 220ms var(--spring);
}

.confirm-v2-header {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 24px 24px 0;
}

.confirm-v2-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--danger-bg);
  color: var(--danger-text);
  font-size: 17px;
}

.confirm-v2-title {
  margin-bottom: 4px;
  font-size: 16px;
  font-weight: 700;
  color: var(--text-color);
}

.confirm-v2-message {
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--text-secondary);
}

.confirm-v2-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 20px 24px;
}

/* --- Toasts (v2) — extends the foundation-phase .toast-v2 / .toast-stack-v2
       with a leading status icon and enter/exit transitions. The base
       classes (bottom-left fixed dark stack, action button) already exist
       above; these are additive and unused by any current page. --- */

.toast-v2 {
  /* Added: enter/exit motion. Base .toast-v2 (dark surface, layout) is
     defined earlier; this only layers on the transition. */
  transition:
    transform 320ms var(--spring),
    opacity 250ms ease-out;
}

.toast-v2.is-entering,
.toast-v2.is-leaving {
  opacity: 0;
  transform: translateY(16px) scale(0.98);
}

.toast-v2-message {
  flex: 1;
  min-width: 0;
  font-size: 13.5px;
  line-height: 1.4;
}

/* Status icon badges. Toasts are always dark, so these fixed colors are
   intentional (mode-varying status tokens would be wrong on a fixed-dark
   surface); they mirror the design_handoff toast icons. */
.toast-v2-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  color: #ffffff;
  font-size: 11px;
}

.toast-v2-icon.is-success {
  background: #1a7f37;
}

.toast-v2-icon.is-error {
  background: #b42318;
}

.toast-v2-icon.is-warning {
  background: #9a6700;
}

.toast-v2-icon.is-info {
  background: #2f6feb;
}
