* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary: #d4a5a5;
  --primary-dark: #b88888;
  --text: #333;
  --text-light: #666;
  --bg: #fdf8f6;
  --white: #fff;
  --border: #eee;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

body {
  font-family: 'Cairo', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
}

/* Header */
.header {
  background: var(--white);
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 0;
}

.logo {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary-dark);
  text-decoration: none;
}

.nav a {
  margin: 0 1rem;
  color: var(--text);
  text-decoration: none;
}

.nav a:hover {
  color: var(--primary-dark);
}

.cart-btn {
  background: var(--primary);
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  font-size: 1rem;
}

/* Hero */
.hero {
  background: linear-gradient(135deg, #fdf8f6, #f5e6e0);
  padding: 5rem 0 4rem;
  text-align: center;
  overflow: visible;
}

.hero .container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.hero h1 {
  font-size: clamp(1.75rem, 5vw, 2.5rem);
  line-height: 1.4;
  margin: 0;
}

.hero p {
  color: var(--text-light);
  font-size: 1.1rem;
  line-height: 1.7;
  margin: 0;
  max-width: 500px;
}

/* Buttons */
.btn {
  display: inline-block;
  padding: 0.75rem 2rem;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  font-size: 1rem;
  text-decoration: none;
  transition: background 0.2s;
}

.btn-primary {
  background: var(--primary);
  color: var(--white);
}

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-block {
  display: block;
  width: 100%;
  text-align: center;
}

/* Sections */
.section {
  padding: 3rem 0;
}

.section-title {
  text-align: center;
  margin-bottom: 2rem;
  font-size: 1.75rem;
}

/* Categories */
.categories-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 1rem;
}

.category-card {
  background: var(--white);
  padding: 1.75rem 1rem;
  border-radius: 12px;
  text-align: center;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.2s, box-shadow 0.2s;
  border: 1px solid var(--border);
  min-height: 100px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.category-card .cat-icon {
  font-size: 2rem;
  line-height: 1;
}

.category-card .cat-image {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: 50%;
  margin-bottom: 0.25rem;
}

.category-card strong {
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.5;
  word-break: keep-all;
}

.category-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
}

/* Products */
.products-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 1.5rem;
}

.product-card {
  background: var(--white);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.product-image {
  width: 100%;
  height: 280px;
  object-fit: cover;
  background: #f0e6e3;
}

.product-image-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 4rem;
  background: linear-gradient(135deg, #f5e6e0, #fdf8f6);
}

.product-info {
  padding: 1rem;
}

.product-name {
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.product-price {
  color: var(--primary-dark);
  font-weight: 700;
  font-size: 1.1rem;
}

.product-price .old {
  text-decoration: line-through;
  color: var(--text-light);
  font-size: 0.9rem;
  margin-right: 0.5rem;
}

.discount-badge {
  display: inline-block;
  background: #e53935;
  color: white;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  margin-right: 0.5rem;
  vertical-align: middle;
}

/* Cart Sidebar */
.cart-sidebar {
  position: fixed;
  top: 0;
  left: -400px;
  width: 380px;
  height: 100vh;
  background: var(--white);
  box-shadow: -4px 0 20px rgba(0, 0, 0, 0.1);
  z-index: 200;
  transition: left 0.3s;
  display: flex;
  flex-direction: column;
}

.cart-sidebar.open {
  left: 0;
}

.cart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  border-bottom: 1px solid var(--border);
}

.cart-header button {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
}

.cart-items {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
}

.cart-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
}

.cart-footer {
  padding: 1rem;
  border-top: 1px solid var(--border);
}

.cart-summary {
  margin-bottom: 1rem;
}

.cart-summary-row {
  display: flex;
  justify-content: space-between;
  font-weight: 700;
  font-size: 1.1rem;
  margin-bottom: 0.75rem;
}

.free-shipping-bar {
  margin-top: 0.5rem;
}

.free-shipping-progress {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 0.35rem;
}

.free-shipping-progress div {
  height: 100%;
  background: var(--primary);
  border-radius: 3px;
  transition: width 0.3s;
}

.free-shipping-bar small {
  color: var(--text-light);
  font-size: 0.85rem;
}

.checkout-modal {
  max-width: 480px;
}

.checkout-summary {
  background: #faf7f6;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  margin: 0.5rem 0 1rem;
}

