/* =========================================================
   components.css — reusable UI units
   btn / card / tag / form / FAB / mobile tabbar / placeholders
   ========================================================= */

/* ============ BUTTON ============ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  font-family: var(--ff-sans);
  font-weight: var(--fw-semibold);
  letter-spacing: 0.01em;
  text-decoration: none;
  border-radius: var(--radius-sm);
  border: 1.5px solid transparent;
  cursor: pointer;
  transition:
    background var(--dur-base) var(--ease-out),
    color var(--dur-base) var(--ease-out),
    border-color var(--dur-base) var(--ease-out),
    box-shadow var(--dur-base) var(--ease-out),
    transform var(--dur-fast) var(--ease-out);
  white-space: nowrap;
}

.btn:focus-visible { box-shadow: var(--focus-ring); }

.btn .btn-arrow {
  width: 1em;
  height: 1em;
  transition: transform var(--dur-base) var(--ease-out);
}
.btn:hover .btn-arrow { transform: translateX(6px); }

/* sizes */
.btn-sm { padding: 8px 16px;  font-size: var(--fs-body-sm); }
.btn-md { padding: 12px 24px; font-size: 15px; }
.btn-lg { padding: 16px 32px; font-size: var(--fs-body); }

/* variants */
.btn-primary {
  background: var(--btn-primary-bg);
  color: var(--btn-primary-text);
}
.btn-primary:hover {
  background: var(--btn-primary-hover);
  color: #fff;
  transform: translateY(-1px);
  box-shadow: var(--shadow-brand);
}

.btn-secondary {
  background: transparent;
  color: var(--color-primary-700);
  border-color: var(--color-primary-500);
}
.btn-secondary:hover {
  background: var(--color-primary-500);
  color: #fff;
  transform: translateY(-1px);
}

.btn-ghost {
  background: transparent;
  color: var(--text-body);
  border-color: transparent;
}
.btn-ghost:hover { background: var(--bg-section); color: var(--text-strong); }

.btn-invert {
  background: transparent;
  color: #fff;
  border-color: rgba(255,255,255,.4);
}
.btn-invert:hover {
  background: #fff;
  color: var(--brand);
  border-color: #fff;
}

.btn-block { display: flex; width: 100%; }

/* ============ LINK (underline on hover) ============ */
.link-underline {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  font-weight: var(--fw-semibold);
  color: var(--text-strong);
  padding-bottom: 4px;
  position: relative;
}
.link-underline::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 1.5px;
  background: var(--text-strong);
  transform-origin: left;
  transition: transform var(--dur-base) var(--ease-out);
}
.link-underline:hover { color: var(--brand); }
.link-underline:hover::after {
  background: var(--brand);
  transform: scaleX(.9);
}
.link-underline .btn-arrow { width: 14px; height: 14px; transition: transform var(--dur-base) var(--ease-out); }
.link-underline:hover .btn-arrow { transform: translateX(4px); }

/* ============ CARD ============ */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: var(--sp-6);
  transition:
    transform var(--dur-base) var(--ease-out),
    box-shadow var(--dur-base) var(--ease-out),
    border-color var(--dur-base) var(--ease-out);
}

/* elevated — used in BUSINESS AREA */
.card-elevated {
  background: var(--bg-card);
  box-shadow: var(--shadow-1);
  position: relative;
  overflow: hidden;
}
.card-elevated::before {
  content: "";
  position: absolute;
  top: 0; left: 0;
  height: 4px;
  width: 40px;
  background: var(--accent);
  border-radius: 0 var(--radius-pill) var(--radius-pill) 0;
  transition: width var(--dur-slow) var(--ease-out);
}

@media (hover: hover) {
  .card-elevated:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-2);
  }
  .card-elevated:hover::before { width: 100%; }
}

/* outlined — used for PRODUCTS/info cards */
.card-outlined {
  background: var(--bg-card-alt);
  border: 1px solid var(--border-soft);
}
@media (hover: hover) {
  .card-outlined:hover {
    background: #fff;
    border-color: var(--color-primary-500);
    box-shadow: var(--shadow-2);
  }
}

