@import url('tool-shared.css');

#ai-label-tool {
  max-width: 1240px;
}

.label-workspace {
  gap: 1.75rem;
  overflow: hidden;
}

.workspace-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.workspace-heading h2,
.export-panel h3 {
  margin: 0;
}

.section-kicker {
  margin: 0 0 0.3rem;
  color: var(--accent);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.label-editor-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(360px, 0.8fr);
  gap: 1.5rem;
  align-items: start;
}

.preview-column {
  min-width: 0;
  display: grid;
  gap: 1rem;
  position: sticky;
  top: 1.5rem;
}

.image-stage {
  position: relative;
  min-height: 580px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px dashed rgba(255, 255, 255, 0.16);
  border-radius: 22px;
  background:
    linear-gradient(45deg, rgba(255, 255, 255, 0.025) 25%, transparent 25%, transparent 75%, rgba(255, 255, 255, 0.025) 75%),
    linear-gradient(45deg, rgba(255, 255, 255, 0.025) 25%, transparent 25%, transparent 75%, rgba(255, 255, 255, 0.025) 75%),
    #090a0f;
  background-position: 0 0, 14px 14px;
  background-size: 28px 28px;
  cursor: pointer;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.image-stage:hover,
.image-stage:focus-visible,
.image-stage.is-dragover {
  border-color: rgba(0, 207, 213, 0.65);
  box-shadow: inset 0 0 0 1px rgba(0, 207, 213, 0.16), 0 22px 55px rgba(0, 0, 0, 0.24);
}

.image-stage:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.image-stage.is-dragover {
  transform: translateY(-2px);
  background-color: rgba(0, 207, 213, 0.06);
}

.empty-preview {
  width: min(100%, 420px);
  min-height: 520px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 1.25rem;
  padding: 2rem;
  text-align: center;
}

.empty-preview[hidden] {
  display: none;
}

.empty-art {
  width: 152px;
  height: 116px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(0, 207, 213, 0.16);
  border-radius: 32px;
  background: linear-gradient(145deg, rgba(0, 207, 213, 0.12), rgba(123, 97, 255, 0.08));
  color: var(--accent);
  transform: rotate(-2deg);
}

.empty-art svg {
  width: 116px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.empty-art .spark {
  stroke: #a596ff;
}

.empty-title {
  margin: 0 0 0.35rem;
  font-size: 1.15rem;
  font-weight: 700;
}

.empty-copy {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.label-preview {
  display: none;
  width: 100%;
  height: auto;
  max-height: 690px;
  object-fit: contain;
  box-shadow: 0 26px 70px rgba(0, 0, 0, 0.35);
}

.label-preview.is-visible {
  display: block;
}

.stage-loading {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.8rem;
  background: rgba(7, 7, 10, 0.78);
  color: var(--text-main);
  font-weight: 600;
  backdrop-filter: blur(8px);
}

.stage-loading[hidden] {
  display: none;
}

.loading-spinner {
  width: 1.3rem;
  height: 1.3rem;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: label-spin 0.7s linear infinite;
}

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

.visually-hidden-input {
  display: none;
}

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.preview-status {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) repeat(2, minmax(100px, 0.7fr));
  gap: 0.65rem;
}

.batch-panel {
  display: grid;
  gap: 0.75rem;
  padding: 0.9rem;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.025);
}

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

.batch-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.batch-heading strong,
.batch-heading span {
  display: block;
}

.batch-heading strong {
  font-size: 0.84rem;
}

.batch-heading > div > span {
  margin-top: 0.15rem;
  color: var(--text-muted);
  font-size: 0.72rem;
}

.batch-count {
  flex: 0 0 auto;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 700;
}

.batch-list {
  display: flex;
  gap: 0.55rem;
  padding-bottom: 0.2rem;
  overflow-x: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 207, 213, 0.35) transparent;
}

.batch-item {
  min-width: 175px;
  max-width: 220px;
  display: grid;
  grid-template-columns: 2rem minmax(0, 1fr);
  align-items: center;
  gap: 0.6rem;
  padding: 0.62rem 0.7rem;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-muted);
  text-align: left;
  cursor: pointer;
}

.batch-item:hover,
.batch-item.is-active {
  border-color: rgba(0, 207, 213, 0.35);
  background: rgba(0, 207, 213, 0.1);
  color: var(--text-main);
}

