@import url("https://fonts.googleapis.com/css2?family=Cairo:wght@400;500;600;700&family=Tajawal:wght@400;500;700;800&display=swap");

:root {
  /* 70% White / Background */
  --color-background: #ffffff;
  --color-surface: #f8f9fa;
  --color-surface-hover: #f1f3f5;
  --color-border: #e9ecef;

  /* 20% Orange / Action */
  --color-primary: #ef9d51;
  --color-primary-hover: #e08b40;

  /* 10% Blue / Accents & Text */
  --color-accent-dark: #404998;
  --color-accent-light: #c0dbf0;

  /* Text */
  --color-text-main: #1a1a2e;
  --color-text-muted: #6b7280;

  /* Status Colors */
  --color-success: #10b981;
  --color-warning: #f59e0b;
  --color-danger: #ef4444;

  /* Typography (Arabic) */
  --font-display: "Tajawal", sans-serif;
  --font-body: "Cairo", sans-serif;

  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md:
    0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg:
    0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);

  /* Transitions */
  --transition-fast: 150ms ease-in-out;
  --transition-normal: 250ms ease-in-out;

  /* Radius */
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-full: 9999px;
}

/* Reset */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-body);
  background-color: var(--color-background);
  color: var(--color-text-main);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* Hide native Edge password reveal icon */
input::-ms-reveal,
input::-ms-clear {
  display: none;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.3;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  cursor: pointer;
  border: none;
  background: none;
  font-family: inherit;
}

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

/* Layout Utilities */
.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

.flex {
  display: flex;
}
.flex-col {
  flex-direction: column;
}
.items-center {
  align-items: center;
}
.justify-between {
  justify-content: space-between;
}
.justify-center {
  justify-content: center;
}
.gap-1 {
  gap: 0.25rem;
}
.gap-2 {
  gap: 0.5rem;
}
.gap-3 {
  gap: 0.75rem;
}
.gap-4 {
  gap: 1rem;
}
.gap-6 {
  gap: 1.5rem;
}
.gap-8 {
  gap: 2rem;
}
.items-start {
  align-items: flex-start;
}
.mt-6 {
  margin-top: 1.5rem;
}
.mb-6 {
  margin-bottom: 1.5rem;
}

.grid {
  display: grid;
}
.grid-cols-2 {
  grid-template-columns: repeat(2, 1fr);
}
.grid-cols-3 {
  grid-template-columns: repeat(3, 1fr);
}
.grid-cols-4 {
  grid-template-columns: repeat(4, 1fr);
}

.mt-2 {
  margin-top: 0.5rem;
}
.mt-4 {
  margin-top: 1rem;
}
.mb-2 {
  margin-bottom: 0.5rem;
}
.mb-4 {
  margin-bottom: 1rem;
}

/* Components */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1.75rem;
  border-radius: var(--radius-full);
  font-weight: 600;
  transition: all var(--transition-fast);
  font-family: var(--font-body);
}

button:active,
.btn:active,
.remove-btn:active,
.color-btn:active,
.size-btn:active,
.product-thumbnail:active {
  transform: scale(0.92) !important;
  opacity: 0.8;
  transition:
    transform 0.1s ease,
    opacity 0.1s ease !important;
}

button:disabled,
.btn:disabled {
  opacity: 0.5 !important;
  cursor: not-allowed !important;
  transform: none !important;
  box-shadow: none !important;
}

.btn-primary {
  background-color: var(--color-primary);
  color: white;
}