/* vendor card (PRODUCTS grid) */
.card-vendor {
  position: relative;
  background: #fff;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: var(--sp-6) var(--sp-4);
  overflow: hidden;
  min-height: 170px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  transition:
    transform var(--dur-base) var(--ease-out),
    background var(--dur-base) var(--ease-out),
    border-color var(--dur-base) var(--ease-out),
    box-shadow var(--dur-base) var(--ease-out);
}
.card-vendor .monogram {
  position: absolute;
  top: -10px;
  right: -5px;
  font-family: var(--ff-display);
  font-weight: 800;
  font-size: 120px;
  line-height: 1;
  color: rgba(107,68,35,.08);
  pointer-events: none;
  user-select: none;
  transition: color var(--dur-base) var(--ease-out);
}
.card-vendor .vendor-cat {
  display: block;
  font-family: var(--ff-display);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: var(--sp-2);
  line-height: 1.4;
  min-height: 2.8em; /* reserve 2 lines so single-line labels (e.g. PLM / ALM) align with multi-line ones */
}
.card-vendor .vendor-name {
  font-family: var(--ff-display);
  font-weight: 700;
  font-size: clamp(13px, 1.15vw, 16px);
  color: var(--color-primary-700);
  letter-spacing: -0.03em;
  word-break: keep-all;
  overflow-wrap: normal;
}
.card-vendor .vendor-desc {
  font-size: var(--fs-body-sm);
  color: var(--text-muted);
  margin-top: var(--sp-2);
  line-height: var(--lh-loose);
  min-height: calc(var(--fs-body-sm) * var(--lh-loose) * 2); /* reserve 2 lines for description alignment */
}
@media (hover: hover) {
  .card-vendor:hover {
    border-color: var(--color-primary-400);
    box-shadow: 0 8px 24px rgba(107,68,35,.12);
    transform: translateY(-4px);
  }
  .card-vendor:hover .monogram { color: rgba(107,68,35,.14); }
  .card-vendor:hover .vendor-name { color: var(--color-primary-800); }
}

/* customer pill card */
.card-customer {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, .72);
  border: 1px solid rgba(107, 68, 35, .10);
  border-radius: var(--radius-pill);
  padding: 11px 22px;
  min-width: 100px;
  font-size: 14px;
  font-weight: var(--fw-medium);
  color: var(--text-strong);
  text-decoration: none;
  box-shadow: 0 1px 2px rgba(21, 19, 15, .04);
  transition: all var(--dur-base) var(--ease-out);
  white-space: nowrap;
}
@media (hover: hover) {
  .card-customer:hover {
    border-color: var(--color-primary-500);
    color: var(--color-primary-700);
    box-shadow: 0 4px 12px rgba(21, 19, 15, .08);
    transform: scale(1.04);
  }
}

/* ============ TAG PILL ============ */
.tag-pill {
  display: inline-block;
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  background: var(--color-accent-50);
  color: var(--color-accent-700);
  font-size: 11px;
  font-weight: var(--fw-semibold);
  letter-spacing: 0.02em;
  line-height: 1.4;
}

.tag-pill--brand {
  background: var(--color-primary-50);
  color: var(--color-primary-700);
}

.tag-pill--neutral {
  background: var(--color-neutral-100);
  color: var(--text-body);
}

/* ============ BADGE (small status indicator) ============ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: rgba(111,168,76,.12);
  color: var(--color-accent-700);
  border-radius: var(--radius-pill);
  font-family: var(--ff-display);
  font-size: 12px;
  font-weight: var(--fw-semibold);
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.badge--dark {
  background: rgba(255,255,255,.1);
  color: var(--color-accent-300);
  backdrop-filter: blur(8px);
}

/* ============ FORM ============ */
.form-field {
  display: block;
  margin-bottom: var(--sp-5);
}
.form-field > label {
  display: block;
  font-size: var(--fs-body-sm);
  font-weight: var(--fw-semibold);
  color: var(--text-strong);
  margin-bottom: var(--sp-2);
}
.form-field > label.required::after {
  content: "*";
  color: var(--color-danger);
  margin-left: 4px;
}

.form-input,
.form-textarea,
.form-select {
  width: 100%;
  padding: 14px 16px;
  font-family: var(--ff-sans);
  font-size: 15px;
  color: var(--text-strong);
  background: #fff;
  border: 1.5px solid var(--border-soft);
  border-radius: var(--radius-sm);
  transition:
    border-color var(--dur-base) var(--ease-out),
    box-shadow var(--dur-base) var(--ease-out);
  appearance: none;
  -webkit-appearance: none;
}
.form-textarea { min-height: 140px; resize: vertical; line-height: 1.6; }

.form-input::placeholder,
.form-textarea::placeholder { color: var(--color-neutral-400); }

.form-input:focus,
.form-textarea:focus,
.form-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(111,168,76,.15);
}

.form-input:invalid:not(:placeholder-shown),
.form-textarea:invalid:not(:placeholder-shown) {
  border-color: var(--color-danger);
}

.form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%236f685d' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 18px center;
  padding-right: 44px;
}

.form-help {
  font-size: var(--fs-caption);
  color: var(--text-muted);
  margin-top: var(--sp-2);
}
.form-error {
  font-size: var(--fs-caption);
  color: var(--color-danger);
  margin-top: var(--sp-2);
  display: none;
}
.form-field.has-error .form-error { display: block; }
.form-field.has-error .form-input,
.form-field.has-error .form-textarea,
.form-field.has-error .form-select { border-color: var(--color-danger); }

.form-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--sp-4);
}
@media (min-width: 641px) {
  .form-row--2 { grid-template-columns: 1fr 1fr; }
  .form-row--3 { grid-template-columns: repeat(3, 1fr); }
}

