/*
==================================================
PRODUCTS DISPLAY STYLES - CLEAN ARCHITECTURE
==================================================
Structure:
1. CSS Variables & Configuration
2. Base Styles
3. Layout Components
4. UI Components
5. State Variations
6. Responsive Design
7. Animations & Transitions
==================================================
*/

/* ===========================================
   1. CSS VARIABLES & CONFIGURATION
   =========================================== */
:root {
  /* Colors */
  --primary-color: #28a745;
  --primary-dark: #065017;
  --primary-darker: #004085;
  --success-color: #28a745;
  --success-dark: #218838;
  --warning-color: #f39c12;
  --text-primary: #1c1c1c;
  --text-secondary: #444;
  --text-muted: #666;
  --text-light: #777;
  --background-primary: #f9f9f9;
  --surface: #ffffff;
  --border-light: rgba(0, 123, 255, 0.1);
  --shadow-light: rgba(0, 0, 0, 0.08);
  --shadow-medium: rgba(0, 123, 255, 0.15);
  --shadow-strong: rgba(0, 123, 255, 0.3);

  /* Typography */
  --font-family: "Cairo", sans-serif;
  --font-size-xs: 14px;
  --font-size-sm: 15px;
  --font-size-base: 16px;
  --font-size-lg: 18px;
  --font-size-xl: 20px;
  --font-size-2xl: 22px;
  --font-size-3xl: 28px;
  --font-size-4xl: 32px;
  --font-weight-normal: 400;
  --font-weight-medium: 600;
  --font-weight-bold: 700;
  --line-height-base: 1.6;
  --line-height-tight: 1.3;

  /* Spacing */
  --spacing-xs: 5px;
  --spacing-sm: 8px;
  --spacing-base: 15px;
  --spacing-md: 20px;
  --spacing-lg: 25px;
  --spacing-xl: 30px;
  --spacing-2xl: 40px;

  /* Border Radius */
  --radius-sm: 8px;
  --radius-base: 12px;
  --radius-lg: 16px;
  --radius-xl: 25px;
  --radius-full: 50%;

  /* Transitions */
  --transition-fast: 0.2s ease;
  --transition-base: 0.3s ease;
  --transition-slow: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-bounce: 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55);

  /* Layout */
  --container-max-width: 1400px;
  --grid-gap: var(--spacing-lg);
  --grid-min-width: 300px;
  --card-padding: var(--spacing-md);
  --image-height: 240px;
  --image-height-mobile: 200px;
}

/* ===========================================
     2. BASE STYLES
     =========================================== */
body {
  font-family: var(--font-family);
  background-color: var(--background-primary);
  margin: 0;
  padding: var(--spacing-md);
  direction: ltr;
  text-align: right;
  line-height: var(--line-height-base);
  min-height: 100vh;
}

/* Reset for better consistency */
*,
*::before,
*::after {
  box-sizing: border-box;
}

/* ===========================================
    3. LAYOUT COMPONENTS
     =========================================== */

/* Section Title */
.section-title {
  font-size: var(--font-size-4xl);
  font-weight: var(--font-weight-bold);
  margin-bottom: var(--spacing-xl);
  color: var(--text-secondary);
  text-align: center;
  position: relative;
  padding-bottom: var(--spacing-base);
}

.section-title::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 80px;
  height: 4px;
  background: linear-gradient(
    135deg,
    var(--primary-color),
    var(--primary-dark)
  );
  border-radius: 2px;
}

/* Products Container Grid */
.products-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(var(--grid-min-width), 1fr));
  gap: var(--grid-gap);
  max-width: var(--container-max-width);
  margin: 0 auto;
  padding: var(--spacing-md) 0;
}

/* ===========================================
     4. UI COMPONENTS
     =========================================== */

/* Product Card */
.product-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 25px var(--shadow-light);
  position: relative;
  overflow: hidden;
  border: 1px solid var(--border-light);
  transition: all var(--transition-slow);
  cursor: pointer;
  animation: fadeInUp 0.6s ease forwards;
}

/* Card Top Border Effect */
.product-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(
    135deg,
    var(--primary-color),
    var(--primary-dark)
  );
  transform: scaleX(0);
  transition: transform var(--transition-slow);
  z-index: 1;
}

