/* ========================================
   DESIGN SYSTEM
======================================== */

:root {
  /* Brand colours */
  --primary-color: #5b4ef5;
  --primary-hover: #4a3de8;
  --primary-soft: rgba(91, 78, 245, 0.1);
  --primary-soft-hover: rgba(91, 78, 245, 0.15);
  --primary-surface: #eef2ff;

  /* Background colours */
  --background-color: #f8fafc;
  --surface-color: #ffffff;
  --surface-muted: #f8fafc;
  --surface-hover: #f1f5f9;

  /* Existing compatibility variable */
  --card-background: var(--surface-color);

  /* Text colours */
  --text-primary: #24324b;
  --text-secondary: #8a94a6;
  --text-dark: #0f172a;
  --text-muted: #64748b;
  --text-subtle: #475569;

  /* Border colours */
  --border-color: #e3e7ef;
  --border-strong: #cbd5e1;
  --border-muted: #e2e8f0;

  /* Shell wrapper (pale bordered container used to group cards) */
  --shell-border-color: #dbe3ee;
  --shell-background: #f7f9fc;

  /* Status colours */
  --success-color: #15803d;
  --success-background: #f0fdf4;

  --warning-color: #9d6500;
  --warning-background: #fff2dc;

  --danger-color: #dc2626;
  --danger-hover: #b91c1c;
  --danger-background: #fef2f2;
  --danger-border: #fecaca;

  /* Typography */
  --font-family: "Inter", sans-serif;

  --font-size-xs: 12px;
  --font-size-sm: 13px;
  --font-size-md: 14px;
  --font-size-base: 15px;
  --font-size-lg: 16px;
  --font-size-xl: 18px;
  --font-size-2xl: 22px;
  --font-size-page-title: 32px;

  /* Spacing */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 28px;
  --space-8: 32px;
  --space-10: 40px;

  /* Component dimensions */
  --input-height: 46px;
  --button-height: 48px;
  --sidebar-width: 260px;

  /* Border radius */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 10px;
  --radius-xl: 16px;
  --radius-2xl: 20px;
  --radius-pill: 999px;

  /* Existing compatibility variable */
  --border-radius: var(--radius-md);

  /* Shadows */
  --shadow-sm: 0 4px 14px rgba(15, 23, 42, 0.08);
  --shadow-md: 0 12px 30px rgba(15, 23, 42, 0.12);
  --shadow-lg: 0 25px 60px rgba(15, 23, 42, 0.12);
  --shadow-overlay: 0 24px 60px rgba(15, 23, 42, 0.24);

  /* Existing compatibility variable */
  --box-shadow: var(--shadow-lg);

  /* Transitions */
  --transition-fast: 0.15s ease;
  --transition-base: 0.2s ease;
  --transition-slow: 0.25s ease;

  /* Layout */
--workspace-max-width: 1760px;
--page-gutter: 32px;
--modal-max-width: 640px;
}

/* ========================================
   GLOBAL RESET
======================================== */

*,
*::before,
*::after {
  box-sizing: border-box;
}

* {
  margin: 0;
  padding: 0;
}

html {
  font-family: var(--font-family);
}

html {
  scrollbar-gutter: stable;
}

body,
button,
input,
select,
textarea {
  font: inherit;
}

body.modal-open {
  overflow: hidden;
}

/*
 * Without this, any element whose own class rule sets `display`
 * explicitly (flex/grid/etc.) silently overrides the browser's
 * default `[hidden] { display: none }` — an author-origin rule always
 * beats the user-agent stylesheet regardless of specificity. Toggling
 * `.hidden = true` on such an element then does nothing visible,
 * which is exactly the class of bug this rule exists to prevent app-
 * wide, on every page.
 */
[hidden] {
  display: none !important;
}

/* ========================================
   SHARED BODY STYLES
======================================== */

body {
  min-height: 100vh;
  color: var(--text-primary);
  background: linear-gradient(
    135deg,
    var(--primary-surface) 0%,
    var(--background-color) 100%
  );
  line-height: 1.5;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

/* ========================================
   FORMS
======================================== */

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 600;
}

/* ========================================
   INPUTS
======================================== */

.input-box {
  position: relative;
}

.input-box i {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: #b0b6c3;
}

.input-box input {
  width: 100%;
  height: var(--input-height);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding-left: 42px;
  font-size: 14px;
  outline: none;
  transition:
    border-color 0.25s ease,
    box-shadow 0.25s ease;
}

.input-box input:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(91, 78, 245, 0.15);
}

/* ========================================
   BUTTONS
======================================== */

button {
  width: 100%;
  height: var(--button-height);
  border: none;
  border-radius: var(--border-radius);
  background: var(--primary-color);
  color: white;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition:
    background-color 0.2s ease,
    transform 0.2s ease,
    box-shadow 0.2s ease;
}

button:hover {
  background: var(--primary-hover);
  transform: translateY(-2px);
}

button:active {
  transform: translateY(0);
}

button:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

/* ========================================
   FORM CONTROLS
======================================== */

.form-control {
  width: 100%;
  height: var(--input-height);
  padding: 0 14px;
  color: var(--text-primary);
  background: var(--card-background);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  font-family: inherit;
  font-size: 14px;
  outline: none;
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease;
}

