/**
 * YLÄUXI Premium Component System
 * Brand palette only: #FAFAF8 (cream) · #B89A6A (gold) · #0A0A0A (dark)
 * Builds on ylux.css tokens — load after ylux.css and ylux-motion.css
 */

/* ─────────────────────────────────────────────
   1. BUTTON STATES — hover / active / loading / disabled
   ───────────────────────────────────────────── */

@keyframes ylux-spin {
  to { transform: rotate(360deg); }
}

/* Base button resets to build every state from */
.btn, .btn-blk, .btn-out, .btn-sm {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  cursor: pointer;
  border-radius: var(--ylux-radius);
  transition:
    background 0.18s var(--ylux-ease),
    border-color 0.18s var(--ylux-ease),
    color 0.18s var(--ylux-ease),
    box-shadow 0.18s var(--ylux-ease),
    transform 0.1s var(--ylux-ease),
    opacity 0.18s;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* Press state — physical feedback */
.btn:active:not(:disabled):not([data-loading]),
.btn-blk:active:not(:disabled):not([data-loading]),
.btn-out:active:not(:disabled):not([data-loading]),
.btn-sm:active:not(:disabled):not([data-loading]) {
  transform: scale(0.975);
}

/* Primary (black) button */
.btn-blk {
  background: var(--ylux-cta);
  color: var(--ylux-bg);
  border: 0.5px solid var(--ylux-cta);
}
.btn-blk:hover:not(:disabled):not([data-loading]) {
  background: var(--ylux-accent);
  border-color: var(--ylux-accent);
  color: var(--ylux-bg2);
  box-shadow: 0 4px 18px rgba(184, 154, 106, 0.22);
}

/* Outline button */
.btn-out {
  background: transparent;
  color: var(--ylux-text);
  border: 0.5px solid var(--ylux-border-s);
}
.btn-out:hover:not(:disabled):not([data-loading]) {
  border-color: var(--ylux-accent);
  color: var(--ylux-accent);
}

/* Gold accent button */
.btn-gold {
  background: var(--ylux-accent);
  color: var(--ylux-bg2);
  border: 0.5px solid var(--ylux-accent);
  font-family: var(--ylux-font-display);
  letter-spacing: 0.14em;
  font-size: 0.62rem;
  text-transform: uppercase;
  padding: 9px 18px;
  border-radius: var(--ylux-radius);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  transition:
    background 0.18s var(--ylux-ease),
    box-shadow 0.18s var(--ylux-ease),
    transform 0.1s;
}
.btn-gold:hover:not(:disabled):not([data-loading]) {
  background: var(--ylux-accent-d);
  border-color: var(--ylux-accent-d);
  box-shadow: 0 4px 18px rgba(184, 154, 106, 0.28);
}
.btn-gold:active:not(:disabled):not([data-loading]) {
  transform: scale(0.975);
}

/* Loading state */
.btn[data-loading],
.btn-blk[data-loading],
.btn-out[data-loading],
.btn-gold[data-loading],
.btn-sm[data-loading] {
  pointer-events: none;
  opacity: 0.7;
}
.btn[data-loading]::after,
.btn-blk[data-loading]::after,
.btn-out[data-loading]::after,
.btn-gold[data-loading]::after,
.btn-sm[data-loading]::after {
  content: '';
  width: 11px;
  height: 11px;
  border: 1.5px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: ylux-spin 0.7s linear infinite;
  margin-left: 4px;
}

/* Disabled state */
.btn:disabled,
.btn-blk:disabled,
.btn-out:disabled,
.btn-gold:disabled,
.btn-sm:disabled {
  opacity: 0.38;
  cursor: not-allowed;
  pointer-events: none;
}


/* ─────────────────────────────────────────────
   2. FORM VALIDATION — real-time inline feedback
   ───────────────────────────────────────────── */

.fi-wrap {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

/* Valid state */
.fi.is-valid {
  border-color: var(--ylux-accent) !important;
}
.fi.is-valid + .fi-msg { display: block; color: var(--ylux-accent); }

/* Invalid state */
.fi.is-invalid {
  border-color: var(--ylux-text) !important;
  box-shadow: 0 0 0 3px rgba(10, 10, 10, 0.06);
}
.fi.is-invalid + .fi-msg { display: block; color: var(--ylux-text-s); }

/* Subtle focus glow — already on focus, now consistent */
.fi:focus {
  border-color: var(--ylux-accent) !important;
  box-shadow: 0 0 0 3px var(--ylux-accent-f);
  outline: none;
}

/* Validation message */
.fi-msg {
  display: none;
  font-family: var(--ylux-font-display);
  font-size: 0.58rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

/* Field label */
.fi-label {
  font-family: var(--ylux-font-display);
  font-size: 0.6rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ylux-text-m);
  margin-bottom: 5px;
  display: block;
}

/* Required marker */
.fi-label .req {
  color: var(--ylux-accent);
  margin-left: 3px;
}

/* Character counter */
.fi-counter {
  font-family: var(--ylux-font-display);
  font-size: 0.55rem;
  letter-spacing: 0.1em;
  color: var(--ylux-text-m);
  text-align: right;
  margin-top: 3px;
}
.fi-counter.near-limit { color: var(--ylux-accent); }
.fi-counter.at-limit { color: var(--ylux-text); font-weight: 500; }


/* ─────────────────────────────────────────────
   3. PREMIUM CARDS — elevation + hover depth
   ───────────────────────────────────────────── */

.card-premium {
  background: var(--ylux-bg2);
  border: 0.5px solid var(--ylux-border);
  border-radius: var(--ylux-radius);
  padding: 24px;
  position: relative;
  overflow: hidden;
  transition:
    border-color 0.2s var(--ylux-ease),
    box-shadow 0.2s var(--ylux-ease),
    transform 0.2s var(--ylux-ease);
}
.card-premium:hover {
  border-color: var(--ylux-accent);
  box-shadow: 0 12px 40px rgba(10, 10, 10, 0.08), 0 2px 8px rgba(184, 154, 106, 0.08);
  transform: translateY(-1px);
}

/* Gold accent line on top */
.card-premium::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: var(--ylux-accent);
  opacity: 0;
  transition: opacity 0.2s var(--ylux-ease);
}
.card-premium:hover::before { opacity: 1; }

/* Card with left border accent variant */
.card-accent {
  background: var(--ylux-bg2);
  border: 0.5px solid var(--ylux-border);
  border-left: 2px solid var(--ylux-accent);
  border-radius: var(--ylux-radius);
  padding: 18px 20px;
  transition: box-shadow 0.2s var(--ylux-ease), transform 0.2s var(--ylux-ease);
}
.card-accent:hover {
  box-shadow: var(--ylux-shadow);
  transform: translateX(2px);
}

/* KPI card — number-forward */
.kpi-premium {
  background: var(--ylux-bg2);
  border: 0.5px solid var(--ylux-border);
  border-radius: var(--ylux-radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s var(--ylux-ease);
}
.kpi-premium:hover {
  border-color: var(--ylux-accent);
  box-shadow: 0 8px 28px rgba(10, 10, 10, 0.06);
  transform: translateY(-1px);
}
.kpi-premium .kpi-label {
  font-family: var(--ylux-font-display);
  font-size: 0.58rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ylux-text-m);
}
.kpi-premium .kpi-number {
  font-family: var(--ylux-font-editorial);
  font-size: 2rem;
  font-weight: 400;
  letter-spacing: 0.04em;
  color: var(--ylux-text);
  line-height: 1;
}
.kpi-premium .kpi-trend {
  font-family: var(--ylux-font-display);
  font-size: 0.58rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ylux-accent);
  display: flex;
  align-items: center;
  gap: 4px;
}
.kpi-premium .kpi-trend.down { color: var(--ylux-text-s); }

