/**
 * Phase 6 — UI/UX, Responsive & Accessibility Hardening
 * Additive layer on top of style.css / mobile-compat / accessibility / ux-system
 * Does not change brand tokens; tightens consistency, overflow, empty/error UX.
 */

/* ========== Shared empty / error panels ========== */
.ux-empty,
.no-products,
.compare-empty,
.wishlist-empty,
.search-empty {
  text-align: center;
  padding: var(--space-7, 48px) var(--space-4, 16px);
  color: var(--text-muted, #5a665e);
  max-width: 420px;
  margin-inline: auto;
}

.ux-empty__icon,
.no-products i {
  font-size: 2.25rem;
  color: var(--green-light, #4fae83);
  margin-bottom: var(--space-3, 12px);
  display: block;
}

.ux-empty h3,
.no-products h3 {
  margin: 0 0 var(--space-2, 8px);
  font-size: 1.15rem;
  color: var(--text-primary, #1a3c2a);
}

.ux-empty p,
.no-products p {
  margin: 0 0 var(--space-4, 16px);
  line-height: 1.6;
  font-size: 0.95rem;
}

.ux-empty__cta,
.no-products .action-btn-sm {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 44px;
  padding: 0.65rem 1.25rem;
  border-radius: var(--radius-md, 12px);
  font-weight: 600;
}

/* Catalog status banner (API fallback) */
#catalogStatusBanner {
  margin: 0.75rem 0;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md, 12px);
  font-size: 0.9rem;
  line-height: 1.5;
}

/* ========== Order modal polish ========== */
.pp-order-modal[hidden] { display: none !important; }
.pp-order-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(1rem, env(safe-area-inset-top)) 1rem max(1rem, env(safe-area-inset-bottom));
}
.pp-order-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
}
.pp-order-modal-panel {
  position: relative;
  background: #fff;
  border-radius: var(--radius-lg, 18px);
  max-width: 420px;
  width: 100%;
  padding: 1.5rem;
  box-shadow: var(--shadow-lg, 0 12px 32px rgba(35, 40, 35, 0.12));
  max-height: min(90vh, 640px);
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}
.pp-order-modal-close {
  position: absolute;
  top: 0.6rem;
  left: 0.8rem;
  border: 0;
  background: transparent;
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
  color: #666;
  min-width: 44px;
  min-height: 44px;
}
.pp-order-modal-panel h2 {
  margin: 0 0 0.35rem;
  font-size: 1.2rem;
  color: var(--green-dark, #145c3f);
}
.pp-order-modal-sub {
  margin: 0 0 1rem;
  color: #5a665e;
  font-size: 0.92rem;
}
.pp-order-form-error {
  color: var(--error, #d64545);
  font-size: 0.9rem;
  margin: 0.5rem 0;
}
.pp-order-modal-panel label {
  display: block;
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 0.35rem;
  color: #1a3c2a;
}
.pp-order-modal-panel input,
.pp-order-modal-panel textarea {
  width: 100%;
  min-height: 44px;
  padding: 0.65rem 0.75rem;
  border: 1px solid #d0d7d2;
  border-radius: var(--radius-sm, 8px);
  font-size: 16px; /* iOS no-zoom */
  box-sizing: border-box;
}
.pp-order-modal-panel input:focus-visible,
.pp-order-modal-panel textarea:focus-visible {
  outline: 3px solid #00b894;
  outline-offset: 2px;
  border-color: var(--green-primary, #1f8a5f);
}
.pp-order-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
}
.pp-order-actions button {
  min-height: 44px;
  padding: 0.65rem 1.1rem;
  border-radius: var(--radius-md, 12px);
  font-weight: 600;
  cursor: pointer;
}
.pp-order-actions button[type="submit"],
.pp-order-actions .pp-order-submit {
  background: var(--green-gradient, linear-gradient(135deg, #1f8a5f, #145c3f));
  color: #fff;
  border: none;
}
.pp-order-actions button[type="submit"]:disabled,
.pp-order-actions .pp-order-submit:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}
.pp-order-cancel {
  background: #eef1ee;
  border: none;
  color: #1a3c2a;
}

/* ========== Product grid responsive consistency ========== */
@media (max-width: 480px) {
  .products-grid,
  #productsGrid {
    grid-template-columns: 1fr !important;
    gap: var(--space-4, 16px);
  }
  .product-card .product-name,
  .product-card h3 {
    font-size: 0.98rem;
    line-height: 1.4;
  }
  .product-cta-btn,
  .wishlist-btn {
    min-height: 44px;
  }
}

@media (min-width: 481px) and (max-width: 768px) {
  .products-grid,
  #productsGrid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-4, 16px);
  }
}

/* Prevent card text overflow */
.product-card {
  min-width: 0;
}
.product-card .product-name,
.product-card h3 {
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* ========== Compare table mobile ========== */
@media (max-width: 768px) {
  .compare-table-wrap,
  .compare-container,
  .compare-table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
  }
  .compare-table {
    min-width: 520px;
  }
}

/* ========== Forms: consistent error + disabled ========== */
.form-error:empty { display: none; }
.form-error:not(:empty) {
  display: block;
  color: var(--error, #d64545);
  font-size: 0.85rem;
  margin-top: 0.35rem;
}
button.is-loading,
button[disabled].is-loading {
  cursor: wait;
  opacity: 0.75;
}

/* ========== Toast container safe area ========== */
.ux-toast-container,
#uxToastRoot {
  padding-bottom: max(0.75rem, env(safe-area-inset-bottom));
  padding-left: max(0.75rem, env(safe-area-inset-left));
  padding-right: max(0.75rem, env(safe-area-inset-right));
}

/* ========== Reduced motion ========== */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ========== Content max width desktop ========== */
@media (min-width: 1280px) {
  .container,
  .main-content > .container,
  section > .container {
    max-width: 1200px;
  }
}

/* ========== Focus for order modal close ========== */
.pp-order-modal-close:focus-visible {
  outline: 3px solid #00b894;
  outline-offset: 2px;
}

/* ========== Visually hidden utility ========== */
.ux-sr-only,
.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;
}