.batch-index {
  width: 2rem;
  height: 2rem;
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: rgba(0, 207, 213, 0.12);
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 700;
}

.batch-meta {
  min-width: 0;
}

.batch-name,
.batch-size {
  display: block;
}

.batch-name {
  overflow: hidden;
  font-size: 0.75rem;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.batch-size {
  margin-top: 0.12rem;
  color: var(--text-muted);
  font-size: 0.68rem;
}

.preview-status > div {
  min-width: 0;
  padding: 0.8rem 0.9rem;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.025);
}

.preview-status strong,
.status-label {
  display: block;
}

.preview-status strong {
  overflow: hidden;
  color: var(--text-main);
  font-size: 0.88rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-label {
  margin-bottom: 0.18rem;
  color: var(--text-muted);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.preview-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
}

.button.ghost {
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
}

.button.ghost:hover:not(:disabled) {
  border-color: rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-main);
}

.designer-controls {
  display: grid;
  gap: 1rem;
}

.control-group,
.export-panel {
  display: block;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 20px;
  background: rgba(8, 9, 13, 0.62);
}

.control-group-heading {
  width: 100%;
  min-height: 4.45rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.15rem;
  border: 0;
  border-bottom: 1px solid transparent;
  border-radius: 19px;
  background: transparent;
  color: var(--text-main);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.inline-info > summary::-webkit-details-marker {
  display: none;
}

.control-heading-copy {
  min-width: 0;
  flex: 1 1 auto;
}

.accordion-title,
.accordion-subtitle {
  display: block;
}

.accordion-title {
  font-size: 1rem;
  font-weight: 700;
}

.accordion-subtitle {
  margin: 0.15rem 0 0;
  color: var(--text-muted);
  font-size: 0.82rem;
}

.accordion-chevron {
  width: 0.62rem;
  height: 0.62rem;
  flex: 0 0 0.62rem;
  margin-left: auto;
  border-right: 2px solid var(--text-muted);
  border-bottom: 2px solid var(--text-muted);
  transform: rotate(45deg);
  transition: transform 0.2s ease, border-color 0.2s ease;
}

[data-label-panel].is-open > .control-group-heading .accordion-chevron {
  border-color: var(--accent);
  transform: rotate(225deg);
}

[data-label-panel].is-open > .control-group-heading {
  border-bottom-color: rgba(255, 255, 255, 0.06);
  border-radius: 19px 19px 0 0;
}

.control-group-heading:hover .accordion-title,
.control-group-heading:focus-visible .accordion-title {
  color: var(--accent);
}

.control-group-heading:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -3px;
}

.accordion-content[hidden] {
  display: none;
}

.accordion-content.is-animating {
  overflow: hidden;
  will-change: height, opacity;
  transition: height 0.24s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.18s ease;
}

.accordion-content-clip {
  min-height: 0;
}

.accordion-content-inner {
  display: grid;
  gap: 1.1rem;
  padding: 1.1rem 1.25rem 1.25rem;
}

.field-stack {
  display: grid;
  gap: 0.65rem;
}

.step-number {
  width: 2rem;
  height: 2rem;
  display: grid;
  flex: 0 0 2rem;
  place-items: center;
  border: 1px solid rgba(0, 207, 213, 0.28);
  border-radius: 10px;
  background: rgba(0, 207, 213, 0.1);
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 700;
}

.field-label,
.color-field > span:first-child,
.range-heading,
.export-options label > span:first-child {
  color: var(--text-main);
  font-size: 0.78rem;
  font-weight: 600;
}

.designer-input,
.designer-select {
  width: 100%;
  min-height: 2.8rem;
  padding: 0.68rem 0.8rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  outline: 0;
  background: var(--bg-2);
  color: var(--text-main);
  font: inherit;
  font-size: 0.9rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.designer-input:focus,
.designer-select:focus {
  border-color: rgba(0, 207, 213, 0.65);
  box-shadow: 0 0 0 3px rgba(0, 207, 213, 0.12);
}

.preset-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.preset-button {
  padding: 0.48rem 0.7rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.035);
  color: var(--text-muted);
  font: inherit;
  font-size: 0.78rem;
  cursor: pointer;
}

.preset-button:hover,
.preset-button.is-active {
  border-color: rgba(0, 207, 213, 0.3);
  background: rgba(0, 207, 213, 0.1);
  color: var(--text-main);
}

