:root {
  --ui-bg: #f4e8d8;
  --ui-surface: #fff9f1;
  --ui-surface-soft: #f7ede0;
  --ui-text: #31170f;
  --ui-muted: #7c5c46;
  --ui-primary: #5f2a19;
  --ui-accent: #d1a056;
  --ui-border: #ead7bf;
  --ui-shadow: 0 12px 32px rgba(59, 23, 15, 0.09);
  --ui-radius: 16px;
}

/* Base */
* {
  box-sizing: border-box;
}
html,
body {
  height: 100%;
}
body {
  margin: 0;
  font-family:
    "Cairo",
    system-ui,
    -apple-system,
    Segoe UI,
    Roboto,
    "Helvetica Neue",
    Arial;
  background: radial-gradient(
    circle at top right,
    #fff7ec 0%,
    var(--ui-bg) 44%,
    #e8d5bf 100%
  );
  color: var(--ui-text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Header */
header,
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.9rem 1rem;
  position: sticky;
  top: 0;
  z-index: 1200;
  backdrop-filter: blur(8px);
  background: rgba(59, 23, 15, 0);
  border-bottom: 1px solid rgba(209, 160, 86, 0.28);
}

.logo h1 {
  margin: 0;
  letter-spacing: 0.6px;
  color: var(--ui-accent) !important;
}

/* Nav links */
.nav-links {
  display: flex;
  gap: 0.6rem;
  align-items: center;
}
.nav-links a,
.back-link {
  border-radius: 999px;
  padding: 0.45rem 0.9rem;
  color: rgba(255, 247, 239, 0.88) !important;
  text-decoration: none;
}
.nav-links a:hover,
.nav-links a.active,
.back-link:hover {
  background: rgba(209, 160, 86, 0.14);
  color: var(--ui-accent) !important;
}

/* Layout containers */
.container,
.profile-container,
.orders-container {
  max-width: 1220px;
  margin: 0 auto;
  padding: 0 1rem;
}

/* Product page */
.products-page,
.product-details-page {
  padding: 80px 4% 3rem;
  min-height: 100vh;
}
.product-shell {
  max-width: 1100px;
  margin: 0 auto;
}

/* Product layout - single-image focused */
.product-layout {
  display: grid;
  grid-template-columns: minmax(320px, 1fr) minmax(0, 1fr);
  gap: 1.25rem;
  align-items: start;
}

/* Gallery */
.gallery {
  position: static;
  top: auto;
}
.main-image {
  position: relative;
  height: clamp(360px, 50vh, 720px);
  border-radius: 18px;
  overflow: hidden;
  background: linear-gradient(180deg, #fff, #fbf6f0);
  display: grid;
  place-items: center;
  box-shadow: 0 18px 40px rgba(59, 23, 15, 0.08);
  transition:
    transform 0.22s ease,
    box-shadow 0.22s ease;
}
@media (hover: hover) {
  .main-image:hover {
    transform: translateY(-4px);
    box-shadow: 0 26px 52px rgba(59, 23, 15, 0.12);
  }
  .main-image:hover img {
    transform: scale(1.03);
  }
}
.main-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
  transition: transform 0.35s ease;
}

/* Hide thumbs for single-image layout */
.thumbs {
  display: none !important;
}

/* Product info panel */
.surface#productInfoDetails {
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}
.product-title {
  font-size: clamp(1.6rem, 3vw, 2.2rem);
  line-height: 1.05;
  margin: 0;
}
.price {
  font-size: clamp(1.4rem, 2.8vw, 2.1rem);
  font-weight: 800;
  color: var(--ui-accent);
}
.old-price {
  text-decoration: line-through;
  color: var(--ui-muted);
}

/* Stock pills */
.pill {
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 700;
}
.stock-ok {
  background: #d4edda;
  color: #155724;
}
.stock-low {
  background: #fff3cd;
  color: #856404;
}
.stock-out {
  background: #f8d7da;
  color: #721c24;
}

/* Actions */
.actions {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  margin-top: 0.9rem;
  flex-wrap: nowrap;
}
.buy-btn {
  min-width: 220px;
  padding: 0.95rem 1.25rem;
  font-size: 1rem;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--ui-primary), var(--ui-accent));
  color: #fff;
  border: none;
}
.wish-btn {
  min-width: 150px;
  padding: 0.9rem 1rem;
  border-radius: 12px;
  background: var(--ui-surface-soft);
  border: 1px solid rgba(95, 42, 25, 0.12);
  color: var(--ui-primary);
}
.buy-btn:disabled,
.wish-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Related */
.related-grid {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}
.related-card {
  overflow: hidden;
  border-radius: 14px;
  background: var(--ui-surface);
  border: 1px solid var(--ui-border);
  cursor: pointer;
}
.related-card img {
  width: 100%;
  height: 150px;
  object-fit: cover;
}

/* Badge */
.product-badge {
  position: absolute;
  top: 1rem;
  right: 1rem;
  padding: 0.45rem 0.75rem;
  border-radius: 999px;
  font-weight: 800;
  font-size: 0.85rem;
  background: linear-gradient(
    135deg,
    rgba(209, 160, 86, 0.98),
    rgba(95, 42, 25, 0.9)
  );
  color: #fff;
  box-shadow: 0 6px 18px rgba(59, 23, 15, 0.12);
  z-index: 5;
}

