/* ═══════════════════════════════════════════════════════════
   InkXed Design System — styles.css
   Shared across all pages. Single source of truth for tokens,
   resets, animations, and component classes.
   ═══════════════════════════════════════════════════════════ */

/* ─── Design Tokens ─── */
:root {
  /* Brand */
  --c-primary: #1F4D8F;
  --c-primary-hover: #183D72;
  --c-primary-pressed: #132F59;

  /* Brand tints */
  --c-primary-6: rgba(31, 77, 143, 0.06);
  --c-primary-10: rgba(31, 77, 143, 0.10);
  --c-primary-12: rgba(31, 77, 143, 0.12);
  --c-primary-15: rgba(31, 77, 143, 0.15);

  /* Semantic */
  --c-success: #1F9D68;
  --c-error: #D94B4B;
  --c-error-dark: #B83D3D;
  --c-warning: #F4B740;
  --c-info: #4D7EA8;
  --c-purple: #6D5BD0;

  /* Semantic tints */
  --c-success-tint: rgba(31, 157, 104, 0.12);
  --c-error-tint: rgba(217, 75, 75, 0.12);
  --c-warning-tint: rgba(244, 183, 64, 0.14);
  --c-info-tint: rgba(77, 126, 168, 0.12);
  --c-purple-tint: rgba(109, 91, 208, 0.12);

  /* Surfaces — light mode */
  --bg: #F7F8FA;
  --bg2: #FFFFFF;
  --card: #FFFFFF;
  --text: #111318;
  --text-muted: #5F6B7A;
  --text-dim: #8A94A6;
  --border: #E4E8EE;
  --border-light: #EEF2F6;
  --input-bg: #FFFFFF;
  --input-border: #D9E0E8;
  --shadow-color: rgba(15, 23, 42, 0.06);

  /* Radii — 5 values, down from 17 */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 16px;
  --r-full: 9999px;

  /* Shadows — 4 levels */
  --sh-sm: 0 1px 4px rgba(15, 23, 42, 0.06);
  --sh-md: 0 4px 16px rgba(31, 77, 143, 0.25);
  --sh-lg: 0 12px 40px rgba(0, 0, 0, 0.12);
  --sh-glow: 0 10px 24px rgba(31, 77, 143, 0.25);

  /* Spacing — 8 values */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;
  --sp-10: 40px;

  /* Type scale — 9 values, down from 19 */
  --fs-xs: 12px;
  --fs-sm: 13px;
  --fs-base: 15px;
  --fs-md: 16px;
  --fs-lg: 18px;
  --fs-xl: 22px;
  --fs-2xl: 28px;
  --fs-3xl: 32px;
  --fs-4xl: 40px;

  /* Fonts */
  --ff-body: 'DM Sans', sans-serif;
  --ff-display: 'Playfair Display', serif;
}

/* ─── Base Resets ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { width: 100%; overflow-x: hidden; }
html { background: var(--bg); }
body { margin: 0; background: var(--bg); font-family: var(--ff-body); color: var(--text); }
#root { width: 100%; }
input::placeholder, textarea::placeholder { color: var(--text-dim); }
select option { background: var(--card); color: var(--text); }

/* ─── Scrollbar ─── */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(0, 0, 0, 0.12); border-radius: 3px; }

/* ─── Focus ─── */
:focus-visible {
  outline: 2px solid var(--c-primary);
  outline-offset: 2px;
}
:focus:not(:focus-visible) { outline: none; }

/* ─── Animations ─── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes slideIn {
  from { opacity: 0; transform: translateX(30px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) scale(0.95); }
  to { opacity: 1; transform: translateX(-50%) scale(1); }
}

/* Suppress column scrollbar in calendar */
[id^=dp-col-]::-webkit-scrollbar { display: none; }

/* ─── Component: Card ─── */
.card {
  background: var(--card);
  border-radius: var(--r-xl);
  padding: var(--sp-5);
  border: 1px solid var(--border);
  box-shadow: var(--sh-sm);
}

/* ─── Component: Input ─── */
.inp {
  width: 100%;
  padding: 11px 14px;
  border-radius: var(--r-md);
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  color: var(--text);
  font-size: var(--fs-base);
  font-family: var(--ff-body);
  outline: none;
  box-sizing: border-box;
  transition: border-color 0.2s;
}
.inp:focus { border-color: rgba(31, 77, 143, 0.4); }
textarea.inp { min-height: 100px; resize: vertical; }
select.inp { cursor: pointer; }

