/* Pagina de produtos: listagem, filtros, painel lateral e formulario. */

.page-header--settings {
  align-items: center;
  padding-bottom: 0;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-elevated);
}

.theme-toggle__icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--theme-icon-idle);
}

:root:not([data-theme="light"]) .theme-toggle__icon--moon {
  color: var(--theme-icon-active);
}

:root[data-theme="light"] .theme-toggle__icon--sun {
  color: var(--theme-icon-active);
}

.theme-toggle__icon svg {
  width: 15px;
  height: 15px;
}

.theme-toggle__switch {
  width: 42px;
  height: 24px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--theme-switch-bg);
  position: relative;
  cursor: pointer;
  padding: 0;
}

.theme-toggle__switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--primary);
  transition: transform 0.15s ease;
  transform: translateX(18px);
}

:root[data-theme="light"] .theme-toggle__switch::after {
  transform: translateX(0);
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: #ffffff;
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.btn-primary svg {
  width: 16px;
  height: 16px;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: wait;
}

.alert-message {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(-12px);
  z-index: 300;
  min-width: min(92vw, 420px);
  padding: 14px 18px;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-weight: 600;
  text-align: center;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.28);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.alert-message.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}

.alert-message--success {
  color: #dcfce7;
  background: #166534;
  border: 1px solid rgba(34, 197, 94, 0.45);
}

.alert-message--error {
  color: #fee2e2;
  background: #991b1b;
  border: 1px solid rgba(239, 68, 68, 0.45);
}

.content--products {
  padding-bottom: 96px;
}

.products-page {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: calc(100vh - 220px);
}

.products-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: end;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-elevated);
}

.products-toolbar__search {
  flex: 1 1 240px;
}

.products-toolbar__filters {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: end;
}

.products-toolbar__actions {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-left: auto;
}

.products-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.products-field label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.products-field input,
.products-field select,
.products-field textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--input-bg);
  color: var(--text);
  font-size: 0.88rem;
  outline: none;
}

.products-field input:focus,
.products-field select:focus,
.products-field textarea:focus {
  border-color: rgba(59, 130, 246, 0.55);
}

.products-field--compact {
  min-width: 140px;
}

.products-status {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.84rem;
  line-height: 1.45;
}

.products-status--loading {
  color: var(--text-muted);
  background: var(--surface-elevated);
  border: 1px solid var(--border);
}

.products-status--error {
  color: #fecaca;
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.35);
}

.products-status--info {
  color: var(--text-muted);
  background: var(--surface-elevated);
  border: 1px solid var(--border);
}

.products-plan-badge {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--border);
}

.products-table-wrap {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
}

.products-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 920px;
}

.products-table th,
.products-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-subtle);
  text-align: left;
  vertical-align: middle;
  font-size: 0.84rem;
}

.products-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-elevated);
  color: var(--text-dim);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.products-table tbody tr:hover {
  background: rgba(41, 121, 255, 0.06);
}

.products-table__product {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.products-thumb {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  background: rgba(41, 121, 255, 0.12);
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.products-thumb--empty {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  font-size: 0.7rem;
  font-weight: 700;
}

.products-table__name-btn,
.products-card__title-btn {
  border: 0;
  background: none;
  padding: 0;
  color: var(--text);
  font: inherit;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}

.products-table__name-btn:hover,
.products-card__title-btn:hover {
  color: var(--primary);
}

.products-stock--low {
  color: #ffab00;
  font-weight: 700;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
}

.status-chip--active {
  color: #86efac;
  background: rgba(34, 197, 94, 0.14);
}

.status-chip--inactive {
  color: var(--text-muted);
  background: rgba(148, 163, 184, 0.14);
}

:root[data-theme="light"] .status-chip--active {
  color: #15803d;
}

.products-actions {
  display: flex;
  gap: 6px;
}

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-elevated);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.icon-btn:hover {
  border-color: rgba(41, 121, 255, 0.45);
  color: var(--primary);
}

.icon-btn svg {
  width: 16px;
  height: 16px;
}

.icon-btn--danger:hover {
  border-color: rgba(239, 68, 68, 0.45);
  color: #ff1744;
}

.products-cards {
  display: none;
  flex-direction: column;
  gap: 12px;
}

.product-card {
  display: flex;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
}

.product-card__body {
  flex: 1;
  min-width: 0;
}

.product-card__meta {
  margin-top: 4px;
  color: var(--text-muted);
  font-size: 0.82rem;
}

.product-card__actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-end;
}