.control-split,
.color-grid,
.toggle-grid,
.export-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.control-split > div,
.export-options label {
  display: grid;
  gap: 0.45rem;
}

.toggle-card,
.compression-card,
.storage-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  min-height: 4.25rem;
  padding: 0.72rem 0.8rem;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.025);
  cursor: pointer;
}

.toggle-card strong,
.toggle-card small,
.compression-card strong,
.compression-card small,
.storage-card strong,
.storage-card small {
  display: block;
}

.toggle-card strong,
.compression-card strong,
.storage-card strong {
  font-size: 0.78rem;
}

.toggle-card small,
.compression-card small,
.storage-card small {
  margin-top: 0.16rem;
  color: var(--text-muted);
  font-size: 0.7rem;
}

.toggle {
  position: relative;
  width: 2.5rem;
  height: 1.45rem;
  flex: 0 0 2.5rem;
}

.toggle input {
  position: absolute;
  opacity: 0;
}

.toggle-track {
  position: absolute;
  inset: 0;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  transition: background 0.2s ease, border-color 0.2s ease;
}

.toggle-track::after {
  content: '';
  position: absolute;
  top: 0.19rem;
  left: 0.2rem;
  width: 0.95rem;
  height: 0.95rem;
  border-radius: 50%;
  background: #d8d8e0;
  transition: transform 0.2s ease, background 0.2s ease;
}

.toggle input:checked + .toggle-track {
  border-color: rgba(0, 207, 213, 0.55);
  background: rgba(0, 207, 213, 0.26);
}

.toggle input:checked + .toggle-track::after {
  transform: translateX(1.04rem);
  background: var(--accent);
}

.toggle input:focus-visible + .toggle-track {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.toggle input:disabled + .toggle-track {
  cursor: not-allowed;
  opacity: 0.38;
}

.color-field,
.range-field {
  display: grid;
  gap: 0.5rem;
}

.range-field {
  min-height: 3.15rem;
  gap: 0.68rem;
  padding: 0.1rem 0 0.35rem;
}

.color-input-wrap {
  min-height: 2.65rem;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.35rem 0.55rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  background: var(--bg-2);
}

.color-input-wrap input[type='color'] {
  width: 1.75rem;
  height: 1.75rem;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 7px;
  background: transparent;
  cursor: pointer;
}

.color-input-wrap output {
  color: var(--text-muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.72rem;
}

.range-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.range-heading output {
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

input[type='range'] {
  width: 100%;
  height: 4px;
  margin: 0.12rem 0 0.2rem;
  border-radius: 999px;
  outline: none;
  accent-color: var(--accent);
  cursor: pointer;
}

input[type='range']:disabled {
  cursor: not-allowed;
  opacity: 0.4;
}

.position-picker {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 2.3rem);
  gap: 0.35rem;
  padding: 0.55rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.025);
}

.position-button {
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-muted);
  font-size: 1rem;
  cursor: pointer;
}

.position-button[data-position='top-left'] { grid-area: 1 / 1; }
.position-button[data-position='top-center'] { grid-area: 1 / 2; }
.position-button[data-position='top-right'] { grid-area: 1 / 3; }
.position-button[data-position='middle-left'] { grid-area: 2 / 1; }
.position-button[data-position='center'] { grid-area: 2 / 2; }
.position-button[data-position='middle-right'] { grid-area: 2 / 3; }
.position-button[data-position='bottom-left'] { grid-area: 3 / 1; }
.position-button[data-position='bottom-center'] { grid-area: 3 / 2; }
.position-button[data-position='bottom-right'] { grid-area: 3 / 3; }

.position-button:hover,
.position-button.is-active {
  border-color: rgba(0, 207, 213, 0.35);
  background: rgba(0, 207, 213, 0.14);
  color: var(--accent);
}

.position-button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.rotation-control {
  display: grid;
  gap: 0.5rem;
}

.rotation-picker {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.4rem;
}

.rotation-button {
  min-height: 2.6rem;
  padding: 0.55rem 0.4rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-muted);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}

.rotation-button:hover,
.rotation-button.is-active {
  border-color: rgba(0, 207, 213, 0.35);
  background: rgba(0, 207, 213, 0.14);
  color: var(--accent);
}

.rotation-button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.export-panel {
  border-color: rgba(0, 207, 213, 0.18);
  background: linear-gradient(145deg, rgba(0, 207, 213, 0.09), rgba(123, 97, 255, 0.05));
}

