/* ============================================================
   UI COMPONENTS — Reusable UI patterns for the entire Dazzle project
   Dependency: tokens.css (variables must be loaded before this file)
   Version: 1.0
   ============================================================ */

/* ----------------------------------------------
   1. BUTTONS
   ---------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: var(--touch-target-min);
  padding: var(--space-2) var(--space-5);
  border: 0;
  border-radius: var(--radius-md);
  font-weight: 800;
  font-size: var(--text-body-sm);
  cursor: pointer;
  transition: all var(--duration-page) var(--ease-standard);
  text-decoration: none;
  white-space: nowrap;
  font-family: inherit;
  line-height: 1;
}
.btn:focus-visible {
  outline: var(--focus-ring-width) solid var(--landing-purple);
  outline-offset: var(--focus-ring-offset);
}
.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none !important;
}

/* Primary (Purple gradient) */
.btn-primary {
  background: var(--landing-purple);
  color: var(--on-purple);
  box-shadow: var(--shadow-purple);
}
.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 10px 32px rgba(124, 88, 253, 0.40);
}
.btn-primary:active:not(:disabled) {
  transform: translateY(0);
}

/* Outline (Purple border) */
.btn-outline {
  border: 1.5px solid var(--landing-purple);
  background: transparent;
  color: var(--landing-purple);
}
.btn-outline:hover:not(:disabled) {
  background: rgba(124, 88, 253, 0.06);
  transform: translateY(-1px);
}

/* Danger (Logout / Delete) */
.btn-danger {
  border: 1.5px solid var(--color-error-border);
  background: #ffffff;
  color: var(--color-error);
}
.btn-danger:hover:not(:disabled) {
  background: var(--color-error-light);
  border-color: var(--color-error);
  transform: translateY(-1px);
}

/* Lime CTA (used in landing/pricing) */
.btn-lime {
  background: var(--landing-lime);
  color: var(--on-lime);
  box-shadow: 0 6px 20px rgba(194, 255, 69, 0.25);
}
.btn-lime:hover:not(:disabled) {
  background: var(--landing-lime-hover);
  transform: translateY(-2px);
  box-shadow: 0 10px 28px rgba(194, 255, 69, 0.35);
}

/* Full width */
.btn-block {
  width: 100%;
  justify-content: center;
  padding-inline: var(--space-3);
}

/* Large size (Auth pages, primary CTAs) */
.btn-lg {
  min-height: 52px;
  padding: var(--space-3) var(--space-6);
  font-size: var(--text-body);
  border-radius: var(--radius-lg);
}

/* ----------------------------------------------
   2. CARDS
   ---------------------------------------------- */
.card {
  background: #ffffff;
  border: 1px solid rgba(124, 88, 253, 0.10);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: 0 6px 20px rgba(124, 88, 253, 0.05);
  transition: box-shadow var(--duration-page) var(--ease-standard);
}

.card-compact {
  padding: var(--space-4);
}

.card-hover {
  transition: transform var(--duration-page) var(--ease-standard),
              box-shadow var(--duration-page) var(--ease-standard);
}
.card-hover:hover {
  transform: translateY(-3px);
  box-shadow: 0 14px 36px rgba(124, 88, 253, 0.12);
}

/* Glassmorphism card (used in auth, landing cards) */
.card-glass {
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(24px) saturate(1.3);
  -webkit-backdrop-filter: blur(24px) saturate(1.3);
  border: 1px solid rgba(124, 88, 253, 0.10);
}

/* ----------------------------------------------
   3. FORM INPUTS
   ---------------------------------------------- */
.input {
  width: 100%;
  height: 48px;
  border: 1.5px solid rgba(124, 88, 253, 0.15);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.9);
  padding: 0 var(--space-3);
  color: var(--landing-ink);
  font: inherit;
  font-size: var(--text-body-sm);
  outline: none;
  transition: all var(--duration-page) var(--ease-standard);
}
.input:focus {
  border-color: var(--landing-purple);
  background: #ffffff;
  box-shadow: 0 0 0 4px rgba(124, 88, 253, 0.10);
}
.input::placeholder {
  color: #b8aed4;
}
.input:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Input with left/right icon (uses flex wrapper, see HTML pattern) */
.input-wrap {
  position: relative;
}
.input-wrap .input {
  padding-inline-start: 44px; /* For LTR */
}
.input-wrap .input-icon {
  position: absolute;
  inset-inline-start: var(--space-4);
  top: 50%;
  transform: translateY(-50%);
  color: var(--landing-purple);
  opacity: 0.55;
  pointer-events: none;
  transition: opacity var(--duration-page) var(--ease-standard);
}
.input-wrap:focus-within .input-icon {
  opacity: 1;
}