/* Product Image */
.product-img {
  width: 100%;
  height: var(--image-height);
  object-fit: cover;
  border-radius: 0;
  margin-bottom: 0;
  transition: transform var(--transition-slow);
  display: block;
  background: linear-gradient(45deg, #f0f0f0, #e0e0e0);
}

/* Product Content Spacing */
.product-card > *:not(.product-img) {
  padding-left: var(--card-padding);
  padding-right: var(--card-padding);
}

.product-card > .product-img + * {
  padding-top: var(--card-padding);
}

.product-card > *:last-child {
  padding-bottom: var(--card-padding);
}

/* Product Title */
.product-card h3 {
  margin: 0 0 var(--spacing-base) 0;
  color: var(--text-primary);
  font-size: var(--font-size-2xl);
  font-weight: var(--font-weight-bold);
  line-height: var(--line-height-tight);
  transition: color var(--transition-base);
}

/* Product Details Paragraphs */
.product-card p {
  margin: var(--spacing-sm) 0;
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  transition: color var(--transition-base);
  position: relative;
}

.product-card p strong {
  color: var(--text-secondary);
  font-weight: var(--font-weight-medium);
  min-width: 80px;
  display: inline-block;
}

/* Product Details Icons */
.product-card p::before {
  content: "";
  width: 6px;
  height: 6px;
  background: var(--primary-color);
  border-radius: var(--radius-full);
  margin-left: var(--spacing-xs);
  opacity: 0.6;
  transition: opacity var(--transition-base);
  flex-shrink: 0;
}

/* Product Button */
.product-card button {
  margin-top: var(--spacing-md);
  background: linear-gradient(
    135deg,
    var(--primary-color),
    var(--primary-dark)
  );
  color: var(--surface);
  border: none;
  padding: 12px 24px;
  border-radius: var(--radius-xl);
  cursor: pointer;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  font-family: var(--font-family);
  transition: all var(--transition-slow);
  position: relative;
  overflow: hidden;
  width: 100%;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Button Shine Effect */
.product-card button::before {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.2), transparent);
  transition: left 0.5s ease;
}

/* ===========================================
     5. STATE VARIATIONS
     =========================================== */

/* Hover States */
.product-card:hover {
  transform: translateY(-8px) scale(1.02);
  box-shadow: 0 20px 40px var(--shadow-medium);
  border-color: rgba(0, 123, 255, 0.3);
}

.product-card:hover::before {
  transform: scaleX(1);
}

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

.product-card:hover h3 {
  color: var(--primary-color);
}

.product-card:hover p {
  color: var(--text-secondary);
}

.product-card:hover p::before {
  opacity: 1;
}

/* Button Hover States */
.product-card button:hover {
  background: linear-gradient(
    135deg,
    var(--primary-dark),
    var(--primary-darker)
  );
  transform: translateY(-2px);
  box-shadow: 0 8px 20px var(--shadow-strong);
}

.product-card button:hover::before {
  left: 100%;
}

/* Active States */
.product-card button:active {
  transform: translateY(0);
  box-shadow: 0 4px 10px rgba(0, 123, 255, 0.2);
}

/* Focus States */
.product-card button:focus {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

.product-card:focus-within {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

/* Loading State */
.products-container.loading {
  opacity: 0.7;
  pointer-events: none;
}

/* Empty & Error States */
.products-container p {
  grid-column: 1 / -1;
  text-align: center;
  font-size: var(--font-size-lg);
  color: var(--text-muted);
  padding: var(--spacing-2xl) var(--spacing-md);
  background: var(--surface);
  border-radius: var(--radius-base);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.products-container p[style*="color:red"] {
  color: #dc3545 !important;
  border-left: 4px solid #dc3545;
  padding-left: var(--spacing-md);
  background: #f8f9fa;
}

/* ===========================================
     6. RESPONSIVE DESIGN
     =========================================== */

/* Tablet */
@media (max-width: 768px) {
  :root {
    --grid-min-width: 280px;
    --image-height: var(--image-height-mobile);
  }

  body {
    padding: var(--spacing-base);
  }

  .section-title {
    font-size: var(--font-size-3xl);
    margin-bottom: var(--spacing-md);
  }

  .products-container {
    gap: var(--spacing-md);
  }

  .product-card {
    border-radius: var(--radius-base);
  }

  .product-card h3 {
    font-size: var(--font-size-xl);
  }

  .product-card p {
    font-size: var(--font-size-xs);
  }

  .product-card button {
    padding: 10px 20px;
    font-size: var(--font-size-xs);
  }
}

/* Mobile */
@media (max-width: 480px) {
  :root {
    --image-height: 180px;
  }

  .products-container {
    grid-template-columns: 1fr;
    gap: var(--spacing-base);
  }

  .section-title {
    font-size: 24px;
  }
}

/* ===========================================
     7. ANIMATIONS & TRANSITIONS
     =========================================== */

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

/* Staggered Animation Delays */
.product-card:nth-child(1) {
  animation-delay: 0.1s;
}
.product-card:nth-child(2) {
  animation-delay: 0.2s;
}
.product-card:nth-child(3) {
  animation-delay: 0.3s;
}
.product-card:nth-child(4) {
  animation-delay: 0.4s;
}
.product-card:nth-child(5) {
  animation-delay: 0.5s;
}
.product-card:nth-child(6) {
  animation-delay: 0.6s;
}

/* ===========================================
      8. LTR SPECIFIC ADJUSTMENTS
  =========================================== */

[dir="ltr"] .product-card {
  direction: ltr;
  text-align: left;
}

[dir="ltr"] .product-card p {
  display: flex;
  flex-direction: row;
  align-items: center;
  text-align: left;
}

[dir="ltr"] .product-card p::before {
  margin-left: 0;
  margin-right: var(--spacing-xs);
}



/* ===========================================
      9. UTILITY CLASSES
  =========================================== */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.no-scroll {
  overflow: hidden;
}

.fade-in {
  animation: fadeInUp 0.6s ease forwards;
}

/* ===========================================
     10. PERFORMANCE OPTIMIZATIONS
     =========================================== */

.product-card {
  contain: layout style paint;
  will-change: transform;
}

.product-img {
  will-change: transform;
}