.compression-card {
  min-height: 3.35rem;
  border-color: rgba(0, 207, 213, 0.13);
  background: rgba(0, 207, 213, 0.055);
  cursor: default;
}

.compression-title-row {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.inline-info {
  position: relative;
  flex: 0 0 auto;
}

.inline-info > summary {
  width: 1.35rem;
  height: 1.35rem;
  display: grid;
  place-items: center;
  border: 1px solid rgba(0, 207, 213, 0.32);
  border-radius: 50%;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  list-style: none;
}

.inline-info > summary:hover,
.inline-info > summary:focus-visible,
.inline-info[open] > summary {
  background: rgba(0, 207, 213, 0.14);
}

.inline-info > summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.inline-info-content {
  position: absolute;
  z-index: 5;
  top: calc(100% + 0.55rem);
  right: 0;
  width: min(290px, 72vw);
  margin: 0;
  padding: 0.75rem 0.8rem;
  border: 1px solid rgba(0, 207, 213, 0.25);
  border-radius: 12px;
  background: #11131a;
  color: var(--text-muted);
  font-size: 0.74rem;
  font-weight: 400;
  line-height: 1.5;
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.38);
}

.storage-card {
  min-height: 4.8rem;
  border-color: rgba(123, 97, 255, 0.2);
  background: rgba(123, 97, 255, 0.06);
}

.storage-copy {
  min-width: 0;
}

.storage-actions {
  display: grid;
  gap: 0.45rem;
}

.storage-actions p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.74rem;
}

.storage-actions p[data-tone='success'] {
  color: #7ce6be;
}

.storage-actions p[data-tone='error'] {
  color: #ff9da2;
}

.button.compact-button {
  width: fit-content;
  min-height: 2.3rem;
  padding: 0.45rem 0.7rem;
  font-size: 0.74rem;
}

.compression-card.is-disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

.quality-option > span {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
}

.quality-option output {
  color: var(--accent);
}

.download-button {
  width: 100%;
  min-height: 3.2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  border: 1px solid rgba(0, 207, 213, 0.45);
  border-radius: 13px;
  background: linear-gradient(135deg, #00cfd5, #00a7ad);
  color: #041012;
  font-weight: 700;
  box-shadow: 0 12px 30px rgba(0, 207, 213, 0.2);
}

.download-button:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 16px 35px rgba(0, 207, 213, 0.3);
}

.download-button svg {
  width: 1.15rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  transform: none;
  box-shadow: none;
}

.export-feedback {
  min-height: 1.15rem;
  margin: 0;
  color: var(--text-muted);
}

.export-feedback[data-tone='success'] { color: #7ce6be; }
.export-feedback[data-tone='error'] { color: #ff9da2; }
.export-feedback[data-tone='warning'] { color: #ffe0a1; }

.info-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
}

.info-grid article {
  position: relative;
  min-height: 175px;
  padding: 1.2rem;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 17px;
  background: rgba(255, 255, 255, 0.025);
}

.info-grid h3 {
  margin: 1.7rem 0 0.45rem;
  font-size: 1rem;
}

.info-grid p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.88rem;
  line-height: 1.6;
}

.info-number {
  position: absolute;
  top: 0.8rem;
  right: 1rem;
  color: rgba(0, 207, 213, 0.24);
  font-size: 2rem;
  font-weight: 700;
}

@media (max-width: 1020px) {
  .label-editor-grid {
    grid-template-columns: 1fr;
  }

  .preview-column {
    position: static;
  }

  .image-stage {
    min-height: 480px;
  }
}

@media (max-width: 700px) {
  .label-workspace {
    padding: 1rem;
  }

  .workspace-heading,
  .preview-actions {
    align-items: flex-start;
  }

  .image-stage {
    min-height: 360px;
  }

  .empty-preview {
    min-height: 340px;
  }

  .empty-art {
    width: 126px;
    height: 96px;
  }

  .empty-art svg {
    width: 96px;
  }

  .preview-status,
  .info-grid {
    grid-template-columns: 1fr;
  }

  .preview-status {
    gap: 0.45rem;
  }

  .control-split,
  .color-grid,
  .toggle-grid,
  .export-options {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .workspace-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .preview-actions .button {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .image-stage,
  .download-button,
  .accordion-content,
  .accordion-chevron,
  .toggle-track,
  .toggle-track::after {
    transition: none;
  }
}
