/* ===== LAYOUT RAIZ ===== */
html, body {
  height: 100%;
  overflow: hidden;
}

.qr-layout {
  display: flex;
  flex-direction: column;
  height: calc(var(--app-height, 100dvh) - var(--topbar-height, 64px));
  overflow: hidden;
  background: var(--md-sys-color-background);
}

/* ===== PREVIEW ===== */
.qr-preview-panel {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 18px 16px 14px;
  margin: 16px 16px 0;
  background-color: var(--md-sys-color-surface-container-low);
  border: 1px solid color-mix(in srgb, var(--md-sys-color-outline-variant) 62%, transparent);
  border-radius: 28px;
}

.qr-canvas {
  display: flex;
  align-items: center;
  justify-content: center;
  width: min(100%, 232px);
  aspect-ratio: 1 / 1;
  padding: 0;
  border-radius: 0;
  background: transparent;
  border: none;
  overflow: visible;
}

.qr-canvas svg,
.qr-canvas canvas,
.qr-canvas img {
  display: block;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 16px;
}

.qr-preview-label {
  color: var(--md-sys-color-on-surface-variant);
  letter-spacing: 0.04em;
}

/* ===== OPTIONS PANEL ===== */
.qr-options-panel {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background-color: var(--md-sys-color-background);
}

.qr-options-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 14px 16px calc(var(--bottombar-height, 77px) + 28px);
  display: flex;
  flex-direction: column;
  gap: 12px;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.opt-bottom-spacer {
  height: 4px;
  flex-shrink: 0;
}

/* ===== GRUPOS ===== */
.opt-group {
  background-color: var(--md-sys-color-surface-container-low);
  border-radius: 24px;
  border: 1px solid color-mix(in srgb, var(--md-sys-color-outline-variant) 62%, transparent);
  padding: 16px 18px 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.opt-group__title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--md-sys-color-primary);
}

.opt-row {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.opt-row--inline {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.opt-label {
  font-size: 14px;
  color: var(--md-sys-color-on-surface);
  font-weight: 500;
  line-height: 1.35;
  flex-shrink: 0;
}

/* ===== CHIPS ===== */
.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  min-height: 38px;
  border: 1px solid var(--md-sys-color-outline-variant);
  background: transparent;
  color: var(--md-sys-color-on-surface-variant);
  font-family: "Roboto", sans-serif;
  font-size: 13px;
  font-weight: 500;
  padding: 8px 14px;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: background-color 150ms, color 150ms, border-color 150ms, transform 100ms;
  position: relative;
  overflow: hidden;
}

.chip::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--md-sys-color-on-surface);
  opacity: 0;
  transition: opacity 150ms;
  pointer-events: none;
}

.chip:active {
  transform: scale(0.985);
}

.chip:active::after {
  opacity: 0.08;
}

.chip--active {
  background-color: var(--md-sys-color-primary-container);
  border-color: transparent;
  color: var(--md-sys-color-on-secondary-container);
}

/* ===== COLOR PICKER ===== */
.color-pick-wrapper {
  position: relative;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid var(--md-sys-color-outline-variant);
  cursor: pointer;
  flex-shrink: 0;
  box-shadow: inset 0 0 0 4px var(--md-sys-color-surface);
}

.color-input {
  position: absolute;
  inset: -8px;
  width: calc(100% + 16px);
  height: calc(100% + 16px);
  border: none;
  padding: 0;
  cursor: pointer;
  opacity: 0;
  z-index: 2;
}

.color-preview {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  z-index: 1;
  pointer-events: none;
}

/* ===== SLIDER ===== */
.slider-wrapper {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}

.md-slider {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  border-radius: 4px;
  background: var(--md-sys-color-outline-variant);
  outline: none;
  cursor: pointer;
}

.md-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--md-sys-color-primary);
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}

.md-slider::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--md-sys-color-primary);
  border: none;
  cursor: pointer;
}

.slider-value {
  font-size: 13px;
  color: var(--md-sys-color-on-surface-variant);
  min-width: 40px;
  text-align: right;
}

/* ===== UPLOAD ===== */
.upload-btn {
  --md-filled-tonal-button-container-height: 40px;
  --md-filled-tonal-button-container-shape: 16px;
  flex-shrink: 0;
}

/* ===== SAVE BAR ===== */
.qr-save-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 14px 16px 12px;
  border-top: 1px solid var(--md-sys-color-outline-variant);
  background-color: color-mix(in srgb, var(--md-sys-color-background) 94%, transparent);
  backdrop-filter: blur(10px);
  z-index: 10;
}

.save-btn {
  width: 100%;
  --md-filled-button-container-height: 52px;
  --md-filled-button-container-shape: 20px;
}

@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .qr-save-bar {
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
  }

  .qr-options-scroll {
    padding-bottom: calc(var(--bottombar-height, 77px) + 28px + env(safe-area-inset-bottom));
  }
}

/* ===== TOP APP BAR START ===== */
.top-app-bar__start {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ===== DIALOG CUSTOM ===== */
.dialog-scrim {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease;
}

.dialog-scrim.open {
  opacity: 1;
  pointer-events: all;
}

.dialog-container {
  background: var(--md-sys-color-surface-container-high);
  border-radius: 24px;
  padding: 24px;
  width: 100%;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.24);
  transform: scale(0.92);
  transition: transform 200ms cubic-bezier(0.2, 0, 0, 1);
}

.dialog-scrim.open .dialog-container {
  transform: scale(1);
}

.dialog-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--md-sys-color-on-surface);
  margin: 0;
}

.dialog-body {
  font-size: 14px;
  color: var(--md-sys-color-on-surface-variant);
  line-height: 1.5;
  margin: 0;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

/* ===== ECC SLIDER ===== */
.ecc-slider-wrapper {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}

.ecc-slider {
  width: 100%;
}

.ecc-ticks {
  display: flex;
  justify-content: space-between;
  padding: 0 2px;
}

.ecc-tick {
  font-size: 12px;
  font-weight: 600;
  color: var(--md-sys-color-on-surface-variant);
  width: 20px;
  text-align: center;
  transition: color 150ms;
}

.ecc-tick[data-active="true"] {
  color: var(--md-sys-color-primary);
}

.ecc-desc-wrapper {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-top: 2px;
}

.ecc-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background-color: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
  font-size: 14px;
  font-weight: 700;
  flex-shrink: 0;
}

.ecc-desc {
  font-size: 13px;
  color: var(--md-sys-color-on-surface-variant);
  line-height: 1.45;
}

@media (max-width: 420px) {
  .qr-preview-panel {
    margin: 12px 12px 0;
    padding: 16px 14px 12px;
    border-radius: 24px;
  }

  .qr-canvas {
    width: min(100%, 212px);
    padding: 0;
  }

  .qr-options-scroll {
    padding: 12px 12px calc(var(--bottombar-height, 77px) + 24px);
    gap: 10px;
  }

  .opt-group {
    border-radius: 20px;
    padding: 15px 16px 16px;
  }

  .opt-row--inline {
    gap: 10px;
  }
}