.btn-primary:hover {
  background-color: var(--color-primary-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn-outline {
  border: 1.5px solid var(--color-accent-dark);
  color: var(--color-accent-dark);
}

.btn-outline:hover {
  background-color: var(--color-accent-dark);
  color: white;
}

.btn-danger {
  color: var(--color-danger);
  background: rgba(239, 68, 68, 0.1);
  padding: 0.5rem;
  border-radius: var(--radius-md);
}
.btn-danger:hover {
  background: var(--color-danger);
  color: white;
}

/* Navbar */
.navbar {
  border-bottom: 1px solid var(--color-border);
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 50;
}

.navbar .container {
  height: 4.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Logo Placeholder */
.brand-logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.5rem;
  color: var(--color-accent-dark);
}
.logo-circle {
  width: 40px;
  height: 40px;
  background-color: var(--color-accent-dark);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  font-family: Arial, sans-serif;
  font-weight: bold;
}

.nav-links {
  display: flex;
  gap: 2rem;
}

.nav-links a {
  font-weight: 600;
  color: var(--color-text-main);
  transition: color var(--transition-fast);
  font-size: 0.95rem;
}

.nav-links a:hover,
.nav-links a.active {
  color: var(--color-primary);
}

.nav-icons {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.nav-icons a {
  color: var(--color-text-muted);
  transition: color var(--transition-fast);
  display: flex;
}

.nav-icons a:hover {
  color: var(--color-accent-dark);
}

.nav-icons svg {
  width: 24px;
  height: 24px;
  fill: currentColor;
}

.cart-count {
  position: absolute;
  top: -6px;
  right: -8px;
  background-color: var(--color-primary);
  color: white;
  font-size: 0.75rem;
  font-weight: bold;
  font-family: Arial, sans-serif;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  border: 2px solid var(--color-background);
  line-height: 1;
  pointer-events: none;
}

.menu-toggle {
  display: none;
  background: none;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 0.25rem;
  cursor: pointer;
}
.menu-toggle svg {
  width: 28px;
  height: 28px;
  fill: var(--color-text-main);
}

/* Floating WhatsApp Button */
.whatsapp-float {
  position: fixed;
  bottom: 2rem;
  right: auto;
  left: 2rem; /* Left side for RTL */
  background-color: #25d366;
  color: white;
  width: 60px;
  height: 60px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-lg);
  z-index: 100;
  transition: transform var(--transition-fast);
}

.whatsapp-float:hover {
  transform: scale(1.1);
}

.whatsapp-float svg {
  width: 32px;
  height: 32px;
  fill: currentColor;
}

/* Cards */
.card {
  background: white;
  border-radius: var(--radius-xl);
  overflow: hidden;
  border: 1px solid var(--color-border);
  transition:
    transform var(--transition-normal),
    box-shadow var(--transition-normal);
}

.card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
}

/* Product Card Fixes */
.product-card {
  padding: 1rem;
  display: flex;
  flex-direction: column;
}
.product-card .img-wrapper {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  margin-bottom: 1rem;
  padding: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1/1; /* FIX 1: Uniform sizing */
  overflow: hidden;
}
.product-card img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  transition: transform var(--transition-fast);
}
.product-card:hover img {
  transform: scale(1.08) rotate(-5deg);
}

/* Badge */
.badge {
  padding: 0.25rem 0.75rem;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

/* Form Elements */
.input {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 1rem;
  transition: border-color var(--transition-fast);
}

.input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(239, 157, 81, 0.1);
}

.label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.5rem;
  font-size: 0.875rem;
}

/* Toast Notification for Add to Cart */
.toast-container {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  background: white;
  border-left: 4px solid var(--color-success); /* Actually border-right in RTL, handled inline or flipped */
  padding: 1rem 1.5rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 1rem;
  font-weight: 600;
  animation: slideIn 0.3s ease-out forwards;
}
html[dir="rtl"] .toast {
  border-left: none;
  border-right: 4px solid var(--color-success);
}

@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}
@keyframes fadeOut {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
    transform: translateY(10px);
  }
}

/* Badges */
.badge-bestseller {
  background: #e0e7ff;
  color: #3730a3;
}
.badge-sale {
  background: #fee2e2;
  color: #991b1b;
}
.badge-new {
  background: #fff7ed;
  color: #c2410c;
}
.badge-limited {
  background: #fef3c7;
  color: #b45309;
}

/* Product Extensions */
.product-card .img-wrapper {
  position: relative;
}
.product-card .badge {
  position: absolute;
  top: 1rem;
  right: 1rem;
  z-index: 10;
}
.product-rating {
  font-size: 0.875rem;
  color: var(--color-text-muted);
  margin-bottom: 0.25rem;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}
.product-rating svg {
  width: 14px;
  height: 14px;
  fill: var(--color-warning);
}
.product-old-price {
  text-decoration: line-through;
  color: var(--color-text-muted);
  font-size: 0.875rem;
  margin-right: 0.5rem;
}
.section-subtitle {
  text-align: center;
  color: var(--color-text-muted);
  margin-top: 0;
  margin-bottom: 3rem;
}

/* Promo Banner */
.promo-banner {
  background-color: var(--color-accent-dark);
  color: white;
  border-radius: var(--radius-xl);
  padding: 4rem 2rem;
  text-align: center;
  margin: 4rem 0;
  position: relative;
  overflow: hidden;
}
.promo-banner h2 {
  font-size: 2.5rem;
  margin-bottom: 1rem;
}
.promo-banner p {
  color: var(--color-accent-light);
  margin-bottom: 2rem;
}

/* =============================================
   RESPONSIVE DESIGN — TABLET (max-width: 768px)
   ============================================= */
