/* ========== CSS VARIABLES - Easy to customize per client ========== */
:root {
  --bg-primary: #0D0D0D;
  --bg-secondary: #1A1A1A;
  --bg-card: #1E1E1E;
  --text-primary: #FFFFFF;
  --text-secondary: #AAAAAA;
  --accent-blue: #2196F3;
  --accent-orange: #FF6B35;
  --badge-green: #4CAF50;
  --badge-red: #F44336;
  --badge-grey: #666666;
  --radius-card: 14px;
  --radius-badge: 20px;
  --font-family: 'Cairo', sans-serif;
  --bottom-nav-height: 60px;
}

/* ========== RESET & BASE ========== */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-family);
  background: var(--bg-primary);
  color: var(--text-primary);
  direction: rtl;
  min-height: 100vh;
  padding-bottom: calc(var(--bottom-nav-height) + 16px);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

.page-container {
  max-width: 1280px;
  margin: 0 auto;
  width: 100%;
}

img {
  display: block;
  max-width: 100%;
}

a {
  color: var(--accent-blue);
  text-decoration: none;
}

/* ========== HEADER ========== */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-primary);
  padding: 16px 16px 8px;
  text-align: center;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  max-width: 1280px;
  margin: 0 auto;
}

.store-logo {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255,255,255,0.1);
}

.store-name {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.store-subtitle {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* ========== CATEGORY NAV ========== */
.category-nav {
  display: flex;
  gap: 0;
  overflow-x: auto;
  padding: 12px 16px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  position: sticky;
  top: 85px;
  z-index: 90;
  background: var(--bg-primary);
  max-width: 1280px;
  margin: 0 auto;
}

.category-nav::-webkit-scrollbar {
  display: none;
}

.category-nav-item {
  flex-shrink: 0;
  padding: 8px 18px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  border-radius: 24px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: var(--font-family);
  white-space: nowrap;
}

.category-nav-item.active {
  background: var(--accent-blue);
  color: #fff;
}

/* ========== MENU SECTIONS ========== */
.menu-sections {
  padding: 0 0 24px;
  max-width: 1280px;
  margin: 0 auto;
}

.category-section {
  margin-bottom: 28px;
}

/* Section Header */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 12px;
}

.section-title {
  font-size: 1.2rem;
  font-weight: 700;
}

.section-more {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--accent-blue);
  cursor: pointer;
  background: none;
  border: none;
  font-family: var(--font-family);
}

.section-more svg {
  width: 16px;
  height: 16px;
}

/* ========== CAROUSEL ========== */
.carousel-wrapper {
  position: relative;
}

.carousel-track {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding: 0 16px 4px;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.carousel-track::-webkit-scrollbar {
  display: none;
}

/* Dots */
.carousel-dots {
  display: flex;
  justify-content: center;
  gap: 6px;
  padding: 12px 0 4px;
}

.carousel-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  border: none;
  padding: 0;
  cursor: pointer;
  transition: all 0.3s ease;
}

.carousel-dot.active {
  background: var(--accent-blue);
  width: 7px;
}

/* ========== PRODUCT CARD ========== */
.product-card {
  flex-shrink: 0;
  width: 170px;
  scroll-snap-align: start;
  cursor: pointer;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
  position: relative;
}

.product-card:active {
  transform: scale(0.97);
}

.product-card:hover {
  transform: translateY(-4px);
}

.product-card:hover .card-image-wrapper img {
  transform: scale(1.05);
}

.card-image-wrapper {
  width: 100%;
  height: 160px;
  border-radius: var(--radius-card);
  overflow: hidden;
  position: relative;
}

.card-image-wrapper img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

/* Unavailable overlay */
.product-card.unavailable .card-image-wrapper::after {
  content: 'غير متوفر';
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
  color: #fff;
  font-family: var(--font-family);
}

/* Badge */
.card-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 3px 10px;
  border-radius: var(--radius-badge);
  font-size: 0.7rem;
  font-weight: 700;
  z-index: 2;
}

.card-badge.new {
  background: var(--badge-green);
  color: #fff;
}

.card-badge.unavail {
  background: var(--badge-grey);
  color: #fff;
}

/* Card info */
.card-info {
  padding: 8px 4px 0;
}

.card-name {
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.3;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-price {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--accent-blue);
  margin-top: 2px;
}

/* ========== GRID VIEW ========== */
.menu-sections.grid-view .carousel-wrapper {
  display: none;
}

.grid-container {
  display: none;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  padding: 0 16px;
}

.menu-sections.grid-view .grid-container {
  display: grid;
}

.menu-sections.grid-view .carousel-dots {
  display: none;
}

.grid-container .product-card {
  width: 100%;
}

.grid-container .card-image-wrapper {
  height: 140px;
}

/* ========== EXPANDED CATEGORY VIEW ========== */
.category-section.expanded .carousel-wrapper {
  display: none;
}

.category-section.expanded .carousel-dots {
  display: none;
}

.category-section.expanded .grid-container {
  display: grid;
}