.checkout-summary-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.5rem;
  color: var(--text-light);
}

.checkout-summary-row.total {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text);
  border-top: 1px solid var(--border);
  padding-top: 0.5rem;
  margin-top: 0.5rem;
}

.checkout-delivery-note,
.checkout-payment-note {
  font-size: 0.85rem;
  color: var(--text-light);
  margin: 0.35rem 0 0;
}

.modal-content select {
  width: 100%;
  padding: 0.75rem;
  margin-bottom: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  background: var(--white);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.account-btn {
  background: var(--white);
  border: 1px solid var(--border);
  padding: 0.45rem 0.75rem;
  border-radius: 8px;
  font-size: 0.95rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

#accountLabel {
  font-size: 0.85rem;
  font-weight: 600;
}

.account-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.account-stat {
  background: var(--bg);
  border-radius: 8px;
  padding: 0.65rem;
  text-align: center;
}

.account-stat span {
  display: block;
  font-size: 0.75rem;
  color: var(--text-light);
  margin-bottom: 0.25rem;
}

.account-stat strong {
  font-size: 0.9rem;
}

.account-section-title {
  font-size: 1rem;
  margin-bottom: 0.5rem;
}

.order-detail-panel {
  background: var(--bg);
  border-radius: 10px;
  padding: 1rem;
  margin-bottom: 1rem;
}

.order-items-mini {
  margin: 0.75rem 0;
  font-size: 0.9rem;
  color: var(--text-light);
}

.order-items-mini div {
  padding: 0.25rem 0;
}

.my-order-card {
  display: block;
  width: 100%;
  text-align: right;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.85rem;
  margin-bottom: 0.75rem;
  cursor: pointer;
  font-family: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.my-order-card:hover {
  border-color: var(--primary);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.my-orders-list {
  max-height: 360px;
  overflow-y: auto;
  margin: 0.5rem 0 1rem;
}

.my-order-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.35rem;
}

.my-order-meta {
  font-size: 0.9rem;
  color: var(--text-light);
}

.my-order-total {
  font-weight: 700;
  margin-top: 0.35rem;
}

.account-greeting {
  color: var(--text-light);
  margin-bottom: 0.5rem;
}

.footer-link {
  background: none;
  border: none;
  color: var(--primary-dark);
  font-family: inherit;
  font-size: 0.95rem;
  cursor: pointer;
  margin-bottom: 0.5rem;
  text-decoration: underline;
}

.track-result {
  margin-top: 1rem;
}

.track-result .track-row,
.order-detail-panel .track-row {
  display: flex;
  justify-content: space-between;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.95rem;
}

.track-result .track-row:last-child,
.order-detail-panel .track-row:last-child {
  border-bottom: none;
}

.track-status {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 12px;
  font-size: 0.85rem;
  background: #f0e6e3;
  color: var(--primary-dark);
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 300;
  align-items: center;
  justify-content: center;
}

.modal.open {
  display: flex;
}

.modal-content {
  background: var(--white);
  padding: 2rem;
  border-radius: 12px;
  width: 90%;
  max-width: 450px;
  position: relative;
  max-height: 90vh;
  overflow-y: auto;
}

.product-modal-content {
  max-width: 900px;
  padding: 1.5rem;
}

.product-detail {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
}

.product-main-image {
  width: 100%;
  height: 400px;
  object-fit: cover;
  border-radius: 12px;
  background: #f0e6e3;
}

.product-thumbs {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
  flex-wrap: wrap;
}

.product-thumbs img {
  width: 70px;
  height: 70px;
  object-fit: cover;
  border-radius: 8px;
  cursor: pointer;
  border: 2px solid transparent;
}

.product-thumbs img.active {
  border-color: var(--primary-dark);
}

.product-detail-info h3 {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
}

.product-desc {
  color: var(--text-light);
  margin: 1rem 0;
  line-height: 1.7;
}

.option-group {
  margin-bottom: 1rem;
}

.option-group label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.option-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.option-pill {
  padding: 0.4rem 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--white);
  cursor: pointer;
  font-family: inherit;
  transition: all 0.2s;
}

.option-pill:hover {
  border-color: var(--primary);
}

.option-pill.active {
  background: var(--primary);
  color: var(--white);
  border-color: var(--primary);
}

.option-pill.disabled {
  opacity: 0.4;
  cursor: not-allowed;
  text-decoration: line-through;
}

.color-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}