@media (max-width: 768px) {
  /* --- General Typography --- */
  h1 {
    font-size: 1.75rem;
  }
  h2 {
    font-size: 1.5rem;
  }

  /* --- Navbar --- */
  .navbar .container {
    flex-wrap: wrap;
    height: auto;
    padding-top: 0.75rem;
    padding-bottom: 0.75rem;
    gap: 0.5rem;
  }

  .nav-links {
    order: 3;
    width: 100%;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
    font-size: 0.875rem;
    border-top: 1px solid var(--color-border);
    padding-top: 0.5rem;
  }

  /* --- Hero Section --- */
  .hero .container {
    grid-template-columns: 1fr;
    gap: 2rem;
    text-align: center;
  }

  .hero .container h1 {
    font-size: 1.75rem;
  }

  .hero .hero-image,
  .hero .container > *:last-child img {
    max-width: 80%;
    margin: 0 auto;
  }

  /* --- Product Grid --- */
  .product-grid {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1rem;
  }

  /* --- Catalog Layout --- */
  .catalog-layout {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }

  /* --- Product Details --- */
  .product-details {
    grid-template-columns: 1fr;
    gap: 2rem;
  }

  /* --- Checkout Layout --- */
  .checkout-layout {
    grid-template-columns: 1fr;
    gap: 2rem;
  }

  .checkout-layout > .order-summary,
  .checkout-layout > *:last-child {
    order: -1;
  }

  /* --- Profile Layout --- */
  .profile-layout {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }

  /* --- Admin Layout --- */
  .admin-layout {
    grid-template-columns: 1fr;
  }

  .admin-layout > aside,
  .admin-layout .admin-sidebar {
    position: static;
    width: 100%;
    height: auto;
    border-radius: 0;
    display: flex;
    flex-direction: column;
    padding: 1rem;
    border-bottom: 1px solid var(--color-border);
    border-left: none;
  }

  .admin-logo {
    margin-bottom: 1.5rem;
  }

  .admin-nav {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .admin-layout > aside a,
  .admin-layout .admin-sidebar a {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    flex: 1 1 auto;
    justify-content: center;
  }

  .nav-item.logout {
    margin-top: 1rem;
    width: 100%;
    justify-content: center;
  }

  /* --- Stats Grid --- */
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
  }

  /* --- Auth Container --- */
  .auth-container {
    margin: 1.5rem auto;
    padding: 1.5rem;
  }

  /* --- Promo Banner --- */
  .promo-banner {
    padding: 2.5rem 1.5rem;
    margin: 2rem 0;
  }

  .promo-banner h2 {
    font-size: 1.75rem;
  }

  /* --- Grid Utility Overrides --- */
  .grid-cols-4 {
    grid-template-columns: repeat(2, 1fr);
  }

  .grid-cols-3 {
    grid-template-columns: repeat(2, 1fr);
  }

  /* --- Container Padding --- */
  .container {
    padding: 0 1rem;
  }

  /* --- Section Subtitle --- */
  .section-subtitle {
    margin-bottom: 2rem;
  }

  /* --- WhatsApp Float (smaller on tablet) --- */
  .whatsapp-float {
    width: 50px;
    height: 50px;
    bottom: 1.5rem;
    left: 1.5rem;
  }

  .whatsapp-float svg {
    width: 26px;
    height: 26px;
  }

  /* --- Toast --- */
  .toast-container {
    right: 1rem;
    left: 1rem;
    bottom: 1rem;
  }
  /* --- Navbar Mobile Drawer --- */
  .navbar .container.figma-nav {
    flex-wrap: nowrap;
    justify-content: space-between;
    height: 4.5rem;
    padding: 0 1rem;
  }
  .menu-toggle {
    display: block;
  }
  .nav-icons {
    gap: 1rem;
  }
  .nav-links {
    display: none;
    position: absolute;
    top: 4.5rem;
    left: 0;
    right: 0;
    background: white;
    flex-direction: column;
    width: 100%;
    padding: 1.5rem;
    border-bottom: 1px solid var(--color-border);
    box-shadow: var(--shadow-md);
    gap: 1.5rem;
    order: unset;
    margin-top: 0;
    border-top: none;
  }
  .nav-links.active {
    display: flex;
  }
  .nav-links a {
    font-size: 1.1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--color-surface);
  }
}

/* =============================================
   RESPONSIVE DESIGN — PHONE (max-width: 480px)
   ============================================= */