/* Checkbox / radio (minimal) */
.form-check {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  cursor: pointer;
  font-size: var(--fs-body-sm);
}
.form-check input[type="checkbox"],
.form-check input[type="radio"] { width: 18px; height: 18px; accent-color: var(--accent); }

/* ============ FAB (floating action button, mobile) ============ */
.fab-group {
  position: fixed;
  right: 16px;
  bottom: calc(80px + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  gap: 12px;
  z-index: var(--z-fab);
  pointer-events: none; /* children re-enable */
}
.fab-group.is-visible .fab { pointer-events: auto; }

.fab {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-3);
  transition:
    transform var(--dur-base) var(--ease-out),
    background var(--dur-base) var(--ease-out),
    opacity var(--dur-base) var(--ease-out);
  opacity: 0;
  transform: translateY(12px) scale(.9);
  border: 0;
}
.fab-group.is-visible .fab {
  opacity: 1;
  transform: none;
}
.fab:hover { transform: translateY(-2px); background: var(--brand-ink); }
.fab--accent { background: var(--accent); }
.fab--accent:hover { background: var(--color-accent-700); }
.fab svg { width: 22px; height: 22px; }

@media (min-width: 1025px) {
  .fab-group { display: none; }
}

/* ============ Mobile bottom tab bar ============ */
.mobile-tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  height: calc(64px + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: #fff;
  border-top: 1px solid var(--border-soft);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  z-index: var(--z-tabbar);
  box-shadow: 0 -4px 16px rgba(21,19,15,.04);
}
.mobile-tabbar a {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: 11px;
  font-weight: var(--fw-medium);
  color: var(--text-muted);
  transition: color var(--dur-base) var(--ease-out);
}
.mobile-tabbar a svg { width: 22px; height: 22px; }
.mobile-tabbar a.is-active,
.mobile-tabbar a[aria-current="page"] { color: var(--brand); }

@media (min-width: 1025px) {
  .mobile-tabbar { display: none; }
}

/* Reserve space at bottom of viewport so content isn't covered */
@media (max-width: 1024px) {
  body { padding-bottom: 64px; }
}

/* ============ Image placeholder (for external-copyright slots) ============ */
.img-placeholder {
  position: relative;
  background: var(--bg-card-alt);
  border: 1px dashed var(--border-mid);
  border-radius: var(--radius-md);
  min-height: 240px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp-3);
  color: var(--text-muted);
  overflow: hidden;
}
.img-placeholder::before {
  content: attr(data-monogram);
  font-family: var(--ff-display);
  font-weight: 700;
  font-size: 120px;
  color: rgba(107,68,35,.08);
  line-height: 1;
}
.img-placeholder .ph-caption {
  font-size: var(--fs-caption);
  color: var(--text-muted);
}

/* ============ Back-to-top button ============ */
.to-top {
  position: fixed;
  right: 16px;
  bottom: calc(152px + env(safe-area-inset-bottom, 0px));
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--color-neutral-900);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition:
    opacity var(--dur-base) var(--ease-out),
    transform var(--dur-base) var(--ease-out),
    background var(--dur-base) var(--ease-out);
  z-index: var(--z-fab);
  box-shadow: var(--shadow-2);
}
.to-top.is-visible {
  opacity: 1;
  pointer-events: auto;
  transform: none;
}
.to-top:hover { background: var(--brand); }
.to-top svg { width: 20px; height: 20px; }

@media (min-width: 1025px) {
  .to-top { right: 32px; bottom: 32px; }
}

/* ============ Divider ============ */
.divider {
  display: block;
  height: 1px;
  background: var(--border-soft);
  border: 0;
  margin: var(--sp-6) 0;
}
.divider--accent {
  height: 3px;
  width: 40px;
  background: var(--accent);
  border-radius: var(--radius-pill);
}

/* ============ Lightbox (image full-size modal) ============ */
.lightbox-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(15, 10, 26, 0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4vh 4vw;
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms ease;
}
.lightbox-overlay.is-open {
  opacity: 1;
  pointer-events: auto;
}
.lightbox-figure {
  margin: 0;
  max-width: 100%;
  max-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-3);
}
.lightbox-img {
  display: block;
  max-width: 100%;
  max-height: 88vh;
  width: auto;
  height: auto;
  border-radius: var(--radius-md);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
}
.lightbox-caption {
  color: rgba(255, 255, 255, 0.82);
  font-size: 13px;
  text-align: center;
  max-width: 80ch;
  margin: 0;
}
.lightbox-caption[hidden] { display: none; }
.lightbox-close {
  position: absolute;
  top: max(20px, 2vh);
  right: max(20px, 2vw);
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 180ms ease;
}
.lightbox-close:hover,
.lightbox-close:focus-visible {
  background: rgba(255, 255, 255, 0.24);
  outline: none;
}
