@tailwind base;
@tailwind components;
@tailwind utilities;

@layer components {
  .b3-wvs-ios-search {
    @apply b3-wvs-block b3-wvs-w-full b3-wvs-rounded-full b3-wvs-bg-[#f2f2f7] b3-wvs-border b3-wvs-border-gray-200 b3-wvs-shadow-inner b3-wvs-text-[15px] b3-wvs-leading-5 b3-wvs-text-gray-900 placeholder:b3-wvs-text-gray-500 b3-wvs-transition b3-wvs-backdrop-blur-sm b3-wvs-py-2.5;
    box-shadow:
      inset 0 1px 1px rgba(0, 0, 0, 0.04),
      0 1px 1px rgba(255, 255, 255, 0.6);
  }

  .b3-wvs-ios-search:focus {
    @apply b3-wvs-bg-white b3-wvs-outline-none b3-wvs-ring-2 b3-wvs-ring-admin b3-wvs-border-admin;
    box-shadow:
      0 0 0 1px var(--b3-wvs-admin-color),
      inset 0 1px 1px rgba(0, 0, 0, 0.04),
      0 1px 1px rgba(255, 255, 255, 0.6);
  }
}

/* Scoped resets for admin to avoid fighting WP styles */
#b3-wvs-admin-root {
  @apply b3-wvs-font-sans;
  /* Prefer WP admin theme color; JS will still override via inline style. */
  --b3-wvs-admin-color: var(--wp-admin-theme-color, #46b3e5);
}

#b3-wvs-admin-root * {
  box-sizing: border-box;
}

/* Hide number input spinner arrows in admin number inputs. */
#b3-wvs-admin-root input[type="number"]::-webkit-outer-spin-button,
#b3-wvs-admin-root input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  appearance: none;
  margin: 0;
}

#b3-wvs-admin-root input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}

/* Ensure range sliders match the current WP/admin theme color (instead of browser default purple/blue). */
#b3-wvs-admin-root input[type="range"] {
  accent-color: var(--b3-wvs-admin-color, var(--wp-admin-theme-color, #46b3e5));
}

/* Dynamic admin color utility classes */
.b3-wvs-bg-admin {
  background-color: var(--b3-wvs-admin-color) !important;
}

.b3-wvs-text-admin {
  color: var(--b3-wvs-admin-color) !important;
}

.b3-wvs-border-admin {
  border-color: var(--b3-wvs-admin-color) !important;
}

.b3-wvs-bg-admin-light {
  background-color: color-mix(
    in srgb,
    var(--b3-wvs-admin-color) 10%,
    transparent
  ) !important;
}

.b3-wvs-border-admin-light {
  border-color: color-mix(
    in srgb,
    var(--b3-wvs-admin-color) 30%,
    transparent
  ) !important;
}

.b3-wvs-ring-admin {
  --tw-ring-color: var(--b3-wvs-admin-color) !important;
}

.b3-wvs-choice-grid {
  display: grid;
  gap: 0.75rem;
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

.b3-wvs-choice-grid--layout {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 10rem), 1fr));
}

.b3-wvs-choice-grid--selector {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 14rem), 1fr));
}

.b3-wvs-choice-grid--shape {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 9rem), 1fr));
}

.b3-wvs-choice-grid--compact {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 8.5rem), 1fr));
}

.b3-wvs-choice-grid--medium {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 11rem), 1fr));
}

.b3-wvs-choice-grid--wide {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 12.5rem), 1fr));
}

.b3-wvs-choice-grid > * {
  min-width: 0;
  width: 100%;
}

.b3-wvs-preview-grid {
  display: grid;
  gap: 1rem;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 6.5rem), 1fr));
}

.b3-wvs-preview-grid--wide {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 8.25rem), 1fr));
}

.b3-wvs-preview-grid > * {
  min-width: 0;
}

/* Dynamic grid for Button/Label swatches. */
.b3-wvs-grid-dynamic {
  grid-template-columns: repeat(auto-fit, max-content);
  justify-content: start;
  align-content: start;
  justify-items: start;
}

.b3-wvs-grid-dynamic > * {
  justify-self: start;
  min-width: 0;
}

/*
 * Live Preview: lock swatch layout to be theme-agnostic.
 * Some themes/plugins inject admin CSS (e.g. button { width:100% !important; display:block; })
 * which can break our swatch presentation.
 */
