/* Product PDF template setup modal */

.prod-pdf-setup-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1350;
  background: color-mix(in srgb, var(--color-inverse-surface) 50%, transparent);
  backdrop-filter: blur(4px);
  padding: var(--space-md);
}

.prod-pdf-setup-overlay.open {
  display: flex;
  align-items: stretch;
  justify-content: center;
}

body.prod-pdf-setup-open {
  overflow: hidden;
}

.prod-pdf-setup {
  width: 100%;
  max-width: 100%;
  height: 100%;
  max-height: 100%;
  background: var(--color-surface-container-lowest);
  border: 1px solid var(--color-outline-variant);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-overlay);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.prod-pdf-setup__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--color-outline-variant);
  background: var(--color-surface-container-low);
}

.prod-pdf-setup__eyebrow {
  margin: 0 0 var(--space-base);
  color: var(--color-primary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.prod-pdf-setup__header h3 {
  margin: 0 0 var(--space-base);
}

.prod-pdf-setup__subtitle {
  margin: 0;
}

.prod-pdf-setup__close {
  border: none;
  background: transparent;
  border-radius: var(--radius-full);
  width: 2.5rem;
  height: 2.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--color-on-surface-variant);
}

.prod-pdf-setup__close:hover {
  background: var(--color-surface-container-high);
}

.prod-pdf-setup__body {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.prod-pdf-setup__tabs {
  display: flex;
  gap: var(--space-xs);
  padding: var(--space-sm) var(--space-lg);
  border-bottom: 1px solid var(--color-outline-variant);
  background: var(--color-surface-container-low);
  overflow-x: auto;
  flex-shrink: 0;
}

.prod-pdf-setup-tab {
  border: 1px solid var(--color-outline-variant);
  border-radius: var(--radius-full);
  background: var(--color-surface-container-lowest);
  color: var(--color-on-surface-variant);
  padding: var(--space-base) var(--space-sm);
  font-family: var(--font-family-base);
  font-size: var(--font-size-label-md);
  font-weight: var(--font-weight-label-md);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.prod-pdf-setup-tab:hover {
  border-color: color-mix(in srgb, var(--color-primary) 35%, var(--color-outline-variant));
  color: var(--color-primary);
}

.prod-pdf-setup-tab.active {
  border-color: var(--color-primary);
  background: color-mix(in srgb, var(--color-primary) 10%, transparent);
  color: var(--color-primary);
  font-weight: 700;
}

.prod-pdf-setup__workspace {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr;
  min-height: 0;
  overflow: hidden;
}

@media (min-width: 1024px) {
  .prod-pdf-setup__workspace {
    grid-template-columns: minmax(18rem, 24rem) 1fr;
  }
}

.prod-pdf-setup__fields-panel {
  border-bottom: 1px solid var(--color-outline-variant);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

@media (min-width: 1024px) {
  .prod-pdf-setup__fields-panel {
    border-bottom: none;
    border-right: 1px solid var(--color-outline-variant);
  }
}

.prod-pdf-setup__fields-head[hidden] {
  display: none !important;
}

.prod-pdf-setup__fields-head {
  padding: var(--space-md);
  border-bottom: 1px solid var(--color-outline-variant);
}

.prod-pdf-setup__fields-head h4 {
  margin: 0 0 var(--space-base);
}

.prod-pdf-setup__fields-head p {
  margin: 0;
}

.prod-pdf-setup__fields {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-md);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.prod-pdf-setup-field label {
  display: block;
  margin-bottom: var(--space-base);
  font-size: var(--font-size-label-md);
  font-weight: 600;
  color: var(--color-on-surface-variant);
  text-transform: capitalize;
}

.prod-pdf-setup-field textarea,
.prod-pdf-setup-field input[type="text"] {
  width: 100%;
  border: 1px solid var(--color-outline-variant);
  border-radius: var(--radius-lg);
  background: var(--color-surface-container-low);
  padding: var(--space-xs) var(--space-sm);
  font-family: var(--font-family-base);
  font-size: var(--font-size-body-md);
  color: var(--color-on-surface);
  box-sizing: border-box;
}

.prod-pdf-setup-field textarea {
  min-height: 4.5rem;
  resize: vertical;
}

.prod-pdf-setup-field__image-row {
  display: flex;
  gap: var(--space-xs);
  align-items: center;
}

.prod-pdf-setup-field__thumb {
  width: 4rem;
  height: 4rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-outline-variant);
  background: var(--color-surface-container-low);
  background-size: cover;
  background-position: center;
  flex-shrink: 0;
  padding: 0;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.prod-pdf-setup-field__thumb:hover {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--color-primary) 15%, transparent);
}

.prod-pdf-setup__preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid var(--color-outline-variant);
  flex-shrink: 0;
}

.prod-pdf-setup__preview-label {
  margin: 0;
}

.prod-pdf-setup__preview-meta {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.prod-pdf-setup__zoom-label {
  min-width: 3rem;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.prod-pdf-setup__canvas-label {
  margin: 0;
}

.prod-pdf-setup__preview-viewport {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.prod-pdf-setup__preview-wrap {
  flex: 1;
  overflow: auto;
  padding: var(--space-md);
  display: grid;
  place-items: center;
  min-height: 0;
}

.prod-pdf-setup__canvas-host {
  position: relative;
  flex-shrink: 0;
  overflow: hidden;
}

.prod-pdf-setup__canvas-host:has(.prod-pdf-setup__canvas--grow) {
  overflow: visible;
}

.prod-pdf-setup__canvas {
  background: var(--color-surface-container-lowest);
  border: 1px solid var(--color-outline-variant);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  transform-origin: top left;
  overflow: hidden;
  flex-shrink: 0;
}

.prod-pdf-setup__canvas--grow {
  overflow: visible;
}

.prod-pdf-setup__zoom-tools {
  position: absolute;
  right: var(--space-sm);
  bottom: var(--space-sm);
  display: flex;
  flex-direction: column;
  gap: var(--space-base);
  padding: var(--space-xs);
  border-radius: var(--radius-xl);
  background: color-mix(in srgb, var(--color-surface-container-lowest) 85%, transparent);
  backdrop-filter: blur(12px);
  border: 1px solid color-mix(in srgb, var(--color-outline-variant) 50%, transparent);
  box-shadow: var(--shadow-overlay);
  z-index: 2;
}

.prod-pdf-setup__zoom-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  border: none;
  border-radius: var(--radius-xl);
  background: transparent;
  color: var(--color-on-surface-variant);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.prod-pdf-setup__zoom-btn:hover {
  background: var(--color-primary-container);
  color: var(--color-on-primary);
}

.prod-pdf-setup__zoom-btn .material-symbols-outlined {
  font-size: 1.25rem;
}

.prod-pdf-setup__zoom-divider {
  height: 1px;
  margin: 0 var(--space-xs);
  background: color-mix(in srgb, var(--color-outline-variant) 30%, transparent);
}

.prod-pdf-setup__preview-frame {
  display: block;
  width: 100%;
  height: 100%;
  border: none;
  background: var(--color-surface-container-lowest);
}

.prod-pdf-setup__empty-fields {
  text-align: center;
  color: var(--color-on-surface-variant);
  padding: var(--space-xl) var(--space-sm);
  margin: auto;
}

.prod-pdf-setup__preview-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  background: var(--color-surface-container-low);
}

.prod-pdf-setup__footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-xs);
  padding: var(--space-sm) var(--space-lg);
  border-top: 1px solid var(--color-outline-variant);
  background: var(--color-surface-container-low);
}

/* Gallery picker */

.prod-pdf-gallery-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1400;
  background: color-mix(in srgb, var(--color-inverse-surface) 55%, transparent);
  padding: var(--space-md);
  align-items: center;
  justify-content: center;
}