/* Sparkline container */
.kpi-sparkline {
  width: 100%;
  height: 28px;
  margin-top: 4px;
  opacity: 0.7;
}


/* ─────────────────────────────────────────────
   4. EMPTY STATES
   ───────────────────────────────────────────── */

.ylux-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 64px 32px;
  text-align: center;
  border: 0.5px dashed var(--ylux-border-s);
  border-radius: var(--ylux-radius);
  background: var(--ylux-faint);
}

.ylux-empty-mark {
  font-family: var(--ylux-font-editorial);
  font-size: 2.2rem;
  letter-spacing: 0.08em;
  color: var(--ylux-accent);
  opacity: 0.25;
  line-height: 1;
  margin-bottom: 16px;
  user-select: none;
}

.ylux-empty-title {
  font-family: var(--ylux-font-display);
  font-size: 0.65rem;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--ylux-text);
  margin-bottom: 6px;
}

.ylux-empty-sub {
  font-family: var(--ylux-font-display);
  font-size: 0.6rem;
  letter-spacing: 0.12em;
  color: var(--ylux-text-m);
  max-width: 260px;
  line-height: 1.7;
}


/* ─────────────────────────────────────────────
   5. ERROR STATES
   ───────────────────────────────────────────── */

/* Inline error banner */
.ylux-error {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  background: var(--ylux-faint);
  border: 0.5px solid var(--ylux-border-s);
  border-left: 2px solid var(--ylux-text);
  border-radius: var(--ylux-radius);
  animation: ylux-fade-up 0.22s var(--ylux-ease) both;
}

