/* ============================================================
   COMPONENTS
   Shared UI vocabulary. Every page uses these classes so
   controls look and behave identically across the app.
   ============================================================ */

/* ------------------------------------------------------------
   BUTTONS
   ------------------------------------------------------------ */
.primary-btn,
.secondary-btn,
.ghost-btn,
.danger-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 11px 20px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  font-size: var(--fs-base);
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  transition: var(--transition-fast);
}

.primary-btn {
  background: var(--brand-gradient);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 8px 20px rgba(106, 90, 249, 0.2);
}

.primary-btn:hover {
  background: var(--brand-gradient);
  border-color: transparent;
  box-shadow: 0 12px 24px rgba(106, 90, 249, 0.28);
  transform: translateY(-1px);
}

.secondary-btn {
  background: rgba(255, 255, 255, 0.7);
  border-color: rgba(124, 111, 191, 0.18);
  color: var(--ink);
  backdrop-filter: blur(12px);
}

.secondary-btn:hover {
  background: rgba(255, 255, 255, 0.92);
  border-color: rgba(106, 90, 249, 0.28);
  box-shadow: 0 8px 18px rgba(35, 28, 80, 0.08);
}

.ghost-btn {
  background: rgba(255, 255, 255, 0.54);
  border-color: rgba(124, 111, 191, 0.12);
  color: var(--muted);
}

.ghost-btn:hover {
  background: var(--surface-alt);
  color: var(--ink);
}

.danger-btn {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}

.danger-btn:hover {
  background: #9e3b33;
  border-color: #9e3b33;
}

.primary-btn:disabled,
.secondary-btn:disabled,
.ghost-btn:disabled,
.danger-btn:disabled,
.icon-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  background: var(--surface-alt);
  border-color: var(--line);
  color: var(--muted);
  box-shadow: none;
}

/* Sizes */
.btn-sm {
  padding: 7px 14px;
  font-size: var(--fs-sm);
}

.btn-lg {
  padding: 14px 26px;
  font-size: var(--fs-md);
}

.btn-block {
  width: 100%;
}

/* ------------------------------------------------------------
   ICON BUTTON
   Square, icon-only. Always give it an aria-label.
   ------------------------------------------------------------ */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: var(--surface-alt);
  color: var(--ink);
  cursor: pointer;
  transition: var(--transition-fast);
}

.icon-btn:hover {
  background: var(--surface-sunken);
  border-color: var(--line);
}

.icon-btn.is-active {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}

/* ------------------------------------------------------------
   CARDS
   ------------------------------------------------------------ */
.card {
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(14px);
}

.card-pad {
  padding: var(--space-5);
}

.card-title {
  font-size: var(--fs-lg);
  font-weight: 600;
  color: var(--ink);
}

.card-body {
  margin-top: var(--space-2);
  color: var(--muted);
  font-size: var(--fs-base);
}

.card-foot {
  margin-top: var(--space-5);
  padding-top: var(--space-4);
  border-top: 1px solid var(--line);
}

.card-interactive {
  cursor: pointer;
  transition: var(--transition);
}

.card-interactive:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow-md);
}

.card-selected {
  border-color: var(--ink);
  box-shadow: 0 0 0 1px var(--ink);
}

/* ------------------------------------------------------------
   TABS
   Usage: [role=tablist] > [role=tab][aria-selected]
   ------------------------------------------------------------ */
.tabs {
  display: flex;
  gap: var(--space-1);
  border-bottom: 1px solid var(--line);
}

.tab {
  padding: 10px 14px;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  background: transparent;
  color: var(--muted);
  font-size: var(--fs-base);
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition-fast);
}

.tab:hover {
  color: var(--ink);
}

.tab[aria-selected='true'] {
  border-bottom-color: var(--ink);
  color: var(--ink);
  font-weight: 600;
}

.tab-panel[hidden] {
  display: none;
}

/* ------------------------------------------------------------
   DROPDOWN / SELECT
   ------------------------------------------------------------ */
.select {
  position: relative;
  display: inline-flex;
}

.select select {
  appearance: none;
  width: 100%;
  padding: 10px 34px 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--ink);
  font-size: var(--fs-base);
  cursor: pointer;
  transition: var(--transition-fast);
}

.select select:hover {
  border-color: var(--muted-light);
}

.select select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--shadow-focus);
}

.select::after {
  content: '';
  position: absolute;
  right: 13px;
  top: 50%;
  width: 6px;
  height: 6px;
  margin-top: -4px;
  border-right: 1.5px solid var(--muted);
  border-bottom: 1.5px solid var(--muted);
  transform: rotate(45deg);
  pointer-events: none;
}

