/* ========================================
   PRODUCTS
======================================== */


/* ----------------------------------------
   Page
---------------------------------------- */

.products-page,
.product-editor-page {
  width: min(1440px, calc(100% - 48px));

  margin: 0 auto;

  padding:
    var(--space-8)
    0
    70px;
}

.product-editor-page {
  max-width: 900px;
}


/* ----------------------------------------
   Header
---------------------------------------- */

.products-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;

  gap: var(--space-6);

  margin-bottom: var(--space-8);
}

.products-back-link {
  display: inline-flex;

  margin-bottom: var(--space-5);

  color: var(--color-text-muted);

  font-size: 14px;
  font-weight: 600;

  text-decoration: none;
}

.products-back-link:hover {
  color: var(--color-text);
}

.products-eyebrow {
  display: block;

  margin-bottom: 5px;

  color: var(--color-text-muted);

  font-size: 10px;
  font-weight: 700;

  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.products-header h1,
.product-editor-header h1 {
  margin: 0;

  font-size: clamp(34px, 5vw, 50px);

  line-height: 1;

  letter-spacing: -0.05em;
}

.products-header p,
.product-editor-header p {
  margin:
    var(--space-3)
    0
    0;

  color: var(--color-text-muted);

  font-size: 14px;
}

.products-create-button {
  flex-shrink: 0;
}

.products-create-icon {
  font-size: 19px;
}


/* ----------------------------------------
   Feedback
---------------------------------------- */

.products-notice,
.products-alert {
  margin-bottom: var(--space-6);

  padding:
    14px
    16px;

  border-radius: var(--radius-md);

  font-size: 13px;
  font-weight: 600;
}

.products-notice {
  display: flex;
  align-items: center;

  gap: var(--space-3);

  background: var(--color-success-light);

  border:
    1px
    solid
    rgba(22, 130, 93, 0.16);

  color: var(--color-success);
}

.products-notice-icon {
  display: flex;
  align-items: center;
  justify-content: center;

  width: 26px;
  height: 26px;

  background: var(--color-success);

  border-radius: 50%;

  color: #ffffff;
}

.products-alert {
  background: var(--color-danger-light);

  border:
    1px
    solid
    var(--color-danger-border);

  color: var(--color-danger);
}


/* ----------------------------------------
   Summary
---------------------------------------- */

.products-summary {
  display: grid;

  grid-template-columns:
    repeat(3, minmax(0, 1fr));

  gap: var(--space-3);

  margin-bottom: var(--space-6);
}

.products-summary-card {
  display: flex;
  flex-direction: column;

  min-height: 120px;

  padding: var(--space-5);

  background: var(--color-surface);

  border:
    1px
    solid
    var(--color-border);

  border-radius: var(--radius-lg);

  box-shadow: var(--shadow-card);
}

.products-summary-card span {
  color: var(--color-text-muted);

  font-size: 12px;
  font-weight: 600;
}

.products-summary-card strong {
  margin-top: auto;

  font-size: 29px;

  line-height: 1;

  letter-spacing: -0.04em;
}


/* ----------------------------------------
   Panel
---------------------------------------- */

.products-panel {
  background: var(--color-surface);

  border:
    1px
    solid
    var(--color-border);

  border-radius: var(--radius-lg);

  box-shadow: var(--shadow-card);

  overflow: hidden;
}

.products-panel-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;

  gap: var(--space-4);

  padding:
    var(--space-5)
    var(--space-6);

  border-bottom:
    1px
    solid
    var(--color-border);
}

.products-panel-header h2 {
  margin: 0;

  font-size: 20px;

  letter-spacing: -0.025em;
}

.products-register-link {
  color: var(--color-text-muted);

  font-size: 12px;
  font-weight: 700;

  text-decoration: none;
}

.products-register-link:hover {
  color: var(--color-text);
}


/* ----------------------------------------
   Table
---------------------------------------- */

.products-table-wrapper {
  overflow-x: auto;
}

.products-table {
  width: 100%;

  border-collapse: collapse;
}

.products-table th {
  padding:
    13px
    var(--space-5);

  background: var(--color-surface-secondary);

  border-bottom:
    1px
    solid
    var(--color-border);

  color: var(--color-text-muted);

  font-size: 10px;
  font-weight: 700;

  letter-spacing: 0.05em;
  text-align: left;
  text-transform: uppercase;

  white-space: nowrap;
}