.prod-pdf-gallery-overlay.open {
  display: flex;
}

.prod-pdf-gallery-modal {
  width: min(100%, 48rem);
  max-height: min(88vh, 40rem);
  background: var(--color-surface-container-lowest);
  border: 1px solid var(--color-outline-variant);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-overlay);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.prod-pdf-gallery-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md);
  border-bottom: 1px solid var(--color-outline-variant);
}

.prod-pdf-gallery-modal__header h3 {
  margin: 0;
}

.prod-pdf-gallery-modal__close {
  border: none;
  background: transparent;
  border-radius: var(--radius-full);
  width: 2.5rem;
  height: 2.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--color-on-surface-variant);
}

.prod-pdf-gallery-modal__tabs {
  display: flex;
  gap: var(--space-xs);
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid var(--color-outline-variant);
}

.prod-pdf-gallery-tab {
  border: 1px solid var(--color-outline-variant);
  border-radius: var(--radius-full);
  background: transparent;
  padding: var(--space-base) var(--space-sm);
  font-family: var(--font-family-base);
  font-size: var(--font-size-label-md);
  cursor: pointer;
}

.prod-pdf-gallery-tab.active {
  border-color: var(--color-primary);
  color: var(--color-primary);
  background: color-mix(in srgb, var(--color-primary) 8%, transparent);
  font-weight: 700;
}

