/* undanganAI — design system
   Apple aesthetic. Used by app UI (login, builder, dashboard, homepage).
   Templates ship their own type/colour; this is the product chrome only. */

/* ── Tokens ──────────────────────────────────────────────────────────────── */
:root {
  --bg: #ffffff;
  --bg-soft: #fbfbfd;
  --bg-soft-2: #f5f5f7;
  --border: #e8e8ed;
  --border-strong: #d2d2d7;
  --text: #1d1d1f;
  --text-soft: #6e6e73;
  --text-muted: #86868b;
  --accent: #0071e3;
  --accent-hover: #0077ed;
  --accent-soft: #ebf3fd;
  --success: #1d8a4e;
  --success-soft: #e7f4ec;
  --error: #d92d20;
  --error-soft: #fdeceb;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.08);

  /* 4px spacing scale */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 18px;
  --r-pill: 980px;

  --font-ui: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Inter',
    'Segoe UI', sans-serif;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Reset ───────────────────────────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
html {
  -webkit-text-size-adjust: 100%;
}
body {
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
img,
svg {
  display: block;
  max-width: 100%;
}
button,
input,
textarea,
select {
  font: inherit;
  color: inherit;
}
a {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

/* ── Typography ──────────────────────────────────────────────────────────── */
h1,
h2,
h3,
h4 {
  font-weight: 600;
  letter-spacing: -0.025em;
  line-height: 1.15;
  color: var(--text);
}
h1 {
  font-size: clamp(32px, 5vw, 48px);
}
h2 {
  font-size: clamp(26px, 3.5vw, 34px);
}
h3 {
  font-size: 21px;
}
h4 {
  font-size: 17px;
}
p {
  line-height: 1.6;
}
.text-soft {
  color: var(--text-soft);
}
.text-muted {
  color: var(--text-muted);
}
.text-sm {
  font-size: 14px;
}
.text-xs {
  font-size: 12px;
}
.text-center {
  text-align: center;
}

/* ── Layout helpers ──────────────────────────────────────────────────────── */
.container {
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 var(--space-5);
}
.stack > * + * {
  margin-top: var(--space-4);
}
.center-screen {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-5);
}
.hidden {
  display: none !important;
}

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 11px 22px;
  font-size: 15px;
  font-weight: 500;
  border: 1px solid transparent;
  border-radius: var(--r-pill);
  cursor: pointer;
  transition: background 0.2s var(--ease), opacity 0.2s var(--ease),
    transform 0.1s var(--ease);
  white-space: nowrap;
  text-decoration: none;
}
.btn:active {
  transform: scale(0.98);
}
.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.btn--primary {
  background: var(--accent);
  color: #fff;
}
.btn--primary:hover:not(:disabled) {
  background: var(--accent-hover);
}
.btn--secondary {
  background: var(--bg-soft-2);
  color: var(--text);
}
.btn--secondary:hover:not(:disabled) {
  background: var(--border);
}
.btn--ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--border-strong);
}
.btn--ghost:hover:not(:disabled) {
  background: var(--bg-soft-2);
}
.btn--block {
  width: 100%;
}
.btn--lg {
  padding: 14px 28px;
  font-size: 17px;
}
.btn--sm {
  padding: 8px 16px;
  font-size: 13px;
}

/* ── Form controls ───────────────────────────────────────────────────────── */
.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.field label {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-soft);
}
.input {
  width: 100%;
  /* 16px keeps iOS from zooming the viewport on focus */
  font-size: 16px;
  padding: 12px 14px;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.input::placeholder {
  color: var(--text-muted);
}
.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}
.input:disabled {
  background: var(--bg-soft-2);
  color: var(--text-muted);
}
textarea.input {
  resize: vertical;
  min-height: 96px;
}

/* ── Card ────────────────────────────────────────────────────────────────── */
.card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  padding: var(--space-6);
}

/* ── Badge ───────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-size: 12px;
  font-weight: 500;
  padding: 3px 10px;
  border-radius: var(--r-pill);
  background: var(--bg-soft-2);
  color: var(--text-soft);
}
.badge--success {
  background: var(--success-soft);
  color: var(--success);
}
.badge--error {
  background: var(--error-soft);
  color: var(--error);
}
.badge--info {
  background: var(--accent-soft);
  color: var(--accent);
}

/* ── Loading states ──────────────────────────────────────────────────────── */
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.spinner--on-accent {
  border-color: rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
}
.spinner--sm {
  width: 16px;
  height: 16px;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.skeleton {
  background: linear-gradient(
    90deg,
    var(--bg-soft-2) 25%,
    var(--border) 37%,
    var(--bg-soft-2) 63%
  );
  background-size: 400% 100%;
  border-radius: var(--r-sm);
  animation: shimmer 1.4s ease infinite;
}
@keyframes shimmer {
  0% {
    background-position: 100% 0;
  }
  100% {
    background-position: -100% 0;
  }
}

/* ── Toast notifications ─────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  top: var(--space-4);
  right: var(--space-4);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  min-width: 260px;
  max-width: 360px;
  padding: 13px 15px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-left: 3px solid var(--text-muted);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  font-size: 14px;
  pointer-events: auto;
  cursor: pointer;
  transform: translateX(130%);
  opacity: 0;
  transition: transform 0.35s var(--ease), opacity 0.35s var(--ease);
}
.toast--in {
  transform: translateX(0);
  opacity: 1;
}
.toast--out {
  transform: translateX(130%);
  opacity: 0;
}
.toast__icon {
  flex-shrink: 0;
  display: flex;
}
.toast__icon svg {
  width: 18px;
  height: 18px;
}
.toast__msg {
  padding-top: 1px;
}
.toast--success {
  border-left-color: var(--success);
}
.toast--success .toast__icon {
  color: var(--success);
}
.toast--error {
  border-left-color: var(--error);
}
.toast--error .toast__icon {
  color: var(--error);
}
.toast--info {
  border-left-color: var(--accent);
}
.toast--info .toast__icon {
  color: var(--accent);
}

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .container {
    padding: 0 var(--space-4);
  }
  .card {
    padding: var(--space-5);
  }
  .toast-container {
    left: var(--space-4);
    right: var(--space-4);
  }
  .toast {
    max-width: none;
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