/* Form controls, cards, buttons */
.filters-sidebar,
.profile-sidebar,
.order-card,
.wishlist-card,
.notification-card,
.product-details-container,
#checkoutLayout > section,
#checkoutLayout > aside,
.empty-wishlist {
  background: var(--ui-surface);
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-radius);
  box-shadow: var(--ui-shadow);
}
.product-card,
.chart-card,
.stat-card {
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-radius);
  box-shadow: var(--ui-shadow);
}
.btn,
.auth-btn,
.quick-action-btn,
.add-to-cart-wishlist,
#applyCouponBtn,
#placeOrderBtn {
  border-radius: 12px;
  border: 1px solid transparent;
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease,
    background-color 0.2s ease;
  cursor: pointer;
}
.btn-primary,
.auth-btn,
#applyCouponBtn,
#placeOrderBtn {
  background: linear-gradient(135deg, var(--ui-primary), var(--ui-accent));
  color: #fff;
  box-shadow: 0 12px 24px rgba(95, 42, 25, 0.18);
}
.btn:hover,
.auth-btn:hover,
.quick-action-btn:hover,
.add-to-cart-wishlist:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(95, 42, 25, 0.24);
}

input,
select,
textarea {
  background: var(--ui-surface-soft);
  border: 1px solid var(--ui-border);
  border-radius: 12px;
  color: var(--ui-text);
  padding: 0.6rem;
}
input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--ui-accent);
  box-shadow: 0 0 0 3px rgba(209, 160, 86, 0.18);
}

/* Misc */
.section-title,
.page-title,
.product-title {
  color: var(--ui-text);
}
.old-price,
.rating-count,
.breadcrumb,
.product-description {
  color: var(--ui-muted);
}
.checkout-page {
  max-width: 1220px;
  margin: 0 auto;
  padding: calc(84px + 2rem) 1rem 3rem;
}


/* Large Desktop (1400px+) */
@media (min-width: 1400px) {
    .container,
    .profile-container,
    .orders-container,
    .product-shell,
    .checkout-page {
        max-width: 1320px;
        margin: 0 auto;
    }
}

/* Desktop (1200px and below) */
@media (max-width: 1200px) {
    .product-layout {
        grid-template-columns: 1fr 1fr;
    }
    
    .main-image {
        height: clamp(320px, 44vh, 560px);
    }
    
    .related-grid {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    }
}

/* Tablet (992px and below) */
@media (max-width: 992px) {
    .product-details-page {
        padding: 70px 1.5rem 2rem;
    }
    
    .product-layout {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .main-image {
        height: 380px;
    }
    
    .gallery {
        position: static;
    }
    
    .surface#productInfoDetails {
        padding: 1rem;
    }
    
    .actions {
        flex-wrap: wrap;
    }
    
    .buy-btn {
        flex: 1;
        min-width: 200px;
    }
    
    .profile-container {
        grid-template-columns: 1fr;
    }
    
    .profile-sidebar {
        text-align: center;
    }
    
    .profile-avatar {
        margin: 0 auto;
    }
    
    .checkout-page {
        padding: 70px 1.5rem 2rem;
    }
    
    .payment-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
}

/* Mobile Landscape (768px and below) */
@media (max-width: 768px) {
    .product-details-page {
        padding: 65px 1rem 1.5rem;
    }
    
    .main-image {
        height: 300px;
        border-radius: 12px;
    }
    
    .product-title {
        font-size: 1.5rem;
    }
    
    .price {
        font-size: 1.6rem;
    }
    
    .actions {
        flex-direction: column;
        gap: 0.6rem;
    }
    
    .buy-btn,
    .wish-btn {
        width: 100%;
        min-width: auto;
    }
    
    .product-badge {
        top: 0.5rem;
        right: 0.5rem;
        padding: 0.3rem 0.6rem;
        font-size: 0.75rem;
    }
    
    .related-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.8rem;
    }
    
    .related-card img {
        height: 120px;
    }
    
    .wishlist-grid {
        grid-template-columns: 1fr;
    }
    
    .order-card {
        padding: 1rem;
    }
    
    .checkout-page {
        padding: 65px 1rem 1.5rem;
    }
    
    .cart-summary {
        margin-top: 1.5rem;
    }
}

/* Mobile Portrait (480px and below) */
@media (max-width: 480px) {
    .product-details-page {
        padding: 60px 0.8rem 1rem;
    }
    
    .main-image {
        height: 250px;
    }
    
    .product-title {
        font-size: 1.3rem;
    }
    
    .price {
        font-size: 1.4rem;
    }
    
    .old-price {
        font-size: 0.9rem;
    }
    
    .product-description {
        font-size: 0.9rem;
    }
    
    .related-grid {
        grid-template-columns: 1fr;
    }
    
    .related-card img {
        height: 140px;
    }
    
    .related-card {
        display: flex;
        gap: 0.8rem;
        align-items: center;
    }
    
    .related-card img {
        width: 80px;
        height: 80px;
        flex-shrink: 0;
    }
    
    .related-card .product-info {
        flex: 1;
        padding: 0.5rem;
    }
    
    .notification-card {
        padding: 0.8rem;
    }
    
    .filters-sidebar {
        padding: 1rem;
    }
}

/* Touch Device Optimizations */
@media (hover: none) and (pointer: coarse) {
    .nav-links a,
    .btn,
    .buy-btn,
    .wish-btn,
    .add-to-cart-wishlist {
        padding: 0.75rem 1rem;
        min-height: 44px;
    }
    
    .product-card:hover {
        transform: none;
    }
    
    .main-image:hover {
        transform: none;
    }
}