/* RTL override for input icon */
html[dir="rtl"] .input-wrap .input {
  padding-inline-start: var(--space-3);
  padding-inline-end: 44px;
}
html[dir="rtl"] .input-wrap .input-icon {
  inset-inline-start: auto;
  inset-inline-end: var(--space-4);
}

/* Input Large (Auth pages) */
.input-lg {
  height: 52px;
  font-size: var(--text-body);
  border-radius: var(--radius-md);
}

/* Textarea */
.textarea {
  width: 100%;
  border: 1.5px solid rgba(124, 88, 253, 0.15);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.9);
  padding: var(--space-3);
  color: var(--landing-ink);
  font: inherit;
  font-size: var(--text-body-sm);
  outline: none;
  resize: vertical;
  transition: all var(--duration-page) var(--ease-standard);
  min-height: 120px;
  line-height: 1.8;
}
.textarea:focus {
  border-color: var(--landing-purple);
  background: #ffffff;
  box-shadow: 0 0 0 4px rgba(124, 88, 253, 0.10);
}

/* ----------------------------------------------
   4. ALERTS / NOTICES
   ---------------------------------------------- */
.alert {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--text-body-sm);
  font-weight: 700;
  line-height: 1.7;
  animation: alertFadeIn var(--duration-page) ease both;
}
.alert svg {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.alert-success {
  background: var(--color-success-light);
  border: 1px solid var(--color-success-border);
  color: var(--color-success);
}
.alert-error {
  background: var(--color-error-light);
  border: 1px solid var(--color-error-border);
  color: var(--color-error);
}

@keyframes alertFadeIn {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ----------------------------------------------
   5. BADGES / CHIPS / PILLS
   ---------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  font-size: var(--text-caption);
  font-weight: 800;
  line-height: 1.4;
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.lang-fa .badge {
  text-transform: none;
  letter-spacing: 0;
}

.badge-purple {
  background: rgba(124, 88, 253, 0.10);
  color: var(--landing-purple-dark);
}
.badge-lime {
  background: rgba(194, 255, 69, 0.20);
  color: #4a6418;
}
.badge-success {
  background: var(--color-success-light);
  color: var(--color-success);
}
.badge-danger {
  background: var(--color-error-light);
  color: var(--color-error);
}

/* Category Chip (interactive) */
.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-full);
  border: 1.5px solid rgba(124, 88, 253, 0.10);
  background: rgba(124, 88, 253, 0.03);
  color: #4d3d72;
  font-weight: 700;
  font-size: var(--text-body-sm);
  transition: all var(--duration-page) var(--ease-standard);
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}
.chip:hover {
  border-color: rgba(124, 88, 253, 0.30);
  background: rgba(124, 88, 253, 0.08);
  color: var(--landing-purple-dark);
  transform: translateY(-2px);
}
.chip-active {
  background: var(--landing-purple);
  border-color: var(--landing-purple);
  color: #ffffff !important;
  box-shadow: 0 4px 16px rgba(124, 88, 253, 0.25);
}
.chip-active:hover {
  color: #ffffff !important;
  background: var(--landing-purple-dark);
}

/* ----------------------------------------------
   6. PAGINATION
   ---------------------------------------------- */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
  margin: var(--space-7) 0 var(--space-2);
}
.pagination a,
.pagination span {
  min-width: 40px;
  min-height: 40px;
  padding: 0 var(--space-3);
  border: 1px solid rgba(124, 88, 253, 0.15);
  border-radius: var(--radius-sm);
  display: grid;
  place-items: center;
  font-size: var(--text-body-sm);
  font-weight: 700;
  color: #6a5a8a;
  background: #ffffff;
  text-decoration: none;
  transition: all var(--duration-page) var(--ease-standard);
}
.pagination a:hover {
  border-color: var(--landing-purple);
  background: rgba(124, 88, 253, 0.06);
  color: var(--landing-purple);
  transform: translateY(-1px);
}
.pagination a.active {
  background: var(--landing-purple);
  border-color: var(--landing-purple);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(124, 88, 253, 0.20);
}
.pagination a:focus-visible {
  outline: var(--focus-ring-width) solid var(--landing-purple);
  outline-offset: var(--focus-ring-offset);
}
.pagination-gap {
  min-width: 32px;
  height: 40px;
  display: grid;
  place-items: center;
  color: #9a8bbf;
  font-weight: 700;
}

