/* DiOrE shared components. Page files only add layout (grid columns, areas) and page-only widgets on top of these. */

/* Section card */
.diore-section {
  margin-bottom: 24px;
  padding: 16px;
  border: 1px solid var(--diore-border);
  border-radius: var(--diore-radius-lg);
  background: var(--diore-surface-muted);
}

.diore-section--plain {
  background: var(--diore-surface);
}

.diore-section--stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

@media (min-width: 769px) {
  .diore-section {
    padding: 28px;
  }
}

@media (min-width: 992px) {
  .diore-section {
    padding: 32px;
  }
}

/* Two sections side by side */
.diore-section-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.diore-section-grid > .diore-section {
  margin-bottom: 0;
}

@media (max-width: 1200px) {
  .diore-section-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* Section header: icon + title (+ optional actions) */
.diore-section-header {
  display: flex;
  align-items: center;
  gap: 10px;
}

.diore-section-header--divided {
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--diore-border);
}

.diore-section-header .icon {
  display: inline-flex;
  flex: 0 0 auto;
  color: var(--diore-primary);
  font-size: var(--diore-font-size-2xl);
  line-height: 1;
}

.diore-section-header .icon svg {
  width: 1em;
  height: 1em;
}

.account-page .diore-section-title {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  padding: 0;
  color: var(--diore-text);
  font-size: var(--diore-font-size-lg);
  font-weight: 600;
  text-align: left;
}

@media (max-width: 768px) {
  .diore-section-header {
    flex-wrap: wrap;
  }
}

/* White panel inside a section */
.diore-panel {
  padding: 20px;
  border-radius: var(--diore-radius-sm);
  background: var(--diore-surface);
}

@media (max-width: 768px) {
  .diore-panel {
    padding: 16px;
  }
}

/* Label/value list */
.diore-info-list {
  display: grid;
  grid-template-columns: minmax(0, var(--diore-info-label-width, 240px)) minmax(0, 1fr);
  align-content: start;
  gap: 8px 16px;
  flex: 1 1 auto;
  margin: 0;
}

.diore-info-list dt {
  margin: 0;
  color: var(--diore-text);
  font-weight: 600;
}

.diore-info-list dd {
  margin: 0;
  color: var(--diore-text);
  overflow-wrap: anywhere;
}

@media (max-width: 768px) {
  .diore-info-list {
    grid-template-columns: minmax(0, 1fr);
    gap: 2px;
  }

  .diore-info-list dd {
    margin-bottom: 8px;
  }
}

/* Grid table: page files set grid-template-columns on the header and rows */
.diore-table {
  width: 100%;
  overflow: hidden;
  border: 1px solid var(--diore-border);
  border-radius: var(--diore-radius-md);
  background: var(--diore-surface);
}

.diore-table-header,
.diore-table-row {
  display: grid;
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
}

.diore-table-header {
  color: var(--diore-text);
  font-weight: 600;
  background: var(--diore-border-light);
}

.diore-table-row {
  border-top: 1px solid var(--diore-border);
  color: var(--diore-text);
  text-decoration: none;
  transition: background var(--diore-transition);
}

.diore-table-row:first-child {
  border-top: 0;
}

.diore-table-header > *,
.diore-table-row > * {
  min-width: 0;
  overflow-wrap: anywhere;
}

a.diore-table-row:hover,
.diore-table-row--link:hover {
  color: var(--diore-primary);
  background: var(--diore-surface-muted);
  text-decoration: none;
}

.diore-table-row .number,
.diore-table-row .name {
  font-weight: 600;
}

.diore-table .total {
  text-align: right;
}

.diore-table-row .total {
  font-weight: 600;
}

.diore-table-row .arrow {
  display: inline-flex;
  justify-content: flex-end;
  justify-self: end;
  color: var(--diore-text);
  font-size: var(--diore-font-size-2xl);
  line-height: 1;
}

.diore-table-row .arrow svg {
  width: 1em;
  height: 1em;
}

a.diore-table-row:hover .arrow,
.diore-table-row--link:hover .arrow {
  color: var(--diore-primary);
}