.products-table td {
  padding:
    var(--space-4)
    var(--space-5);

  border-bottom:
    1px
    solid
    var(--color-border);

  font-size: 13px;

  vertical-align: middle;
}

.products-table tbody tr:last-child td {
  border-bottom: 0;
}

.products-table tbody tr {
  transition:
    background var(--transition-fast),
    opacity var(--transition-fast);
}

.products-table tbody tr:hover {
  background: var(--color-surface-secondary);
}

.products-table tbody tr.is-inactive {
  opacity: 0.6;
}

.products-position-column {
  width: 80px;

  text-align: center !important;
}

.products-position {
  display: inline-flex;
  align-items: center;
  justify-content: center;

  width: 32px;
  height: 32px;

  background: var(--color-surface-secondary);

  border-radius: var(--radius-xs);

  color: var(--color-text-muted);

  font-size: 11px;
  font-weight: 800;
}

.products-name {
  display: flex;
  flex-direction: column;

  gap: 4px;
}

.products-name strong {
  font-size: 14px;
}

.products-name small {
  color: var(--color-text-muted);

  font-size: 10px;
}

.products-price {
  font-size: 14px;

  white-space: nowrap;
}

.products-sales-count {
  color: var(--color-text-muted);

  font-weight: 700;
}


/* ----------------------------------------
   Status
---------------------------------------- */

.products-status {
  display: inline-flex;
  align-items: center;

  gap: 6px;

  min-height: 26px;

  padding:
    0
    9px;

  background: var(--color-surface-secondary);

  border-radius: var(--radius-pill);

  color: var(--color-text-muted);

  font-size: 10px;
  font-weight: 750;
}

.products-status--active {
  background: var(--color-success-light);

  color: var(--color-success);
}

.products-status--active span {
  width: 6px;
  height: 6px;

  background: currentColor;

  border-radius: 50%;
}


/* ----------------------------------------
   Actions
---------------------------------------- */

.products-actions-column {
  text-align: right;
}

.products-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;

  gap: 7px;
}

.products-actions form {
  margin: 0;
}

.products-action-link,
.products-action-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;

  min-height: 34px;

  padding:
    0
    10px;

  background: var(--color-surface-secondary);

  border:
    1px
    solid
    var(--color-border);

  border-radius: var(--radius-xs);

  color: var(--color-text);

  font: inherit;
  font-size: 11px;
  font-weight: 700;

  text-decoration: none;

  cursor: pointer;
}

.products-action-link:hover,
.products-action-button:hover {
  background: var(--color-border);
}

.products-action-button--activate {
  background: var(--color-success-light);

  border-color: transparent;

  color: var(--color-success);
}

.products-action-button--danger {
  background: var(--color-danger-light);

  border-color: transparent;

  color: var(--color-danger);
}


/* ----------------------------------------
   Empty
---------------------------------------- */

.products-empty {
  display: flex;
  flex-direction: column;
  align-items: center;

  padding:
    70px
    30px;

  text-align: center;
}

.products-empty-icon {
  display: flex;
  align-items: center;
  justify-content: center;

  width: 56px;
  height: 56px;

  margin-bottom: var(--space-5);

  background: var(--color-primary);

  border-radius: 50%;

  color: #ffffff;

  font-size: 25px;
}

.products-empty h3 {
  margin:
    0
    0
    var(--space-2);

  font-size: 18px;
}

.products-empty p {
  max-width: 420px;

  margin:
    0
    0
    var(--space-5);

  color: var(--color-text-muted);

  font-size: 13px;

  line-height: 1.6;
}


/* ----------------------------------------
   Editor
---------------------------------------- */

.product-editor-header {
  margin-bottom: var(--space-8);
}

.product-form {
  display: grid;

  gap: var(--space-5);
}

.product-form-section {
  padding: var(--space-6);

  background: var(--color-surface);

  border:
    1px
    solid
    var(--color-border);

  border-radius: var(--radius-lg);

  box-shadow: var(--shadow-card);
}

.product-form-section-heading {
  margin-bottom: var(--space-6);
}

.product-form-section-heading h2 {
  margin: 0;

  font-size: 20px;
}

.product-form-section-heading p {
  margin:
    var(--space-2)
    0
    0;

  color: var(--color-text-muted);

  font-size: 12px;
}

.product-form-fields {
  display: grid;

  grid-template-columns:
    repeat(2, minmax(0, 1fr));

  gap: var(--space-5);
}

.product-form-field {
  display: flex;
  flex-direction: column;

  gap: var(--space-2);
}

