/* ── Spareza Design System — Base Tokens & Resets ── */

:root {
  --primary-600: #1a56db;
  --primary-500: #1c64f2;
  --primary-400: #76a9fa;
  --primary-200: #c3ddfd;
  --primary-100: #ebf5ff;
  --neutral-1000: #111928;
  --neutral-900: #1f2a37;
  --neutral-800: #374151;
  --neutral-700: #4b5563;
  --neutral-600: #6b7280;
  --neutral-500: #848b98;
  --neutral-400: #9ca3af;
  --neutral-200: #d1d5db;
  --neutral-100: #f3f4f6;
  --neutral-50: #f9fafb;
  --white: #ffffff;
  --success-600: #057a55;
  --success-500: #057a55;
  --success-200: #bcf0da;
  --success-100: #f3faf7;
  --warning-600: #9d6307;
  --warning-500: #c27803;
  --warning-200: #fce96a;
  --warning-100: #fdfdea;
  --error-600: #c81e1e;
  --error-500: #c81e1e;
  --error-200: #fbd5d5;
  --error-100: #fdf2f2;
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-2xl: 24px;
  --radius-full: 9999px;
  --shadow-sm:
    0 1px 3px rgba(17, 25, 40, 0.07), 0 1px 2px rgba(17, 25, 40, 0.04);
  --shadow-md:
    0 4px 12px rgba(17, 25, 40, 0.09), 0 2px 4px rgba(17, 25, 40, 0.05);
  --shadow-lg:
    0 12px 32px rgba(17, 25, 40, 0.12), 0 4px 8px rgba(17, 25, 40, 0.06);
  --w: 1280px;
}

/* ── Base Resets ── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
html {
  scroll-behavior: smooth;
  overflow-x: visible;
  overscroll-behavior-x: none;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}
body {
  font-family:
    "Inter",
    -apple-system,
    BlinkMacSystemFont,
    sans-serif;
  background: var(--neutral-50);
  color: var(--neutral-1000);
  line-height: 1.5;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  width: 100%;
  overflow-x: visible;
  overscroll-behavior-x: none;
}
a {
  color: inherit;
  text-decoration: none;
}
img {
  display: block;
  max-width: 100%;
  height: auto;
}
button,
input,
select,
textarea {
  font: inherit;
}
button,
[role="button"] {
  cursor: pointer;
}
:focus-visible {
  outline: 3px solid rgba(28, 100, 242, 0.35);
  outline-offset: 2px;
}
.skip-link {
  position: fixed;
  top: 8px;
  left: -9999px;
  z-index: 2000;
  padding: 10px 14px;
  background: var(--white);
  color: var(--neutral-1000);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  opacity: 0;
}
.skip-link:focus {
  left: 8px;
  opacity: 1;
}
#main-content {
  min-height: 45vh;
  flex: 1 0 auto;
  width: 100%;
  max-width: 100%;
  overflow-x: visible;
  overscroll-behavior-x: none;
}
.parsley-required,
.parsley-minlength,
.parsley-equalto,
.parsley-type,
.parsley-length {
  font-size: 10px;
  color: #ef4444;
}
.tb-flags {
  height: 15px;
}

/* ══════════════════════════════════════
   HEADER PLACEHOLDER
══════════════════════════════════════ */
.header-placeholder {
  background: var(--neutral-1000);
  border-bottom: 2px dashed rgba(255, 255, 255, 0.12);
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--neutral-400);
  font-size: 12px;
}
.header-placeholder a {
  color: var(--primary-400);
  font-size: 12px;
}
.header-placeholder a:hover {
  text-decoration: underline;
}

/* =======================
      MODAL WINDOWS
 =========================*/