.products-empty {
  padding: 48px 20px;
  text-align: center;
  color: var(--text-dim);
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
}

.products-fab-group {
  position: fixed;
  right: 20px;
  bottom: 24px;
  display: none;
  flex-direction: column;
  gap: 12px;
  z-index: 140;
}

.products-fab {
  width: 56px;
  height: 56px;
  border: 0;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.32);
  cursor: pointer;
}

.products-delete-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  cursor: not-allowed;
}

.products-delete-btn__icon {
  display: block;
  width: 20px;
  height: 20px;
  background-color: var(--text-dim);
  -webkit-mask-image: url("../../../assets/icons/trash-bin.svg");
  mask-image: url("../../../assets/icons/trash-bin.svg");
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
  -webkit-mask-size: contain;
  mask-size: contain;
  -webkit-mask-mode: alpha;
  mask-mode: alpha;
}

.products-delete-btn.is-ready {
  border-color: rgba(239, 68, 68, 0.45);
  background: rgba(239, 68, 68, 0.12);
  cursor: pointer;
}

.products-delete-btn.is-ready .products-delete-btn__icon {
  background-color: #ff1744;
}

.products-delete-btn.is-ready:hover {
  background: rgba(239, 68, 68, 0.2);
}

.products-delete-btn:disabled {
  cursor: not-allowed;
}

.products-fab svg {
  width: 22px;
  height: 22px;
}

.products-fab .products-delete-btn__icon {
  width: 22px;
  height: 22px;
  background-color: #d4d4d8;
}

.products-fab--create {
  background: var(--primary);
  color: #fff;
}

.products-fab--delete {
  background: #52525b;
  color: #fff;
  cursor: not-allowed;
}

.products-fab--delete.is-ready {
  background: #ff1744;
  cursor: pointer;
}

.products-fab--delete.is-ready .products-delete-btn__icon {
  background-color: #ffffff;
}

.products-fab--delete:disabled {
  cursor: not-allowed;
}

.product-panel-backdrop,
.product-details-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 180;
}

.product-panel,
.product-details-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: min(560px, 100vw);
  height: 100vh;
  z-index: 190;
  background: var(--surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.22s ease;
}

.product-panel.is-open,
.product-details-panel.is-open {
  transform: translateX(0);
}

.product-panel__header,
.product-details-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}

.product-panel__title,
.product-details-panel__title {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
}

.product-panel__body,
.product-details-panel__body {
  flex: 1;
  overflow: auto;
  padding: 18px 20px 24px;
}

.product-details-panel__body {
  padding: 14px 20px 20px;
}

.product-panel__footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
}

.product-form {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.product-form__section-title {
  margin: 0 0 10px;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text);
}

.product-form__grid {
  display: grid;
  gap: 12px;
}

.product-form__grid--2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.product-form__grid--3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.product-form__switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-elevated);
}

.product-form__switch-row label {
  font-size: 0.84rem;
  font-weight: 600;
}

.category-row {
  display: flex;
  gap: 8px;
  align-items: end;
}

.category-row select {
  flex: 1;
}