#b3-wvs-admin-root .b3-wvs-admin-preview button[class*="b3-wvs-"],
#b3-wvs-admin-root .b3-wvs-admin-preview [role="button"][class*="b3-wvs-"] {
  display: inline-flex !important;
  box-sizing: border-box;
  max-width: 100%;
}

/* Button/Label swatches should stay content-sized (not forced full-width). */
#b3-wvs-admin-root .b3-wvs-admin-preview button.b3-wvs-min-w-14,
#b3-wvs-admin-root .b3-wvs-admin-preview button.b3-wvs-whitespace-nowrap {
  width: auto !important;
}

/* ScrollSpy-style shell parity classes */
.b3-wvs-settings-header-bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 1rem;
}

.b3-wvs-settings-header-main {
  grid-column: 1;
  min-width: 0;
  flex-wrap: wrap;
}

.b3-wvs-settings-header-actions {
  grid-column: 2;
  min-width: 0;
  justify-self: end;
  justify-content: flex-end;
}

@media (max-width: 960px) {
  .b3-wvs-settings-header-bar {
    grid-template-columns: 1fr;
  }

  .b3-wvs-settings-header-actions {
    grid-column: 1;
    justify-self: start;
  }
}

@media (max-width: 480px) {
  .b3-wvs-settings-header-bar {
    padding-left: 1rem;
    padding-right: 1rem;
    gap: 0.5rem;
  }

  .b3-wvs-settings-header-actions {
    flex-wrap: wrap;
  }
}

.b3-wvs-nav-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.6rem 0.85rem;
  border-radius: 0.625rem;
  border: 1px solid transparent;
  background: transparent;
  font-size: 0.8125rem;
  font-weight: 500;
  color: #475569;
  cursor: pointer;
  /* Leaving active → smooth fade back to dark, no delay */
  transition:
    color 0.3s ease,
    background 0.15s ease;
  text-align: left;
  min-width: 0;
}

.b3-wvs-nav-item > svg {
  transition: color 0.3s ease;
}

#b3-wvs-admin-root .b3-wvs-nav-item > svg {
  width: 1rem !important;
  height: 1rem !important;
  min-width: 1rem;
  min-height: 1rem;
  flex: 0 0 1rem;
}

#b3-wvs-admin-root .b3-wvs-nav-item > span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.b3-wvs-nav-item:hover:not(.is-active) {
  background: #f1f5f9;
  color: #1e293b;
}

/* Animated sliding pill behind the active nav item */
#b3-wvs-admin-root .b3-wvs-nav-slider {
  position: absolute;
  top: 0;
  left: 0;
  border-radius: 0.625rem;
  background-color: var(--b3-wvs-admin-color) !important;
  box-shadow: 0 2px 8px
    color-mix(in srgb, var(--b3-wvs-admin-color) 35%, transparent);
  pointer-events: none;
  z-index: 1;
}

#b3-wvs-admin-root .b3-wvs-nav-item.is-active {
  background: transparent !important;
  color: #ffffff;
  border-color: transparent;
  box-shadow: none;
  /* Entering active → smooth fade to white after slider arrives */
  transition:
    color 0.3s ease 0.1s,
    background 0s;
}

#b3-wvs-admin-root .b3-wvs-nav-item.is-active > svg {
  transition: color 0.3s ease 0.1s;
}

.b3-wvs-action-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.625rem;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  padding: 0.55rem 0.95rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: #334155;
  text-decoration: none;
  transition: all 0.15s ease;
}

.b3-wvs-action-link:hover {
  border-color: #94a3b8;
  background: #f8fafc;
  color: #0f172a;
}

.b3-wvs-action-link.is-primary {
  background: var(--b3-wvs-admin-color);
  border-color: var(--b3-wvs-admin-color);
  color: #ffffff;
}

.b3-wvs-action-link.is-primary:hover {
  filter: brightness(0.96);
}