.diore-table--truncate .diore-table-header > *,
.diore-table--truncate .diore-table-row > * {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.diore-table-empty {
  padding: 24px 16px;
  border-top: 1px solid var(--diore-border);
  color: var(--diore-text-secondary);
  text-align: center;
}

.diore-table-empty:first-child {
  border-top: 0;
}

.diore-table-total {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 16px;
  padding: 12px 20px;
  border-top: 1px solid var(--diore-border);
  color: var(--diore-text);
  background: var(--diore-surface-accent);
}

.diore-table-total-value {
  font-weight: 700;
}

/* Product cells */
.diore-table-header .cell-product {
  grid-column: span 2;
}

.diore-table-row .cell-image img {
  display: block;
  max-width: 100%;
  max-height: 56px;
  object-fit: contain;
  margin: 0 auto;
}

.diore-table-row .cell-description {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  overflow-wrap: anywhere;
}

.diore-table-row .cell-description .sku {
  color: var(--diore-text-secondary);
  font-size: var(--diore-font-size-sm);
}

.diore-table-row .price-unit {
  margin-left: 2px;
  color: var(--diore-text-light);
}

.diore-table-row .cell-actions {
  display: flex;
  justify-content: flex-end;
}

/* Native <table> inside .diore-table */
.diore-table > table {
  width: 100%;
  border-collapse: collapse;
}

.diore-table th,
.diore-table td {
  padding: 12px 16px;
  color: var(--diore-text);
  text-align: left;
  vertical-align: middle;
}

.diore-table thead th {
  font-weight: 600;
  background: var(--diore-border-light);
}

.diore-table tbody tr,
.diore-table tfoot tr {
  border-top: 1px solid var(--diore-border);
}

@media (max-width: 768px) {
  .diore-table-header {
    display: none;
  }

  .diore-table-header + .diore-table-row {
    border-top: 0;
  }

  .diore-table-row > :first-child {
    font-weight: 600;
  }

  .diore-table--truncate .diore-table-row > * {
    white-space: normal;
  }

  .diore-table-total {
    padding: 12px 16px;
  }
}

/* Status pill: neutral by default, tone via .is-success / .is-warning / .is-error / .is-info */
.diore-status {
  display: inline-flex;
  align-items: center;
  justify-self: start;
  gap: 8px;
  padding: 6px 14px;
  border-radius: 999px;
  color: var(--diore-text-secondary);
  background: var(--diore-border-light);
  font-size: var(--diore-font-size-sm);
  font-weight: 500;
  line-height: 1.2;
  white-space: nowrap;
}

.diore-status::before {
  content: "";
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

.diore-status.is-success {
  color: var(--diore-success-dark);
  background: var(--diore-success-soft);
}

.diore-status.is-warning {
  color: var(--diore-warning-dark);
  background: var(--diore-warning-soft);
}

.diore-status.is-error {
  color: var(--diore-error-dark);
  background: var(--diore-error-soft);
}

.diore-status.is-info {
  color: var(--diore-info);
  background: var(--diore-info-soft);
}

/* Empty state */
.diore-empty {
  padding: 24px 16px;
  border: 1px dashed var(--diore-border);
  border-radius: var(--diore-radius-sm);
  color: var(--diore-text-secondary);
  background: var(--diore-surface);
  text-align: center;
}

/* Form controls */
.diore-field-label {
  display: block;
  margin: 0;
  color: var(--diore-text);
  font-weight: 600;
}

.diore-account-page .diore-input {
  display: block;
  width: 100%;
  max-width: none;
  height: 48px;
  margin: 0;
  padding: 0 16px;
  border: 1px solid var(--diore-border);
  border-radius: var(--diore-radius);
  color: var(--diore-text);
  background-color: var(--diore-surface);
  box-shadow: none;
  font-family: inherit;
  font-size: var(--diore-font-size-md);
  box-sizing: border-box;
  transition: border-color var(--diore-transition), box-shadow var(--diore-transition);
}

.diore-account-page .diore-input:hover {
  border-color: var(--diore-primary);
}

.diore-account-page .diore-input:focus {
  border-color: var(--diore-primary);
  box-shadow: var(--diore-focus-ring);
  outline: none;
}

.diore-account-page .diore-input::placeholder {
  color: var(--diore-text-light);
}

.diore-account-page .diore-input:disabled {
  cursor: not-allowed;
  background-color: var(--diore-surface-muted);
}

/* Element-qualified so it beats the theme's .form-fields .inputs select */
.diore-account-page select.diore-input {
  padding-right: 40px;
  appearance: none;
  background-image: var(--diore-select-chevron);
  background-position: right 16px center;
  background-repeat: no-repeat;
  background-size: 16px;
}

.diore-account-page select.diore-input[multiple] {
  height: auto;
  padding: 8px 12px;
  background-image: none;
}

.diore-account-page .diore-input:where(textarea) {
  height: auto;
  min-height: 90px;
  padding: 12px 16px;
  line-height: 1.5;
  resize: vertical;
}

.diore-account-page .diore-qty-input {
  width: 80px;
  max-width: 100%;
  height: 40px;
  padding: 0 8px;
  text-align: center;
}

/* Input with a postfix (e.g. currency) */
.diore-input-group {
  display: flex;
  align-items: stretch;
}

.diore-account-page .diore-input-group > input {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}

.diore-input-addon {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  padding: 0 12px;
  border: 1px solid var(--diore-border);
  border-left: 0;
  border-radius: 0 var(--diore-radius) var(--diore-radius) 0;
  color: var(--diore-text);
  background: var(--diore-surface-muted);
  font-size: var(--diore-font-size-base);
}

/* Info callout */
.diore-note {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin: 0;
  padding: 12px 16px;
  border: 1px solid var(--diore-accent-border);
  border-radius: var(--diore-radius);
  color: var(--diore-text-secondary);
  background: var(--diore-surface-accent);
  font-size: var(--diore-font-size-sm);
  line-height: 1.5;
}

.diore-note > .icon,
.diore-note > i {
  display: inline-flex;
  flex: 0 0 auto;
  color: var(--diore-primary);
  font-size: var(--diore-font-size-xl);
  line-height: 1;
}

/* Button row */
.diore-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

.diore-actions--start {
  justify-content: flex-start;
}

.diore-actions--center {
  justify-content: center;
}

.diore-actions .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.diore-actions .button i {
  font-size: var(--diore-font-size-lg);
  line-height: 1;
}

.diore-account-page .button:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

@media (max-width: 768px) {
  .diore-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .diore-actions > :only-child {
    grid-column: 1 / -1;
  }

  .diore-actions .button {
    width: 100%;
    min-width: 0;
    max-width: none;
  }
}

/* Modal: hidden with the [hidden] attribute; the panel's auto margin centers it and still lets a tall panel scroll */
.diore-modal {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: flex;
  padding: 40px 16px;
  overflow-y: auto;
}

.diore-modal[hidden] {
  display: none;
}

.diore-modal-backdrop {
  position: fixed;
  inset: 0;
  background: var(--diore-overlay);
}

.diore-modal-panel {
  position: relative;
  box-sizing: border-box;
  width: 100%;
  max-width: var(--diore-modal-width, 480px);
  margin: auto;
  overflow: hidden;
  border-radius: var(--diore-radius-lg);
  background: var(--diore-surface);
  box-shadow: var(--diore-shadow-lg);
}

.diore-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 24px;
  border-bottom: 1px solid var(--diore-border-light);
}

.diore-modal-header h2 {
  margin: 0;
  padding: 0;
  color: var(--diore-text);
  font-size: var(--diore-font-size-xl);
  font-weight: 700;
  line-height: 1.3;
  text-align: left;
}

.diore-modal-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--diore-text-light);
  font-size: var(--diore-font-size-4xl);
  line-height: 1;
  cursor: pointer;
  transition: color var(--diore-transition);
}

.diore-modal-close:hover {
  color: var(--diore-text);
}

.diore-modal-body {
  padding: 24px;
}

.diore-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 16px 24px;
  border-top: 1px solid var(--diore-border-light);
}

.diore-modal-footer .button {
  min-width: 110px;
}

@media (max-width: 768px) {
  .diore-modal {
    padding: 16px;
  }

  .diore-modal-header,
  .diore-modal-body,
  .diore-modal-footer {
    padding-right: 16px;
    padding-left: 16px;
  }

  .diore-modal-footer .button {
    flex: 1 1 0;
    min-width: 0;
  }
}