.ylux-error-icon {
  flex-shrink: 0;
  width: 14px;
  height: 14px;
  opacity: 0.6;
  margin-top: 1px;
}

.ylux-error-body {
  flex: 1;
}

.ylux-error-title {
  font-family: var(--ylux-font-display);
  font-size: 0.6rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ylux-text);
  margin-bottom: 3px;
}

.ylux-error-msg {
  font-family: var(--ylux-font-display);
  font-size: 0.6rem;
  letter-spacing: 0.1em;
  color: var(--ylux-text-s);
  line-height: 1.6;
}

/* Full-panel error state */
.ylux-error-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 56px 32px;
  text-align: center;
  gap: 12px;
}
.ylux-error-panel .ylux-error-code {
  font-family: var(--ylux-font-editorial);
  font-size: 3rem;
  color: var(--ylux-accent);
  opacity: 0.2;
  letter-spacing: 0.08em;
  line-height: 1;
}
.ylux-error-panel .ylux-error-title {
  font-size: 0.62rem;
  letter-spacing: 0.22em;
}
.ylux-error-panel .ylux-error-msg {
  max-width: 260px;
}


/* ─────────────────────────────────────────────
   6. TOAST NOTIFICATIONS — enhanced
   ───────────────────────────────────────────── */

/* Override/extend existing #ylux-toast */
#ylux-toast {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-width: 280px;
}

#ylux-toast .toast-icon {
  flex-shrink: 0;
  width: 13px;
  height: 13px;
  margin-top: 1px;
  opacity: 0.7;
}

#ylux-toast .toast-body { flex: 1; }

#ylux-toast .toast-title {
  font-size: 0.62rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ylux-text);
  margin-bottom: 2px;
}

#ylux-toast .toast-sub {
  font-size: 0.58rem;
  letter-spacing: 0.1em;
  color: var(--ylux-text-s);
  line-height: 1.5;
}

#ylux-toast .toast-close {
  flex-shrink: 0;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  opacity: 0.4;
  font-size: 14px;
  line-height: 1;
  color: var(--ylux-text);
  transition: opacity 0.15s;
  margin-top: -2px;
}
#ylux-toast .toast-close:hover { opacity: 0.8; }

/* Toast type variants */
#ylux-toast.ok { border-left: 2px solid var(--ylux-accent); }
#ylux-toast.err { border-left: 2px solid var(--ylux-text); }
#ylux-toast.info { border-left: 2px solid var(--ylux-text-m); }

/* Toast stack — for multiple concurrent toasts */
#ylux-toast-stack {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 9100;
  display: flex;
  flex-direction: column-reverse;
  gap: 8px;
  pointer-events: none;
}

.ylux-toast-item {
  background: var(--ylux-bg2);
  border: 0.5px solid var(--ylux-border-s);
  padding: 13px 18px 13px 14px;
  font-family: var(--ylux-font-display);
  font-size: 0.6rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ylux-text);
  box-shadow: 0 8px 32px rgba(10, 10, 10, 0.1);
  max-width: 340px;
  min-width: 220px;
  pointer-events: all;
  opacity: 0;
  transform: translateY(8px) translateX(4px);
  transition: opacity 0.26s var(--ylux-ease), transform 0.26s var(--ylux-ease);
  display: flex;
  align-items: flex-start;
  gap: 10px;
  border-radius: var(--ylux-radius);
}
.ylux-toast-item.show {
  opacity: 1;
  transform: none;
}
.ylux-toast-item.hiding {
  opacity: 0;
  transform: translateX(8px);
}
.ylux-toast-item.ok { border-left: 2px solid var(--ylux-accent); }
.ylux-toast-item.err { border-left: 2px solid var(--ylux-text); }
.ylux-toast-item.info { border-left: 2px solid var(--ylux-text-m); }