.product-form-field--full {
  grid-column:
    1
    /
    -1;
}

.product-form-field label {
  font-size: 12px;
  font-weight: 750;
}

.product-form-field input,
.product-form-field select {
  width: 100%;
  min-height: 48px;

  padding:
    0
    14px;

  background: var(--color-surface);

  border:
    1px
    solid
    var(--color-border);

  border-radius: var(--radius-sm);

  color: var(--color-text);

  font: inherit;
  font-size: 14px;
}

.product-form-field input:focus,
.product-form-field select:focus {
  outline:
    2px
    solid
    rgba(23, 32, 42, 0.1);

  outline-offset: 1px;

  border-color: var(--color-primary);
}

.product-form-field small {
  color: var(--color-text-muted);

  font-size: 10px;
}


/* ----------------------------------------
   Price input
---------------------------------------- */

.product-price-input {
  position: relative;
}

.product-price-input input {
  padding-right: 48px;
}

.product-price-input span {
  position: absolute;

  top: 50%;
  right: 15px;

  transform: translateY(-50%);

  color: var(--color-text-muted);

  font-size: 14px;
  font-weight: 750;
}


/* ----------------------------------------
   Active toggle
---------------------------------------- */

.product-active-control {
  display: flex;
  align-items: center;

  gap: var(--space-4);

  cursor: pointer;
}

.product-active-control input {
  position: absolute;

  opacity: 0;

  pointer-events: none;
}

.product-active-toggle {
  position: relative;

  width: 48px;
  height: 28px;

  flex-shrink: 0;

  background: #d5d9de;

  border-radius: var(--radius-pill);

  transition:
    background var(--transition-fast);
}

.product-active-toggle::after {
  content: "";

  position: absolute;

  top: 4px;
  left: 4px;

  width: 20px;
  height: 20px;

  background: #ffffff;

  border-radius: 50%;

  box-shadow:
    0 1px 3px rgba(0, 0, 0, 0.18);

  transition:
    transform var(--transition-fast);
}

.product-active-control input:checked + .product-active-toggle {
  background: var(--color-success);
}

.product-active-control input:checked + .product-active-toggle::after {
  transform: translateX(20px);
}

.product-active-content {
  display: flex;
  flex-direction: column;

  gap: 3px;
}

.product-active-content strong {
  font-size: 13px;
}

.product-active-content small {
  color: var(--color-text-muted);

  font-size: 11px;
}


/* ----------------------------------------
   Errors
---------------------------------------- */

.product-form-errors {
  padding:
    var(--space-4)
    var(--space-5);

  background: var(--color-danger-light);

  border:
    1px
    solid
    var(--color-danger-border);

  border-radius: var(--radius-md);

  color: var(--color-danger);

  font-size: 12px;
}

.product-form-errors ul {
  margin:
    var(--space-2)
    0
    0;

  padding-left: 20px;
}


/* ----------------------------------------
   Form actions
---------------------------------------- */

.product-form-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;

  gap: var(--space-3);
}

.product-form-cancel {
  display: inline-flex;
  align-items: center;
  justify-content: center;

  min-height: 44px;

  padding:
    0
    18px;

  color: var(--color-text-muted);

  font-size: 13px;
  font-weight: 700;

  text-decoration: none;
}

.product-form-cancel:hover {
  color: var(--color-text);
}


/* ----------------------------------------
   Responsive
---------------------------------------- */

@media (max-width: 850px) {
  .products-page,
  .product-editor-page {
    width: calc(100% - 28px);

    padding-top: var(--space-5);
  }

  .products-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .products-create-button {
    width: 100%;
  }

  .products-actions {
    min-width: 260px;
  }
}


@media (max-width: 600px) {
  .products-page,
  .product-editor-page {
    width: calc(100% - 20px);
  }

  .products-summary {
    grid-template-columns:
      repeat(3, 1fr);
  }

  .products-summary-card {
    min-height: 100px;

    padding: var(--space-4);
  }

  .products-summary-card strong {
    font-size: 23px;
  }

  .product-form-fields {
    grid-template-columns: 1fr;
  }

  .product-form-field--full {
    grid-column: auto;
  }

  .product-form-section {
    padding: var(--space-5);
  }

  .product-form-actions {
    align-items: stretch;
    flex-direction: column-reverse;
  }

  .product-form-actions .button,
  .product-form-cancel {
    width: 100%;
  }
}