.b3-wvs-action-link.is-upsell {
  gap: 0.45rem;
  border-color: #f59e0b;
  background: linear-gradient(135deg, #fff7ed 0%, #fffbeb 100%);
  color: #9a3412;
  box-shadow: 0 8px 18px -14px rgba(245, 158, 11, 0.9);
}

.b3-wvs-action-link.is-upsell:hover {
  border-color: #d97706;
  background: linear-gradient(135deg, #ffedd5 0%, #fef3c7 100%);
  color: #7c2d12;
  box-shadow: 0 12px 24px -16px rgba(217, 119, 6, 0.95);
  transform: translateY(-1px);
}

.b3-wvs-shell-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.625rem;
  padding: 0.5rem 1.1rem;
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1.2;
  border: 1px solid transparent;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
  transition: all 0.15s ease;
}

.b3-wvs-shell-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

@media (max-width: 480px) {
  .b3-wvs-shell-btn {
    padding: 0.4rem 0.75rem;
    font-size: 0.75rem;
  }
}

.b3-wvs-shell-btn.is-secondary {
  border-color: #e2e8f0;
  background: #ffffff;
  color: #475569;
}

.b3-wvs-shell-btn.is-secondary:hover:not(:disabled) {
  background: #f8fafc;
  color: #1e293b;
}

.b3-wvs-shell-btn.is-primary {
  border-color: var(--b3-wvs-admin-color);
  background: var(--b3-wvs-admin-color);
  color: #ffffff;
}

.b3-wvs-shell-btn.is-primary:hover:not(:disabled) {
  filter: brightness(0.95);
}

.b3-wvs-step-card {
  border: 1px solid #e2e8f0;
  border-radius: 0.875rem;
  background: #ffffff;
  padding: 1rem;
}

.b3-wvs-step-index {
  display: inline-flex;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 999px;
  align-items: center;
  justify-content: center;
  background: color-mix(in srgb, var(--b3-wvs-admin-color) 12%, #ffffff);
  color: color-mix(in srgb, var(--b3-wvs-admin-color) 85%, #0f172a);
  font-size: 0.75rem;
  font-weight: 700;
}

.b3-wvs-step-title {
  margin-top: 0.65rem;
  font-size: 0.9375rem;
  font-weight: 700;
  color: #0f172a;
}

.b3-wvs-step-copy {
  margin-top: 0.35rem;
  font-size: 0.8125rem;
  line-height: 1.45;
  color: #64748b;
}

.b3-wvs-sub-tabs {
  display: inline-flex;
  position: relative;
  gap: 0.25rem;
  padding: 0.3rem;
  border-radius: 999px;
  background: #e8ecf1;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.b3-wvs-sub-tabs::-webkit-scrollbar {
  display: none;
}

.b3-wvs-sub-tab {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  border: none;
  background: transparent;
  padding: 0.5rem 1.15rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: #50575e;
  border-radius: 999px;
  cursor: pointer;
  transition: color 0.2s ease;
  white-space: nowrap;
}

.b3-wvs-sub-tab:hover {
  color: #1d2327;
}

.b3-wvs-sub-tab.is-active {
  background: transparent;
  color: #ffffff;
}

.b3-wvs-toggle {
  position: relative;
  width: 44px;
  height: 24px;
  border-radius: 999px;
  background: #cbd5e1;
  border: none;
  cursor: pointer;
  transition: background-color 0.2s ease;
  flex-shrink: 0;
  padding: 0;
}

.b3-wvs-toggle.is-checked {
  background-color: var(--b3-wvs-admin-color);
}

.b3-wvs-toggle:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.b3-wvs-toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 999px;
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
  transition: transform 0.2s ease;
  pointer-events: none;
}

.b3-wvs-toggle.is-checked .b3-wvs-toggle-thumb {
  transform: translateX(20px);
}

.b3-wvs-range-wrap {
  position: relative;
  padding: 0.25rem 0;
}

.b3-wvs-range-input {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(
    to right,
    var(--b3-wvs-admin-color) var(--b3-range-pct, 50%),
    #e2e8f0 var(--b3-range-pct, 50%)
  );
  outline: none;
  cursor: pointer;
}

.b3-wvs-range-input::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: #ffffff;
  border: 2px solid var(--b3-wvs-admin-color);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
  cursor: pointer;
}

.b3-wvs-range-input::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: #ffffff;
  border: 2px solid var(--b3-wvs-admin-color);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
  cursor: pointer;
}

.b3-wvs-shell-btn.is-success {
  background: var(--b3-wvs-admin-color);
  border-color: var(--b3-wvs-admin-color);
  color: #ffffff;
}