.prod-pdf-gallery-modal__body {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-md);
}

.prod-pdf-gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(7rem, 1fr));
  gap: var(--space-sm);
}

.prod-pdf-gallery-item {
  aspect-ratio: 1;
  border: 2px solid var(--color-outline-variant);
  border-radius: var(--radius-lg);
  overflow: hidden;
  cursor: pointer;
  padding: 0;
  background: var(--color-surface-container-low);
}

.prod-pdf-gallery-item:hover {
  border-color: var(--color-primary);
}

.prod-pdf-gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.prod-pdf-gallery-empty {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--color-on-surface-variant);
  padding: var(--space-lg);
}

/* Franchise manager */

.prod-pdf-setup-franchises {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  padding-top: var(--space-sm);
  margin-top: var(--space-sm);
  border-top: 1px solid var(--color-outline-variant);
}

.prod-pdf-setup-franchises__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
}

.prod-pdf-setup-franchises__head h5 {
  margin: 0;
  font-size: var(--font-size-label-lg);
  font-weight: 700;
}

.prod-pdf-setup-franchises__add {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border: 1px solid var(--color-outline-variant);
  border-radius: var(--radius-full);
  background: var(--color-surface-container-lowest);
  color: var(--color-primary);
  cursor: pointer;
}

.prod-pdf-setup-franchises__add:hover {
  border-color: var(--color-primary);
  background: color-mix(in srgb, var(--color-primary) 8%, transparent);
}

.prod-pdf-setup-franchises__add .material-symbols-outlined {
  font-size: 1.25rem;
}

.prod-pdf-setup-franchises__list {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.prod-pdf-setup-franchises__empty {
  margin: 0;
  color: var(--color-on-surface-variant);
  font-size: var(--font-size-label-md);
}

.prod-pdf-setup-franchise-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  padding: var(--space-sm);
  border: 1px solid var(--color-outline-variant);
  border-radius: var(--radius-lg);
  background: var(--color-surface-container-lowest);
}

.prod-pdf-setup-franchise-card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
}

.prod-pdf-setup-franchise-card__label {
  font-size: var(--font-size-label-lg);
  font-weight: 700;
}