.btn-icon-action {
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

.btn-icon-action svg {
  width: 18px;
  height: 18px;
}

.btn-icon-action--add {
  background: rgba(34, 197, 94, 0.16);
  color: #00c853;
}

.btn-icon-action--remove {
  background: rgba(239, 68, 68, 0.14);
  color: #ff1744;
}

.product-images {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}

.product-image-slot {
  display: flex;
  flex-direction: column;
}

.product-image-slot__preview {
  width: 100%;
  aspect-ratio: 1;
  padding: 0;
  border-radius: var(--radius-sm);
  border: 1px dashed var(--border);
  background: rgba(41, 121, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.product-image-slot__preview:hover {
  border-color: var(--primary);
  background: rgba(41, 121, 255, 0.14);
}

.product-image-slot__preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}

.product-image-slot__placeholder {
  display: block;
  width: 38px;
  height: 38px;
  background-color: var(--primary);
  opacity: 0.8;
  -webkit-mask-image: url("../../../assets/icons/image.svg");
  mask-image: url("../../../assets/icons/image.svg");
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
  -webkit-mask-size: contain;
  mask-size: contain;
  -webkit-mask-mode: alpha;
  mask-mode: alpha;
}

.product-image-slot__input {
  display: none;
}

.details-list {
  display: flex;
  flex-direction: column;
}

.details-row {
  padding: 8px 0 10px;
  border-bottom: 1px solid var(--border);
}

.details-row:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.details-row__label {
  display: block;
  font-size: 0.72rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 3px;
}

.details-row__value {
  font-size: 0.9rem;
  color: var(--text);
  word-break: break-word;
  line-height: 1.35;
}

.details-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
  gap: 10px;
}

.details-gallery img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.details-gallery img:hover {
  transform: scale(1.02);
  border-color: var(--primary);
}

.image-lightbox[hidden] {
  display: none !important;
}

.image-lightbox {
  position: fixed;
  inset: 0;
  z-index: 260;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.image-lightbox__backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  padding: 0;
  margin: 0;
  background: rgba(0, 0, 0, 0.72);
  cursor: pointer;
}

.image-lightbox__content {
  position: relative;
  z-index: 1;
  width: min(960px, 100%);
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
}

.image-lightbox__close {
  position: absolute;
  top: -46px;
  right: 0;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  cursor: pointer;
}

.image-lightbox__close svg {
  width: 18px;
  height: 18px;
}

.image-lightbox__close:hover {
  background: rgba(255, 255, 255, 0.2);
}

.image-lightbox__nav {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  cursor: pointer;
  flex-shrink: 0;
}

.image-lightbox__nav svg {
  width: 22px;
  height: 22px;
}

.image-lightbox__nav:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.22);
}

.image-lightbox__nav:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.image-lightbox__stage {
  margin: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.image-lightbox__image {
  display: block;
  width: 100%;
  max-height: min(72vh, 760px);
  object-fit: contain;
  border-radius: var(--radius-md);
  background: rgba(0, 0, 0, 0.35);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.45);
}

.image-lightbox__counter {
  margin: 0;
  font-size: 0.88rem;
  color: #e4e4e7;
}

@media (max-width: 640px) {
  .image-lightbox {
    padding: 14px;
  }

  .image-lightbox__content {
    gap: 8px;
  }

  .image-lightbox__nav {
    width: 36px;
    height: 36px;
  }

  .image-lightbox__nav svg {
    width: 18px;
    height: 18px;
  }

  .image-lightbox__close {
    top: -36px;
    width: 34px;
    height: 34px;
  }
}

.dialog-backdrop[hidden] {
  display: none !important;
}

.dialog-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 220;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.dialog-card {
  width: min(420px, 100%);
  padding: 20px;
  border-radius: var(--radius-md);
  background: var(--surface);
  border: 1px solid var(--border);
}

.dialog-card h3 {
  margin: 0 0 12px;
  font-size: 1rem;
}

.dialog-card__actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-elevated);
  color: var(--text);
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-danger {
  background: rgba(239, 68, 68, 0.14);
  border-color: rgba(239, 68, 68, 0.35);
  color: #ff1744;
}

.margin-badge {
  display: inline-flex;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
}

.margin-badge--positive {
  color: #86efac;
  background: rgba(34, 197, 94, 0.14);
}

.margin-badge--negative {
  color: #fecaca;
  background: rgba(239, 68, 68, 0.14);
}

@media (max-width: 1023px) {
  .products-table-wrap {
    display: none;
  }

  .products-cards {
    display: flex;
  }

  .products-toolbar__actions .btn-primary {
    display: none;
  }

  .products-fab-group {
    display: flex;
  }

  .product-images {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .product-form__grid--2,
  .product-form__grid--3 {
    grid-template-columns: 1fr;
  }

  .products-toolbar__actions {
    width: 100%;
    margin-left: 0;
  }
}