@media (max-width: 480px) {
  /* --- General Typography --- */
  h1 {
    font-size: 1.4rem;
  }
  h2 {
    font-size: 1.25rem;
  }
  h3 {
    font-size: 1.1rem;
  }

  body {
    font-size: 0.9rem;
  }

  /* --- Hero Section --- */
  .hero .container h1 {
    font-size: 1.4rem;
  }

  .hero .hero-image,
  .hero .container > *:last-child img {
    max-width: 100%;
  }

  /* --- Product Grid --- */
  .product-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 0.75rem;
  }

  .product-card {
    padding: 0.75rem;
  }

  .product-card .img-wrapper {
    padding: 1rem;
  }

  .product-card .badge {
    top: 0.5rem;
    right: 0.5rem;
    font-size: 0.65rem;
    padding: 0.2rem 0.5rem;
  }

  /* --- Catalog Layout --- */
  .catalog-layout {
    gap: 1rem;
  }

  /* --- Product Details --- */
  .product-details {
    gap: 1.5rem;
  }

  /* --- Checkout Layout --- */
  .checkout-layout {
    gap: 1.5rem;
  }

  /* --- Stats Grid --- */
  .stats-grid {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  /* --- Grid Utility Overrides --- */
  .grid-cols-4,
  .grid-cols-3,
  .grid-cols-2 {
    grid-template-columns: 1fr;
  }

  /* --- Auth Container --- */
  .auth-container {
    margin: 1rem;
    padding: 1.25rem;
  }

  /* --- Promo Banner --- */
  .promo-banner {
    padding: 2rem 1rem;
    margin: 1.5rem 0;
    border-radius: var(--radius-lg);
  }

  .promo-banner h2 {
    font-size: 1.4rem;
    margin-bottom: 0.75rem;
  }

  .promo-banner p {
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
  }

  /* --- Buttons --- */
  .btn {
    padding: 0.6rem 1.25rem;
    font-size: 0.875rem;
  }

  /* --- Container Padding --- */
  .container {
    padding: 0 0.75rem;
  }

  /* --- WhatsApp Float (phone) --- */
  .whatsapp-float {
    width: 46px;
    height: 46px;
    bottom: 1rem;
    left: 1rem;
  }

  .whatsapp-float svg {
    width: 24px;
    height: 24px;
  }

  /* --- Toast --- */
  .toast {
    font-size: 0.85rem;
    padding: 0.75rem 1rem;
  }

  /* --- Form Elements --- */
  .input {
    padding: 0.6rem 0.85rem;
    font-size: 0.9rem;
  }
}

/* --- Navbar Search --- */
.search-container {
  position: relative;
  display: flex;
  align-items: center;
}
.search-box {
  position: absolute;
  top: 50%;
  right: 0;
  transform: translateY(-50%) scaleX(0);
  transform-origin: right center;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s ease;
  z-index: 100;
  display: flex;
  align-items: center;
  background: white;
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-md);
  padding: 0.25rem 1rem;
  width: 400px;
  border: 1px solid var(--color-border);
}
[dir="rtl"] .search-box {
  right: auto;
  left: 0;
  transform-origin: left center;
}
.search-box.active {
  transform: translateY(-50%) scaleX(1);
  opacity: 1;
  pointer-events: auto;
}
.search-box input {
  border: none;
  outline: none;
  width: 100%;
  padding: 0.75rem 0;
  font-family: inherit;
  font-size: 1rem;
  background: transparent;
}
.search-results {
  position: absolute;
  top: 120%;
  right: 0;
  width: 100%;
  background: white;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  max-height: 400px;
  overflow-y: auto;
  display: none;
  flex-direction: column;
  z-index: 101;
  border: 1px solid var(--color-border);
}
.search-results.active {
  display: flex;
}
.search-result-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  text-decoration: none;
  color: var(--color-text-main);
  border-bottom: 1px solid var(--color-border);
  transition: background 0.2s;
}
.search-result-item:last-child {
  border-bottom: none;
}
.search-result-item:hover {
  background: var(--color-surface);
}
.search-result-img {
  width: 50px;
  height: 50px;
  object-fit: cover;
  border-radius: var(--radius-md);
}
.search-result-info {
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.search-result-name {
  font-weight: 600;
  font-size: 1rem;
  margin-bottom: 0.25rem;
}
.search-result-price {
  color: var(--color-accent-dark);
  font-size: 0.875rem;
  font-weight: bold;
}
@media (max-width: 768px) {
  .search-box,
  [dir="rtl"] .search-box {
    position: fixed;
    top: 60px;
    left: 10px;
    right: 10px;
    width: auto;
    transform: translateY(-20px);
    transform-origin: top center;
  }
  .search-box.active {
    transform: translateY(0);
  }
}