/* Custom menu list */
.dropdown {
  position: relative;
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: var(--z-overlay);
  min-width: 190px;
  padding: var(--space-1);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: var(--transition-fast);
}

.dropdown.open .dropdown-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--ink-light);
  font-size: var(--fs-base);
  text-align: left;
  cursor: pointer;
  transition: var(--transition-fast);
}

.dropdown-item:hover {
  background: var(--surface-alt);
}

.dropdown-item[aria-selected='true'] {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 500;
}

/* ------------------------------------------------------------
   SLIDER
   ------------------------------------------------------------ */
.slider {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.slider input[type='range'] {
  flex: 1;
  height: 4px;
  appearance: none;
  -webkit-appearance: none;
  background: var(--line-strong);
  border-radius: var(--radius-pill);
  cursor: pointer;
}

.slider input[type='range']::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border: none;
  border-radius: 50%;
  background: var(--ink);
  cursor: pointer;
  transition: box-shadow 0.15s var(--ease);
}

.slider input[type='range']::-webkit-slider-thumb:hover {
  box-shadow: 0 0 0 4px var(--accent-ring);
}

.slider input[type='range']::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border: none;
  border-radius: 50%;
  background: var(--ink);
  cursor: pointer;
}

.slider input[type='range']:focus-visible {
  outline: none;
}

.slider input[type='range']:focus-visible::-webkit-slider-thumb {
  box-shadow: var(--shadow-focus);
}

.slider-value {
  min-width: 42px;
  font-size: var(--fs-sm);
  color: var(--muted);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ------------------------------------------------------------
   TOGGLE BUTTONS
   Segmented control for small mutually-exclusive sets.
   ------------------------------------------------------------ */
.toggle-group {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--surface-alt);
}

.toggle-btn {
  padding: 7px 14px;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--muted);
  font-size: var(--fs-sm);
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition-fast);
}

.toggle-btn:hover {
  color: var(--ink);
}

.toggle-btn.active {
  background: var(--ink);
  color: #fff;
  font-weight: 600;
}

/* Switch — binary on/off */
.switch {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  cursor: pointer;
}

.switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.switch-track {
  position: relative;
  width: 40px;
  height: 23px;
  flex: 0 0 auto;
  border-radius: var(--radius-pill);
  background: var(--line-strong);
  transition: var(--transition-fast);
}

.switch-track::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: #fff;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s var(--ease);
}

.switch input:checked + .switch-track {
  background: var(--ink);
}

.switch input:checked + .switch-track::after {
  transform: translateX(17px);
}

.switch input:focus-visible + .switch-track {
  box-shadow: var(--shadow-focus);
}

.switch-label {
  font-size: var(--fs-base);
  color: var(--ink-light);
}

/* ------------------------------------------------------------
   CHIPS / BADGES
   ------------------------------------------------------------ */
.chip {
  padding: 7px 14px;
  min-width: 70px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--muted);
  font-size: var(--fs-sm);
  font-weight: 500;
  text-align: center;
  cursor: pointer;
  transition: background-color 0.18s var(--ease), border-color 0.18s var(--ease),
    color 0.18s var(--ease), transform 0.18s var(--ease);
  transition: var(--transition-fast);
}

.chip:hover {
  border-color: var(--line-strong);
  color: var(--ink);
}

.chip.active {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 2px 10px rgba(23, 23, 23, 0.22);
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: var(--radius-pill);
  background: var(--surface-alt);
  color: var(--muted);
  font-size: var(--fs-xs);
  font-weight: 500;
  white-space: nowrap;
}

/* ------------------------------------------------------------
   MODAL
   ------------------------------------------------------------ */
.modal {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: grid;
  place-items: center;
  padding: var(--space-5);
  background: rgba(23, 23, 23, 0.45);
  opacity: 0;
  visibility: hidden;
  transition: var(--transition);
}

.modal.open {
  opacity: 1;
  visibility: visible;
}

.modal-panel {
  width: 100%;
  max-width: 460px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  transform: translateY(8px);
  transition: transform 0.2s var(--ease);
}

.modal.open .modal-panel {
  transform: translateY(0);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-5) var(--space-5) var(--space-3);
}

.modal-title {
  font-size: var(--fs-lg);
  font-weight: 600;
  color: var(--ink);
}

.modal-body {
  padding: 0 var(--space-5) var(--space-5);
  color: var(--muted);
  font-size: var(--fs-base);
  line-height: 1.7;
}

.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--line);
  background: var(--surface-alt);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* Confirmation dialog reuses the modal shell */
.confirm-icon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  border-radius: var(--radius-md);
  background: var(--accent-soft);
  color: var(--accent);
}

.confirm-icon.is-danger {
  background: var(--danger-soft);
  color: var(--danger);
}