.form-control:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(91, 78, 245, 0.15);
}

/* ========================================
   VALIDATION MODAL
======================================== */

.validation-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.validation-modal-backdrop,
.property-modal-backdrop,
.goal-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(3px);
}

.validation-modal-dialog {
  position: relative;
  width: 100%;
  max-width: 420px;
  padding: 32px;
  border-radius: 18px;
  background: var(--surface-color);
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.24);
  text-align: center;
  animation: validationModalEnter 180ms ease-out;
}

.validation-modal-dialog--wide {
  max-width: 480px;
}

.validation-modal-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  margin: 0 auto 18px;
  border-radius: 50%;
  background: #fee2e2;
  color: var(--danger-color);
  font-size: 24px;
}

.validation-modal-icon--info {
  background: var(--primary-surface);
  color: var(--primary-color);
}

.validation-modal-dialog h2 {
  margin: 0 0 10px;
  color: var(--text-dark);
  font-size: 22px;
}

.validation-modal-dialog p {
  margin: 0 0 24px;
  color: var(--text-muted);
  line-height: 1.6;
}

.validation-modal-button {
  width: 100%;
  min-height: 46px;
  border: none;
  border-radius: 10px;
  background: var(--primary-color);
  color: var(--surface-color);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.validation-modal-button:hover {
  background: var(--primary-hover);
}

.validation-modal-button:focus-visible {
  outline: 3px solid rgba(91, 78, 245, 0.25);
  outline-offset: 3px;
}

.validation-modal-actions {
  display: flex;
  gap: 10px;
}

.validation-modal-button--secondary {
  background: var(--surface-color);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.validation-modal-button--secondary:hover {
  background: var(--surface-hover);
}

.validation-modal-button--danger {
  background: var(--danger-color);
}

.validation-modal-button--danger:hover {
  background: var(--danger-hover);
}

@keyframes validationModalEnter {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

body.validation-modal-open {
  overflow: hidden;
}

/* ========================================
   PIN INPUT ERROR
   Shared by the Client Profile delete-PIN modal and the Dashboard
   batch-delete modal's per-client PIN fields.
======================================== */

.pin-input-error {
  margin: 6px 0 0;
  color: var(--danger-color);
  font-size: 12px;
  text-align: left;
}

.forgot-password-success {
  margin: 6px 0 0;
  color: var(--success-color);
  font-size: 12px;
  text-align: left;
}

.validation-modal-dialog .form-control {
  margin-bottom: 20px;
}

/* ========================================
   PASSWORD PROTECTION (SHARED)
   Used by Client Profile's per-client delete-protection card and
   Dashboard's account-wide admin override password card — same
   toggle + password field + status pattern, two different scopes.
======================================== */

.planning-switch {
  position: relative;
  display: inline-flex;
  flex: 0 0 44px;
  width: 44px;
  height: 26px;
  justify-self: end;
  cursor: pointer;
}

.planning-switch input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  border: 0;
  white-space: nowrap;
}

.planning-switch-slider {
  position: absolute;
  inset: 0;
  border: 1px solid var(--border-color);
  border-radius: 999px;
  background: var(--border-strong);
  transition:
    background-color 0.2s ease,
    border-color 0.2s ease,
    box-shadow 0.2s ease;
}

.planning-switch-slider::before {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--surface-color);
  box-shadow: 0 1px 3px rgb(15 23 42 / 25%);
  transition: transform 0.2s ease;
}

.planning-switch input:checked + .planning-switch-slider {
  background: var(--primary-color);
  border-color: var(--primary-color);
}

.planning-switch input:checked + .planning-switch-slider::before {
  transform: translateX(18px);
}

.planning-switch input:focus-visible + .planning-switch-slider {
  box-shadow: 0 0 0 3px rgb(89 76 255 / 20%);
}

.delete-protection-card {
  padding: 20px 24px;
  background: var(--surface-muted);
  border: 1px solid var(--border-color);
  border-radius: 16px;
}

.delete-protection-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.delete-protection-text strong {
  display: block;
  margin-bottom: 4px;
  color: var(--text-primary);
  font-size: 14px;
}

.delete-protection-text span {
  display: block;
  max-width: 480px;
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.5;
}

.delete-protection-pin-field {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border-color);
}

.delete-protection-pin-field label {
  display: block;
  margin-bottom: 8px;
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 600;
}

.delete-protection-pin-field input {
  width: 100%;
  max-width: 280px;
  height: 42px;
  padding: 0 14px;
  color: var(--text-primary);
  background: var(--card-background);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 14px;
  outline: none;
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease;
}

.delete-protection-pin-field input:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(91, 78, 245, 0.15);
}

.reassign-owner-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.reassign-owner-row select {
  flex: 1 1 auto;
  min-width: 0;
  max-width: 280px;
}

.reassign-owner-row button {
  flex-shrink: 0;
  width: auto;
  padding: 0 20px;
  white-space: nowrap;
}

.delete-protection-pin-status {
  margin-top: 8px;
  color: var(--text-secondary);
  font-size: 12px;
}

.delete-protection-pin-status--set {
  color: var(--success-color);
  font-weight: 600;
}