.ylux-toast-item .ti-body { flex: 1; }
.ylux-toast-item .ti-title {
  color: var(--ylux-text);
  margin-bottom: 1px;
}
.ylux-toast-item .ti-sub {
  color: var(--ylux-text-s);
  letter-spacing: 0.08em;
  line-height: 1.5;
  margin-top: 2px;
  text-transform: none;
  font-size: 0.57rem;
}
.ylux-toast-item .ti-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--ylux-text-m);
  font-size: 13px;
  line-height: 1;
  padding: 0;
  flex-shrink: 0;
  transition: color 0.15s;
}
.ylux-toast-item .ti-close:hover { color: var(--ylux-text); }


/* ─────────────────────────────────────────────
   7. STATUS BADGES
   ───────────────────────────────────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: var(--ylux-font-display);
  font-size: 0.55rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: var(--ylux-radius);
  font-weight: 400;
  white-space: nowrap;
}

/* Dot indicator */
.badge::before {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* Active / Live / Success → gold */
.badge-active,
.badge-live,
.badge-success,
.badge-paid,
.badge-published {
  background: var(--ylux-accent-f);
  color: var(--ylux-accent-d);
  border: 0.5px solid rgba(184, 154, 106, 0.22);
}
.badge-active::before,
.badge-live::before,
.badge-success::before,
.badge-paid::before,
.badge-published::before {
  background: var(--ylux-accent);
}

/* Live badge gets a pulse */
.badge-live::before {
  animation: ylux-badge-pulse 2s ease infinite;
}
@keyframes ylux-badge-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(184, 154, 106, 0.5); }
  50% { box-shadow: 0 0 0 4px rgba(184, 154, 106, 0); }
}

/* Pending / Draft / Scheduled → cream with dark border */
.badge-pending,
.badge-draft,
.badge-scheduled,
.badge-review {
  background: var(--ylux-bg-subtle);
  color: var(--ylux-text-s);
  border: 0.5px solid var(--ylux-border-s);
}
.badge-pending::before,
.badge-draft::before,
.badge-scheduled::before,
.badge-review::before {
  background: var(--ylux-text-m);
}

/* Inactive / Archived → muted */
.badge-inactive,
.badge-archived,
.badge-cancelled {
  background: var(--ylux-faint);
  color: var(--ylux-text-m);
  border: 0.5px solid var(--ylux-border);
}
.badge-inactive::before,
.badge-archived::before,
.badge-cancelled::before {
  background: var(--ylux-text-m);
  opacity: 0.4;
}

/* Error / Overdue / Failed → dark (no red) */
.badge-error,
.badge-overdue,
.badge-failed,
.badge-urgent {
  background: rgba(10, 10, 10, 0.06);
  color: var(--ylux-text);
  border: 0.5px solid rgba(10, 10, 10, 0.18);
}
.badge-error::before,
.badge-overdue::before,
.badge-failed::before,
.badge-urgent::before {
  background: var(--ylux-text);
}

/* No dot variant */
.badge.no-dot::before { display: none; }


/* ─────────────────────────────────────────────
   8. PREMIUM TABLES
   ───────────────────────────────────────────── */

.tbl-premium {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--ylux-font-display);
}

.tbl-premium thead th {
  font-size: 0.56rem;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--ylux-text-m);
  font-weight: 400;
  padding: 0 14px 10px;
  text-align: left;
  border-bottom: 0.5px solid var(--ylux-border-s);
  white-space: nowrap;
}

.tbl-premium thead th:first-child { padding-left: 0; }
.tbl-premium thead th:last-child { text-align: right; padding-right: 0; }

.tbl-premium tbody tr {
  border-bottom: 0.5px solid var(--ylux-border);
  transition: background 0.14s, transform 0.14s var(--ylux-ease);
  cursor: default;
}

.tbl-premium tbody tr:last-child { border-bottom: none; }

.tbl-premium tbody tr:hover {
  background: var(--ylux-accent-f);
}

/* Row with left reveal on hover */
.tbl-premium tbody tr {
  position: relative;
}
.tbl-premium tbody tr::before {
  content: '';
  position: absolute;
  left: -1px;
  top: 0; bottom: 0;
  width: 2px;
  background: var(--ylux-accent);
  opacity: 0;
  transition: opacity 0.14s;
}
.tbl-premium tbody tr:hover::before { opacity: 1; }

.tbl-premium tbody td {
  padding: 13px 14px;
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  color: var(--ylux-text);
  vertical-align: middle;
}