/* ── COMMON MODAL STYLES ── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(17, 25, 40, 0.65);
  backdrop-filter: blur(4px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-overlay.open {
  display: flex;
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.modal {
  background: var(--white);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 480px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.22);
  animation: slideUp 0.22s ease;
  overflow: hidden;
  max-height: 90vh;
  overflow-y: auto;
}
@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.modal-head-dark {
  background: var(--neutral-900);
  padding: 18px 20px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
}
.modal-head-icon {
  width: 42px;
  height: 42px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.modal-head-text {
  flex: 1;
}
.modal-head-title {
  font-size: 16px;
  font-weight: 800;
  color: white;
  letter-spacing: -0.3px;
  margin-bottom: 2px;
}
.modal-head-sub {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.5);
  line-height: 1.4;
}
.modal-close-btn {
  width: 30px;
  height: 30px;
  background: rgba(255, 255, 255, 0.12);
  border: none;
  border-radius: var(--radius-md);
  color: rgba(255, 255, 255, 0.7);
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s;
}
.modal-close-btn:hover {
  background: rgba(255, 255, 255, 0.22);
  color: white;
}

.modal-body {
  padding: 20px;
}
.modal-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--neutral-200);
  display: flex;
  gap: 10px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 14px;
}
.field:last-child {
  margin-bottom: 0;
}
.field-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--neutral-600);
}
.field-input {
  height: 42px;
  padding: 0 12px;
  border: 1.5px solid var(--neutral-200);
  border-radius: var(--radius-md);
  font-size: 14px;
  font-family: "Inter", sans-serif;
  color: var(--neutral-1000);
  background: var(--white);
  outline: none;
  transition: border-color 0.15s;
  -webkit-appearance: none;
}
.field-input:focus {
  border-color: var(--primary-500);
}

.auth-login-error {
  margin-bottom: 16px;
  padding: 11px 13px;
  border: 1px solid #ef4444;
  border-radius: 9px;
  background: #fff1f2;
  color: #b42318;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.45;
}

.auth-login-error[hidden] {
  display: none;
}

form[data-form="login"].has-auth-error .field-input {
  border-color: #ef4444;
  background: #fffafa;
}
.field-textarea {
  padding: 10px 12px;
  border: 1.5px solid var(--neutral-200);
  border-radius: var(--radius-md);
  font-size: 13px;
  font-family: "Inter", sans-serif;
  color: var(--neutral-1000);
  resize: none;
  outline: none;
  transition: border-color 0.15s;
  line-height: 1.5;
}
.field-textarea:focus {
  border-color: var(--primary-500);
}
.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* Registration names need the full modal width. Keeping them in one row can
   squeeze or visually crop the surname field in narrower browser windows. */
.auth-name-grid {
  grid-template-columns: minmax(0, 1fr);
}
.auth-name-grid .field,
.auth-name-grid .field-input {
  min-width: 0;
  width: 100%;
}

.btn-primary {
  height: 46px;
  background: var(--primary-500);
  color: white;
  border: none;
  border-radius: var(--radius-lg);
  font-size: 14px;
  font-weight: 700;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  transition: background 0.15s;
}
.btn-primary:hover {
  background: var(--primary-600);
}
.btn-secondary {
  height: 46px;
  background: var(--neutral-100);
  color: var(--neutral-800);
  border: none;
  border-radius: var(--radius-lg);
  font-size: 14px;
  font-weight: 600;
  padding: 0 20px;
  transition: background 0.15s;
}
.btn-secondary:hover {
  background: var(--neutral-200);
}

@media (max-width: 768px) {
  /* iOS zooms focused controls whose computed font size is below 16px. */
  input,
  select,
  textarea,
  [contenteditable="true"] {
    font-size: 16px !important;
  }
  body {
    padding-bottom: env(safe-area-inset-bottom);
  }
  .field-grid {
    grid-template-columns: 1fr;
  }
  .modal-overlay {
    padding: 10px;
    align-items: flex-end;
  }
  .modal {
    max-height: calc(100dvh - 20px);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  }
  .modal-body {
    padding: 16px;
  }
  .modal-footer {
    flex-direction: column-reverse;
  }
  .modal-footer > * {
    width: 100%;
  }
}