.prod-pdf-setup-franchise-item__btn {
  width: 2rem;
  height: 2rem;
  border: none;
  border-radius: var(--radius-full);
  background: transparent;
  color: var(--color-on-surface-variant);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.prod-pdf-setup-franchise-item__btn:hover {
  background: var(--color-surface-container-high);
  color: var(--color-on-surface);
}

.prod-pdf-setup-franchise-item__btn--danger:hover {
  color: var(--color-error);
  background: color-mix(in srgb, var(--color-error) 10%, transparent);
}

@media (max-width: 640px) {
  .prod-pdf-setup-overlay {
    padding: 0;
  }

  .prod-pdf-setup {
    border-radius: 0;
  }

  .prod-pdf-setup__footer {
    flex-direction: column-reverse;
  }

  .prod-pdf-setup__footer .prod-btn-secondary,
  .prod-pdf-setup__footer .prod-btn-primary {
    width: 100%;
    justify-content: center;
  }
}

/* Policy selection (privacy policy tab) */

.prod-pdf-setup-policies {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.prod-pdf-setup-policies__head h5 {
  margin: 0 0 var(--space-base);
}

.prod-pdf-setup-policies__head p {
  margin: 0;
}

.prod-pdf-setup-policies__empty {
  margin: 0;
  color: var(--color-on-surface-variant);
}

.prod-pdf-setup-policy-group {
  border: 1px solid var(--color-outline-variant);
  border-radius: var(--radius-lg);
  background: var(--color-surface-container-low);
  overflow: hidden;
}

.prod-pdf-setup-policy-group__head {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid var(--color-outline-variant);
  background: var(--color-surface-container);
}

.prod-pdf-setup-policy-group__head h5 {
  margin: 0;
  flex: 1;
  font-size: 0.95rem;
}

.prod-pdf-setup-policy-group__toggle {
  border: none;
  background: transparent;
  color: var(--color-primary);
  cursor: pointer;
  padding: 0;
}

.prod-pdf-setup-policy-group__toggle:hover {
  text-decoration: underline;
}

.prod-pdf-setup-policy-group__list {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.prod-pdf-setup-policy-item {
  display: flex;
  align-items: flex-start;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid var(--color-outline-variant);
  cursor: pointer;
}

.prod-pdf-setup-policy-item:last-child {
  border-bottom: none;
}

.prod-pdf-setup-policy-item input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.prod-pdf-setup-policy-item__box {
  width: 1.25rem;
  height: 1.25rem;
  border: 2px solid var(--color-outline);
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 0.15rem;
  color: transparent;
}

.prod-pdf-setup-policy-item__box .material-symbols-outlined {
  font-size: 1rem;
}

.prod-pdf-setup-policy-item input:checked + .prod-pdf-setup-policy-item__box {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: var(--color-on-primary);
}

.prod-pdf-setup-policy-item__body {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
}

.prod-pdf-setup-policy-item__label {
  font-weight: 600;
  color: var(--color-on-surface);
}

.prod-pdf-setup-policy-item__text {
  color: var(--color-on-surface-variant);
  font-size: 0.875rem;
  line-height: 1.45;
}

.prod-pdf-setup-policy-item__sub {
  display: block;
  margin-top: 0.15rem;
  padding-left: 0.75rem;
  border-left: 2px solid var(--color-outline-variant);
}

.prod-pdf-setup-policy-item--intro {
  background: color-mix(in srgb, var(--color-primary) 6%, transparent);
}

.prod-pdf-setup-policy-custom {
  border-top: 1px dashed var(--color-outline-variant);
  padding: var(--space-sm) var(--space-md) var(--space-md);
  background: var(--color-surface-container-lowest);
}

.prod-pdf-setup-policy-custom__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
  margin-bottom: var(--space-sm);
}

.prod-pdf-setup-policy-custom__add {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  border: 1px dashed var(--color-outline);
  background: transparent;
  color: var(--color-primary);
  border-radius: var(--radius-md);
  padding: 0.35rem 0.65rem;
  cursor: pointer;
  font-size: 0.8125rem;
}

.prod-pdf-setup-policy-custom__add:hover {
  background: color-mix(in srgb, var(--color-primary) 8%, transparent);
}

.prod-pdf-setup-policy-custom__list {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.prod-pdf-setup-policy-custom__item {
  display: flex;
  flex-direction: column;
  gap: var(--space-base);
  padding: var(--space-sm);
  border: 1px solid var(--color-outline-variant);
  border-radius: var(--radius-md);
  background: var(--color-surface-container-low);
}

.prod-pdf-setup-policy-custom__item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
}

.prod-pdf-setup-policy-custom__item-label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--color-on-surface-variant);
}

.prod-pdf-setup-policy-custom__remove {
  border: none;
  background: transparent;
  color: var(--color-on-surface-variant);
  cursor: pointer;
  border-radius: var(--radius-full);
  width: 2rem;
  height: 2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.prod-pdf-setup-policy-custom__remove:hover {
  color: var(--color-error);
  background: color-mix(in srgb, var(--color-error) 10%, transparent);
}

.prod-pdf-setup-policy-custom__item textarea {
  width: 100%;
  border: 1px solid var(--color-outline-variant);
  border-radius: var(--radius-md);
  padding: 0.5rem 0.65rem;
  font: inherit;
  resize: vertical;
  background: var(--color-surface-container-lowest);
  color: var(--color-on-surface);
}

.prod-pdf-setup-policy-custom__sub {
  font-size: 0.875rem;
}

.prod-pdf-setup__preview-viewport--policy-scroll {
  overflow: auto;
}

.prod-pdf-setup__canvas--grow {
  height: auto !important;
  min-height: var(--pdf-canvas-height, 842px);
}

.prod-pdf-setup__preview-frame--grow {
  min-height: var(--pdf-canvas-height, 842px);
  height: auto;
}