.tbl-premium tbody td:first-child { padding-left: 0; }
.tbl-premium tbody td:last-child { text-align: right; padding-right: 0; }

/* Primary cell — Bodoni */
.tbl-premium .td-primary {
  font-family: var(--ylux-font-editorial);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
}

/* Secondary / muted cell */
.tbl-premium .td-muted {
  color: var(--ylux-text-m);
  font-size: 0.58rem;
  letter-spacing: 0.1em;
}

/* Number cell */
.tbl-premium .td-num {
  font-family: var(--ylux-font-editorial);
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-align: right;
}

/* Clickable row */
.tbl-premium tbody tr.clickable { cursor: pointer; }
.tbl-premium tbody tr.clickable:hover .td-primary {
  color: var(--ylux-accent);
}

/* Row actions — appear on hover */
.tbl-premium .td-actions {
  opacity: 0;
  transition: opacity 0.14s;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}
.tbl-premium tbody tr:hover .td-actions { opacity: 1; }

/* Table action button */
.tbl-action {
  background: none;
  border: 0.5px solid var(--ylux-border-s);
  padding: 4px 10px;
  font-family: var(--ylux-font-display);
  font-size: 0.55rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ylux-text-s);
  cursor: pointer;
  border-radius: var(--ylux-radius);
  transition: border-color 0.14s, color 0.14s;
}
.tbl-action:hover {
  border-color: var(--ylux-accent);
  color: var(--ylux-accent);
}


/* ─────────────────────────────────────────────
   MODAL — enter/exit animations
   ───────────────────────────────────────────── */

@keyframes ylux-modal-in {
  from { opacity: 0; transform: translateY(10px) scale(0.99); }
  to   { opacity: 1; transform: none; }
}
@keyframes ylux-modal-out {
  from { opacity: 1; transform: none; }
  to   { opacity: 0; transform: translateY(6px) scale(0.99); }
}
@keyframes ylux-overlay-in {
  from { opacity: 0; backdrop-filter: blur(0px); }
  to   { opacity: 1; backdrop-filter: blur(2px); }
}

.ylux-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 9, 8, 0.5);
  z-index: 8000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: ylux-overlay-in 0.22s var(--ylux-ease) both;
  backdrop-filter: blur(2px);
}

.ylux-modal-overlay.closing {
  animation: ylux-fade-in 0.18s var(--ylux-ease) reverse both;
}

.ylux-modal {
  background: var(--ylux-bg2);
  border: 0.5px solid var(--ylux-border-s);
  border-radius: var(--ylux-radius);
  padding: 32px;
  width: 100%;
  max-width: 520px;
  box-shadow: 0 32px 80px rgba(10, 10, 10, 0.16);
  animation: ylux-modal-in 0.26s var(--ylux-ease) both;
  position: relative;
}

.ylux-modal.closing {
  animation: ylux-modal-out 0.18s var(--ylux-ease) both;
}

.ylux-modal-sm { max-width: 380px; }
.ylux-modal-lg { max-width: 720px; }

.ylux-modal-hdr {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 0.5px solid var(--ylux-border);
}

.ylux-modal-title {
  font-family: var(--ylux-font-display);
  font-size: 0.65rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ylux-text);
}

.ylux-modal-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--ylux-text-m);
  font-size: 18px;
  line-height: 1;
  padding: 0;
  transition: color 0.15s;
  margin-top: -2px;
}
.ylux-modal-close:hover { color: var(--ylux-text); }


/* ─────────────────────────────────────────────
   SIDEBAR NAV — smooth active transition
   ───────────────────────────────────────────── */

.ni {
  transition: background 0.15s var(--ylux-ease), color 0.15s;
}


/* ─────────────────────────────────────────────
   LIVE DOT — pulsing indicator
   ───────────────────────────────────────────── */

.ylux-live-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ylux-accent);
  animation: ylux-badge-pulse 2.4s ease infinite;
  flex-shrink: 0;
}


/* ─────────────────────────────────────────────
   REDUCED MOTION
   ───────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  .btn, .btn-blk, .btn-out, .btn-gold, .btn-sm,
  .card-premium, .kpi-premium, .card-accent,
  .tbl-premium tbody tr,
  .ylux-modal, .ylux-modal-overlay,
  .ylux-toast-item,
  .ylux-live-dot,
  .badge-live::before {
    transition: none !important;
    animation: none !important;
  }
}