/* ========== BOTTOM NAVIGATION ========== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--bottom-nav-height);
  background: var(--bg-secondary);
  border-top: 1px solid rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  justify-content: space-around;
  z-index: 200;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.nav-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  padding: 8px;
  cursor: pointer;
  border-radius: 12px;
  transition: all 0.2s ease;
}

.nav-btn:active,
.nav-btn.active {
  color: var(--accent-blue);
}

/* ========== MODAL ========== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.modal-overlay.show {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  background: var(--bg-secondary);
  border-radius: 20px;
  width: 100%;
  max-width: 360px;
  overflow: hidden;
  transform: translateY(30px);
  transition: transform 0.25s ease;
}

.modal-overlay.show .modal-content {
  transform: translateY(0);
}

.modal-close {
  position: absolute;
  top: 12px;
  left: 12px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(0,0,0,0.5);
  color: #fff;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-image {
  width: 100%;
  height: 280px;
  object-fit: cover;
}

.modal-info {
  padding: 20px;
}

.modal-name {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 6px;
}

.modal-price {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--accent-blue);
}

.modal-badges {
  margin-top: 10px;
  display: flex;
  gap: 8px;
}

/* ========== FOOTER ========== */
.footer {
  text-align: center;
  padding: 24px 16px;
  font-size: 0.78rem;
  color: var(--text-secondary);
  max-width: 1280px;
  margin: 0 auto;
  border-top: 1px solid rgba(255,255,255,0.06);
}

.footer a {
  color: var(--accent-blue);
  font-weight: 600;
}

/* ========== ANIMATIONS ========== */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.category-section {
  animation: fadeInUp 0.4s ease both;
  scroll-margin-top: 140px;
}

.category-section:nth-child(2) { animation-delay: 0.06s; }
.category-section:nth-child(3) { animation-delay: 0.12s; }
.category-section:nth-child(4) { animation-delay: 0.18s; }
.category-section:nth-child(5) { animation-delay: 0.24s; }

/* ========== DESKTOP: Show grid by default ========== */
@media (min-width: 900px) {
  .carousel-wrapper {
    display: none !important;
  }
  .carousel-dots {
    display: none !important;
  }
  .grid-container {
    display: grid !important;
  }
  .section-more {
    display: none;
  }
}

/* ========== RESPONSIVE ========== */

/* Small phones */
@media (max-width: 360px) {
  .product-card { width: 150px; }
  .card-image-wrapper { height: 140px; }
  .section-title { font-size: 1.05rem; }
  .store-name { font-size: 1.15rem; }
}

/* Large phones */
@media (min-width: 414px) {
  .product-card { width: 185px; }
  .card-image-wrapper { height: 170px; }
  .grid-container { grid-template-columns: repeat(2, 1fr); }
}

/* Tablets */
@media (min-width: 768px) {
  .product-card { width: 210px; }
  .card-image-wrapper { height: 190px; }
  .grid-container { grid-template-columns: repeat(3, 1fr); gap: 18px; }
  .store-name { font-size: 1.6rem; }
  .store-logo { width: 56px; height: 56px; }
  .section-title { font-size: 1.35rem; }
  .menu-sections { padding: 0 16px 24px; }
  .card-name { font-size: 0.92rem; }
  .card-price { font-size: 1rem; }
  .category-nav-item { padding: 10px 22px; font-size: 0.9rem; }
  .category-nav { justify-content: center; padding: 14px 24px; }
}

/* Desktop */
@media (min-width: 1024px) {
  body {
    padding-bottom: 24px;
  }
  .bottom-nav {
    display: none;
  }
  .header {
    padding: 20px 32px 10px;
  }
  .store-logo { width: 64px; height: 64px; }
  .store-name { font-size: 1.8rem; }
  .store-subtitle { font-size: 0.9rem; }
  .menu-sections { padding: 0 32px 40px; }
  .section-header { padding: 24px 0 16px; }
  .section-title { font-size: 1.5rem; }
  .grid-container { grid-template-columns: repeat(4, 1fr); gap: 20px; padding: 0; }
  .card-image-wrapper { height: 200px; }
  .grid-container .card-image-wrapper { height: 200px; }
  .card-name { font-size: 0.95rem; }
  .card-price { font-size: 1.05rem; }
  .card-info { padding: 10px 6px 0; }
  .modal-content { max-width: 500px; }
  .modal-image { height: 350px; }
  .modal-name { font-size: 1.4rem; }
  .modal-price { font-size: 1.5rem; }
  .category-nav { padding: 16px 32px; gap: 4px; }
  .category-nav-item { padding: 10px 28px; font-size: 0.95rem; }
  .footer { padding: 32px 16px; font-size: 0.85rem; }
}

/* Large Desktop */
@media (min-width: 1400px) {
  .grid-container { grid-template-columns: repeat(5, 1fr); gap: 24px; }
  .card-image-wrapper { height: 220px; }
  .grid-container .card-image-wrapper { height: 220px; }
}

/* ========== LOADING SKELETON ========== */
.skeleton {
  background: linear-gradient(110deg, #1E1E1E 8%, #2A2A2A 18%, #1E1E1E 33%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-card);
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