/* ----------------------------------------------
   7. EMPTY STATE
   ---------------------------------------------- */
.empty-state {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  min-height: 120px;
  padding: var(--space-5);
  border: 1.5px dashed rgba(124, 88, 253, 0.25);
  border-radius: var(--radius-md);
  background: rgba(124, 88, 253, 0.03);
  color: #8a7ab0;
  text-align: center;
}
.empty-state span {
  font-size: var(--text-h3);
  opacity: 0.6;
}
.empty-state p {
  margin: 0;
  font-size: var(--text-body-sm);
  line-height: 1.7;
}
.empty-state img {
  width: 52px;
  height: 52px;
  opacity: 0.5;
}

/* ----------------------------------------------
   8. BREADCRUMB
   ---------------------------------------------- */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
  font-size: var(--text-caption);
  color: #8a7ab0;
  margin: 0 0 var(--space-5);
}
.breadcrumb a {
  color: var(--landing-purple);
  font-weight: 700;
  transition: color var(--duration-micro) var(--ease-standard);
}
.breadcrumb a:hover {
  color: var(--landing-purple-dark);
}
.breadcrumb a:focus-visible {
  outline: var(--focus-ring-width) solid var(--landing-purple);
  outline-offset: var(--focus-ring-offset);
  border-radius: var(--radius-sm);
}
.breadcrumb span:last-child {
  color: var(--landing-ink);
  font-weight: 700;
}
/* RTL support for breadcrumb separators */
html[dir="rtl"] .breadcrumb span:not(:last-child)::after {
  content: "‹";
  margin-inline: var(--space-1);
}
html[dir="ltr"] .breadcrumb span:not(:last-child)::after {
  content: "›";
  margin-inline: var(--space-1);
}

/* ----------------------------------------------
   9. EYEBROW (Section headers)
   ---------------------------------------------- */
.eyebrow {
  display: block;
  font-size: var(--text-caption);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--landing-purple);
  margin: 0 0 var(--space-2);
}
.lang-fa .eyebrow {
  text-transform: none;
  letter-spacing: 0;
}

/* ----------------------------------------------
   10. BACKDROP / OVERLAY (for modals & sidebars)
   ---------------------------------------------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 999;
  border: 0;
  padding: 0;
  background: rgba(26, 16, 40, 0.35);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--duration-complex) var(--ease-standard);
  cursor: pointer;
}
.overlay.show {
  opacity: 1;
  pointer-events: auto;
}

/* ----------------------------------------------
   11. LANGUAGE BADGE (for book covers & filters)
   ---------------------------------------------- */
.lang-badge {
  position: absolute;
  inset-inline-start: var(--space-2);
  top: var(--space-2);
  min-width: 28px;
  height: 24px;
  padding: 0 var(--space-2);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.94);
  color: var(--landing-purple-dark);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-caption);
  font-weight: 900;
  letter-spacing: 0.04em;
  direction: ltr;
  box-shadow: 0 3px 9px rgba(124, 88, 253, 0.10);
  backdrop-filter: blur(5px);
}

/* ----------------------------------------------
   12. MISC UTILITIES
   ---------------------------------------------- */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.text-center { text-align: center; }
.text-start { text-align: start; }
.text-end { text-align: end; }

/* ----------------------------------------------
   13. BRAND / LOGO
   ---------------------------------------------- */
.dazzle-brand {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    text-decoration: none;
    color: var(--landing-ink);
}
.dazzle-brand img {
    width: 38px;
    height: 38px;
    object-fit: contain;
    flex: 0 0 auto;
}
.dazzle-brand > span {
    font: 800 25px/1 Literata, Georgia, serif;
}
.dazzle-brand-footer {
    color: var(--landing-white);
}
.dazzle-brand-footer > span {
    color: var(--landing-white);
}