.color-swatch {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid var(--border);
  cursor: pointer;
  flex-shrink: 0;
}

.color-swatch.active {
  border-color: var(--primary-dark);
  box-shadow: 0 0 0 2px var(--white), 0 0 0 4px var(--primary-dark);
}

.color-swatch.disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.stock-info {
  font-size: 0.9rem;
  margin-bottom: 1rem;
  color: var(--text-light);
}

.stock-info.low { color: #e65100; }
.stock-info.out { color: #c62828; }

.product-card {
  cursor: pointer;
}

.product-card .btn {
  position: relative;
  z-index: 1;
}

.modal-content h3 {
  margin-bottom: 1.5rem;
}

.modal-content input,
.modal-content textarea {
  width: 100%;
  padding: 0.75rem;
  margin-bottom: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
}

.modal-close {
  position: absolute;
  top: 1rem;
  left: 1rem;
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
}

/* Footer */
.footer {
  background: var(--white);
  padding: 2rem 0;
  text-align: center;
  color: var(--text-light);
  margin-top: 2rem;
}

/* Responsive */
@media (max-width: 768px) {
  .container {
    padding: 0 0.85rem;
  }

  .header-inner {
    padding: 0.65rem 0;
    gap: 0.5rem;
  }

  .logo {
    font-size: 1.25rem;
  }

  .nav {
    display: none;
  }

  .header-actions {
    gap: 0.4rem;
  }

  .account-btn,
  .cart-btn {
    padding: 0.45rem 0.6rem;
    font-size: 0.9rem;
    white-space: nowrap;
  }

  #accountLabel {
    max-width: 90px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .hero {
    padding: 2.5rem 0 2.25rem;
  }

  .hero p {
    font-size: 1rem;
  }

  .section {
    padding: 2rem 0;
  }

  .section-title {
    font-size: 1.4rem;
    margin-bottom: 1.25rem;
  }

  /* شبكتان للمنتجات بدل عمود واحد ضخم */
  .products-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
  }

  .product-image {
    height: 190px;
  }

  .product-image-placeholder {
    font-size: 2.5rem;
  }

  .product-info {
    padding: 0.7rem;
  }

  .product-name {
    font-size: 0.9rem;
    margin-bottom: 0.3rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .product-price {
    font-size: 1rem;
  }

  .product-card .btn {
    padding: 0.55rem 1rem;
    font-size: 0.85rem;
    width: 100%;
    text-align: center;
  }

  .categories-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
  }

  .category-card {
    padding: 1.15rem 0.75rem;
    min-height: 80px;
  }

  .category-card .cat-image {
    width: 60px;
    height: 60px;
  }

  .cart-sidebar {
    width: 100%;
    left: -100%;
  }

  /* المودالات كورقة سفلية بعرض كامل */
  .modal.open {
    align-items: flex-end;
  }

  .modal-content {
    width: 100%;
    max-width: none;
    border-radius: 16px 16px 0 0;
    padding: 1.25rem 1rem 1.5rem;
    max-height: 92dvh;
  }

  .modal-close {
    top: 0.75rem;
    left: 0.75rem;
    font-size: 1.75rem;
    padding: 0.25rem;
  }

  /* 16px تمنع تكبير iOS التلقائي عند التركيز */
  .modal-content input,
  .modal-content textarea,
  .modal-content select {
    font-size: 16px;
    padding: 0.7rem;
  }

  .product-detail {
    grid-template-columns: 1fr;
    gap: 1.25rem;
  }

  .product-main-image {
    height: 300px;
  }

  .product-thumbs img {
    width: 56px;
    height: 56px;
  }

  .account-stats {
    gap: 0.4rem;
  }

  .account-stat {
    padding: 0.5rem 0.35rem;
  }

  .account-stat strong {
    font-size: 0.85rem;
  }

  .my-orders-list {
    max-height: 45dvh;
  }

  .btn {
    padding: 0.7rem 1.5rem;
  }
}

@media (max-width: 380px) {
  .products-grid,
  .categories-grid {
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
  }

  .product-image {
    height: 165px;
  }

  #accountLabel {
    display: none;
  }
}