.b3-wvs-shell-btn.is-success:hover:not(:disabled) {
  filter: brightness(0.95);
}

.b3-wvs-shell-btn.is-destructive {
  background: #ffffff;
  border-color: #e2e8f0;
  color: #64748b;
}

.b3-wvs-shell-btn.is-destructive:hover:not(:disabled) {
  background: #fef2f2;
  border-color: #fecaca;
  color: #dc2626;
}

.is-density-compact .b3-wvs-settings-header-bar {
  gap: 0.75rem;
}

.is-density-compact .b3-wvs-nav-item {
  padding: 0.52rem 0.75rem;
}

.is-density-compact .b3-wvs-shell-btn,
.is-density-compact .b3-wvs-action-link {
  padding: 0.45rem 0.95rem;
}

.is-density-compact .b3-wvs-step-card {
  padding: 0.85rem;
}

.is-density-compact .b3-wvs-sub-tab {
  padding: 0.4rem 1rem;
}

.is-density-compact .b3-wvs-admin-preview {
  padding: 0.85rem;
}

/* Responsive: nav items smaller on small screens */
@media (max-width: 480px) {
  .b3-wvs-nav-item {
    padding: 0.45rem 0.65rem;
    font-size: 0.75rem;
  }

  .b3-wvs-action-link {
    padding: 0.45rem 0.75rem;
    font-size: 0.75rem;
  }

  .b3-wvs-step-card {
    padding: 0.75rem;
  }
}

.b3-wvs-custom-select {
  position: relative;
  width: 100%;
}

.b3-wvs-custom-select-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  width: 100%;
  padding: 0.625rem 0.75rem;
  border: 1px solid #cbd5e1;
  border-radius: 0.5rem;
  background: #ffffff;
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.05);
  color: #0f172a;
  cursor: pointer;
  font: inherit;
  font-size: 0.875rem;
  line-height: 1.25rem;
  text-align: left;
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease;
}

.b3-wvs-custom-select-trigger:hover:not(:disabled) {
  border-color: #94a3b8;
}

.b3-wvs-custom-select-trigger:focus,
.b3-wvs-custom-select-trigger:focus-visible {
  outline: none;
  border-color: var(--b3-wvs-admin-color, #46b3e5);
  box-shadow:
    0 0 0 1px var(--b3-wvs-admin-color, #46b3e5),
    0 1px 2px rgb(0 0 0 / 0.05);
}

.b3-wvs-custom-select-trigger:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.b3-wvs-custom-select-placeholder {
  color: #94a3b8;
}

.b3-wvs-custom-select-chevron {
  width: 1.25rem;
  height: 1.25rem;
  color: #94a3b8;
  flex-shrink: 0;
  transition: transform 0.2s ease;
}

.b3-wvs-custom-select-chevron.is-open {
  transform: rotate(180deg);
}

.b3-wvs-custom-select-menu {
  position: absolute;
  z-index: 50;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: min(15rem, 50vh);
  margin: 0;
  padding: 0.25rem;
  list-style: none;
  overflow: auto;
  border: 1px solid #e2e8f0;
  border-radius: 0.5rem;
  background: #ffffff;
  box-shadow:
    0 4px 6px -1px rgb(0 0 0 / 0.1),
    0 2px 4px -2px rgb(0 0 0 / 0.1);
  animation: b3-wvs-dropdown-in 0.12s ease-out;
}

@keyframes b3-wvs-dropdown-in {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.b3-wvs-custom-select-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.5rem 0.625rem;
  border-radius: 0.375rem;
  color: #334155;
  cursor: pointer;
  font-size: 0.875rem;
  line-height: 1.25rem;
  transition: background-color 0.1s ease;
}

.b3-wvs-custom-select-option.is-focused {
  background-color: #f1f5f9;
}

.b3-wvs-custom-select-option.is-selected {
  color: var(--b3-wvs-admin-color, #46b3e5);
  font-weight: 600;
}

.b3-wvs-custom-select-option.is-selected.is-focused {
  background-color: color-mix(
    in srgb,
    var(--b3-wvs-admin-color, #46b3e5) 8%,
    transparent
  );
}

.b3-wvs-custom-select-check {
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
  color: var(--b3-wvs-admin-color, #46b3e5);
}