/* ─── Component: Label ─── */
.label {
  color: var(--text-dim);
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 600;
  display: block;
  margin-bottom: 6px;
}

/* ─── Component: Buttons ─── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: var(--ff-body);
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
  border: none;
  text-decoration: none;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; }

/* Primary */
.btn-primary {
  padding: 10px 18px;
  border-radius: var(--r-md);
  background: linear-gradient(135deg, var(--c-primary), var(--c-primary-hover));
  color: #fff;
  font-size: var(--fs-base);
  box-shadow: var(--sh-md);
}
.btn-primary:hover:not(:disabled) { transform: translateY(-1px); }

/* Primary large (full-width CTA) */
.btn-primary-lg {
  width: 100%;
  padding: 16px;
  border-radius: var(--r-lg);
  background: linear-gradient(135deg, var(--c-primary), var(--c-primary-hover));
  color: #fff;
  font-size: var(--fs-md);
  font-weight: 700;
  box-shadow: var(--sh-glow);
}
.btn-primary-lg:hover:not(:disabled) { transform: translateY(-1px); }

/* Secondary */
.btn-secondary {
  padding: 10px 18px;
  border-radius: var(--r-md);
  background: var(--border-light);
  color: var(--text-dim);
  font-size: var(--fs-base);
}

/* Ghost */
.btn-ghost {
  padding: 10px 18px;
  border-radius: var(--r-md);
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: var(--fs-base);
}

/* Danger */
.btn-danger {
  padding: 10px 18px;
  border-radius: var(--r-md);
  background: linear-gradient(135deg, var(--c-error), var(--c-error-dark));
  color: #fff;
  font-size: var(--fs-base);
  box-shadow: 0 4px 16px rgba(217, 75, 75, 0.25);
}

/* Small variant */
.btn-sm { padding: 6px 12px; font-size: var(--fs-sm); }

/* ─── Component: Pill / Badge ─── */
.pill {
  font-size: var(--fs-xs);
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--r-full);
  white-space: nowrap;
  display: inline-block;
}

/* ─── Component: Section Title ─── */
.section-title {
  color: var(--text-dim);
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 600;
}

/* ─── Component: Detail Row ─── */
.detail-row {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-light);
}
.detail-row:last-child { border-bottom: none; }
.detail-label { color: var(--text-dim); font-size: var(--fs-base); }
.detail-value { color: var(--text); font-size: var(--fs-base); font-weight: 600; }

/* ─── Component: Required Asterisk ─── */
.req { color: var(--c-error) !important; }

/* ─── Utility: Powered by footer ─── */
.powered-by {
  text-align: center;
  padding: var(--sp-6) 0;
  border-top: 1px solid var(--border);
  color: var(--text-dim);
  font-size: var(--fs-xs);
}

/* ─── External page container ─── */
.page-wrap {
  min-height: 100vh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: var(--sp-5);
  animation: fadeUp 0.4s ease;
}
.page-content {
  width: 100%;
  max-width: 480px;
}

/* ─── Loading state ─── */
.loading-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--c-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto;
}

/* ─── Success checkmark circle ─── */
.success-circle {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--c-success-tint);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto var(--sp-5);
}

/* ─── Error/invalid state ─── */
.error-circle {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--c-error-tint);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto var(--sp-5);
}

/* ─── Accessibility ─── */

/* Focus states for accessibility */
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--c-primary);
  outline-offset: 2px;
}

/* Remove default outline only when using mouse */
button:focus:not(:focus-visible), a:focus:not(:focus-visible) {
  outline: none;
}

/* Prevent iOS Safari auto-zoom on input focus (requires 16px minimum) */
@media screen and (max-width: 768px) {
  input, select, textarea {
    font-size: 16px !important;
  }
}

/* Minimum touch targets for mobile — only for primary action buttons */
@media (pointer: coarse) {
  /* Primary/secondary/ghost buttons with text get min-height + centering */
  .btn, .btn-primary, .btn-primary-lg, .btn-secondary, .btn-ghost, .btn-destructive {
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* Selects get min-height for usability */
  select {
    min-height: 44px;
  }

  /* Exceptions — don't enlarge these */
  .pill, .badge, [data-compact] {
    min-height: unset;
    min-width: unset;
  }
}

/* Disabled button styling */
button:disabled, button[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}