/* ------------------------------------------------------------
   TOAST
   ------------------------------------------------------------ */
#toast,
.toast {
  position: fixed;
  right: var(--space-5);
  bottom: var(--space-5);
  z-index: var(--z-toast);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  max-width: 340px;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--ink);
  color: #fff;
  font-size: var(--fs-base);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  transition: var(--transition);
}

#toast.visible,
.toast.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.toast-icon {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
}

.toast-success {
  border-color: var(--success);
}

.toast-error {
  border-color: var(--danger);
}

/* ------------------------------------------------------------
   LOADING STATE
   ------------------------------------------------------------ */
.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--line-strong);
  border-top-color: var(--ink);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

.loading-inline {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  color: var(--muted);
  font-size: var(--fs-base);
}

.loading-block {
  display: grid;
  place-items: center;
  gap: var(--space-3);
  padding: var(--space-7) var(--space-5);
  color: var(--muted);
}

.skeleton {
  background: var(--surface-sunken);
  border-radius: var(--radius-sm);
  animation: skeleton-pulse 1.4s ease-in-out infinite;
}

@keyframes skeleton-pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

@media (prefers-reduced-motion: reduce) {
  .spinner,
  .skeleton {
    animation: none;
  }
}

/* ------------------------------------------------------------
   EMPTY STATE
   ------------------------------------------------------------ */
.empty-state {
  display: grid;
  place-items: center;
  gap: var(--space-3);
  padding: var(--space-7) var(--space-5);
  text-align: center;
}

.empty-state-icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  background: var(--surface-alt);
  color: var(--muted-light);
}

.empty-state-title {
  font-size: var(--fs-md);
  font-weight: 600;
  color: var(--ink);
}

.empty-state-text {
  max-width: 360px;
  color: var(--muted);
  font-size: var(--fs-sm);
  line-height: 1.6;
}

/* ------------------------------------------------------------
   ERROR STATE
   ------------------------------------------------------------ */
.error-state {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-4);
  border: 1px solid #f0d5d2;
  border-radius: var(--radius-md);
  background: var(--danger-soft);
}

.error-state-icon {
  flex: 0 0 auto;
  color: var(--danger);
}

.error-state-title {
  font-size: var(--fs-base);
  font-weight: 600;
  color: var(--danger);
}

.error-state-text {
  margin-top: 2px;
  color: var(--muted);
  font-size: var(--fs-sm);
  line-height: 1.6;
}

/* ------------------------------------------------------------
   NOTICE (informational, used for the local-QR caveat)
   ------------------------------------------------------------ */
.notice {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-alt);
}

.notice-icon {
  flex: 0 0 auto;
  color: var(--muted);
}

.notice-text {
  color: var(--muted);
  font-size: var(--fs-sm);
  line-height: 1.6;
}

.notice-text strong {
  color: var(--ink);
  font-weight: 600;
}

/* ------------------------------------------------------------
   DIVIDER
   ------------------------------------------------------------ */
.divider {
  height: 1px;
  border: 0;
  background: var(--line);
  margin: var(--space-5) 0;
}

/* ------------------------------------------------------------
   SHARED STRIP + CATEGORY PRIMITIVES

   Used by the landing page, the template studio and the camera
   studio, so they live here rather than in any one page sheet.
   Every strip thumbnail is a real render from photostrip.js.
   ------------------------------------------------------------ */

.strip-thumb {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: fill;
  border-radius: 2px;
  opacity: 0;
  transition: opacity var(--dur-base) var(--ease);
}

.category-row {
  display: flex;
  align-items: stretch;
  gap: var(--space-1);
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  -webkit-overflow-scrolling: touch;
}

.category-row::-webkit-scrollbar {
  display: none;
}

.category-tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  flex: 0 0 auto;
  padding: 13px 16px 14px;
  border: 0;
  background: none;
  color: var(--muted);
  font-family: inherit;
  font-size: var(--fs-sm);
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: color var(--dur-fast) var(--ease);
}

.category-tab::after {
  content: '';
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: -1px;
  height: 2px;
  background: var(--ink);
  transform: scaleX(0);
  transition: transform var(--dur-base) var(--ease-print);
}

.category-tab:hover {
  color: var(--ink);
}

.category-tab.is-active {
  color: var(--ink);
  font-weight: 600;
}

.category-tab.is-active::after {
  transform: scaleX(1);
}

.category-count {
  display: grid;
  place-items: center;
  min-width: 20px;
  height: 18px;
  padding: 0 5px;
  border-radius: var(--radius-pill);
  background: var(--surface-sunken);
  color: var(--muted-light);
  font-size: 0.625rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  transition: background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}

.category-tab.is-active .category-count {
  background: var(--ink);
  color: #fff;
}
