@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap');

:root {
  --bg: #f9f9f9;
  --card: #ffffff;
  --accent: #5a67d8;
  --dark: #2d3748;
  --muted: #a0aec0;
  --border-color: #e2e8f0;
  --shadow-light: rgba(0, 0, 0, 0.05);
  --shadow-medium: rgba(0, 0, 0, 0.1);
  --welcome-bg: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --welcome-text: #ffffff;
  --scroll-bg: #f0f0f0;
  --scroll-item-bg: #ffffff;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Poppins', sans-serif;
  background: var(--bg);
  color: var(--dark);
  -webkit-font-smoothing: antialiased;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  background: var(--dark);
  color: #fff;
  border-bottom: 1px solid var(--border-color);

  position: sticky;
  top: 0;
  left: 0;
  z-index: 50;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
}

.logo {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #fff;
  font-size: 18px;
}

.title {
  font-size: 20px;
  font-weight: 600;
  color: var(--dark);
}

.subtitle {
  font-size: 14px;
  color: var(--muted);
}

header .title,
header .subtitle,
header .cart {
  color: #fff;
}

.cart {
  position: relative;
  cursor: pointer;
  background: transparent;
  border: none;
  color: var(--dark);
  font-size: 18px;
}

.cart-count {
  position: absolute;
  top: -8px;
  right: -8px;
  background: #ef4444;
  color: #fff;
  padding: 3px 7px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

/* Categories */
.categories {
  display: flex;
  gap: 10px;
  padding: 16px;
  justify-content: center;
  background: var(--card);
  border-bottom: 1px solid var(--border-color);
  flex-wrap: wrap;
}

.category {
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--bg);
  cursor: pointer;
  color: var(--dark);
  border: 1px solid var(--border-color);
  font-weight: 500;
  transition: all 0.2s ease-in-out;
}

.category:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

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

.intro {
  text-align: center;
  margin-top: 2rem;
}

/* Grid */
.container {
  max-width: 1100px;
  margin: 2rem auto;
  padding: 0 16px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 18px;
}

.card {
  background: var(--card);
  border-radius: 12px;
  box-shadow: 0 4px 12px var(--shadow-light);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
  transition: all 0.2s ease-in-out;
}

.card:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 20px var(--shadow-medium);
}

.card img {
  width: 100%;
  height: 200px; /* Augmenter légèrement la hauteur pour plus d'impact */
  object-fit: cover;
  border-radius: 8px;
  cursor: pointer;
}

.card h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

.desc {
  font-size: 14px;
  color: var(--muted);
  min-height: 40px; /* Ajuster la hauteur minimale */
  text-align: center;
}

.price {
  font-weight: 700;
  font-size: 18px;
  color: var(--dark);
}

.actions {
  display: flex;
  gap: 8px;
  width: 100%;
}

button.btn {
  flex: 1;
  padding: 10px 15px;
  border-radius: 8px;
  border: 0;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease-in-out;
  font-size: 15px;
}

.btn-buy {
  background: var(--accent);
  color: #fff;
}

.btn-buy:hover {
  opacity: 0.9;
}

.btn-add {
  background: var(--dark);
  color: #fff;
}

.btn-add:hover {
  opacity: 0.9;
}

/* Modal image */
.modal,
.cart-modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.6); /* Arrière-plan légèrement plus foncé */
  z-index: 80;
}

.modal .inner,
.cart-modal .inner {
  background: var(--card);
  border-radius: 12px;
  max-width: 900px;
  width: 95%;
  padding: 24px;
  box-shadow: 0 10px 25px var(--shadow-medium);
}

.modal img {
  width: 100%;
  height: auto;
  border-radius: 8px;
}

.close-btn {
  background: var(--dark);
  color: #fff;
  border: 0;
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s ease-in-out;
}

.close-btn:hover {
  background: #ef4444; /* Un rouge pour le survol du bouton de fermeture */
}

/* Cart content */
.cart-list {
  max-height: 60vh;
  overflow-y: auto;
  padding-right: 8px; /* Espacement pour la barre de défilement */
  margin-bottom: 20px;
}

.cart-summary {
  margin-top: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid var(--border-color);
  padding-top: 20px;
}

.cart-total-label {
  font-size: 15px;
  color: var(--muted);
}

.cart-total-amount {
  font-weight: 700;
  font-size: 22px;
  color: var(--dark);
}

.cart-actions {
  display: flex;
  gap: 10px;
}

.btn-danger {
  background: #ef4444;
  color: #fff;
}

.btn-danger:hover {
  opacity: 0.9;
}

.cart-item {
  display: flex;
  gap: 15px;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-color);
}

.cart-item img {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: 8px;
  flex-shrink: 0;
}

.cart-item-details {
  flex: 1;
}

.qty-controls {
  display: flex;
  gap: 8px;
  align-items: center;
}

.qty-controls button {
  padding: 7px 10px;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  background: var(--bg);
  cursor: pointer;
  transition: all 0.2s ease-in-out;
}

.qty-controls button:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* Scroll-to-top button */
.scroll-to-top-btn {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background-color: var(--accent);
  color: #fff;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  display: flex; /* font-size removed as it's an image now */
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
  z-index: 100; /* Ensure it's above most other content */
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease-in-out, visibility 0.3s ease-in-out;
}

.scroll-to-top-btn img {
  width: 60%; /* Adjust size of the SVG within the button */
  height: 60%;
}

.scroll-to-top-btn.active {
  opacity: 1;
  visibility: visible;
}

/* Responsive adjustment for button */
@media (max-width: 520px) {
  .scroll-to-top-btn {
    width: 40px;
    height: 40px;
    /* font-size removed */
    bottom: 15px;
    right: 15px;
  }
  /* Ensure SVG scales within the smaller button */
  .scroll-to-top-btn img {
    width: 60%;
    height: 60%;
  }
}

footer {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--dark);
  color: #fff; /* Texte blanc sur fond sombre */
  padding: 20px;
  margin-top: 40px;
  font-size: 14px;
}

/* Styles pour la page d'accueil */
.welcome-page {
  min-height: 100vh;
  background: var(--welcome-bg);
  display: flex;
  flex-direction: column;
  color: var(--welcome-text);
  padding: 0;
  margin: 0;
  position: relative; /* Added for correct pseudo-element positioning */
}

.welcome-page header {
  background: transparent;
  border-bottom: none;
  color: var(--welcome-text);
}

.welcome-page .logo {
  background: var(--welcome-text);
  color: var(--accent);
}

.welcome-page .title {
  color: var(--welcome-text);
}

.welcome-page .subtitle {
  color: rgba(255, 255, 255, 0.8);
}

/* Styles for welcome background slideshow */
.welcome-background-slideshow {
  position: absolute;
  inset: 0;
  overflow: hidden;
  z-index: 0; /* Ensures it's behind main content on welcome page */
  display: none; /* Hidden by default on large screens */
}

.welcome-background-slideshow img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 1s ease-in-out;
  z-index: -1; /* Ensures images are behind the slideshow container itself */
}

.welcome-background-slideshow img.active {
  opacity: 1;
}

/* Show slideshow on small screens */
@media (max-width: 768px) {
  .welcome-background-slideshow {
    display: block;
  }
}

.welcome-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  padding: 20px;
  text-align: center;
  max-width: 800px;
  margin: 0 auto;
  position: relative; /* Ensure content is above overlay */
  z-index: 2; /* Ensure content is above overlay */
}

.welcome-page::after {
  content: '';
  position: absolute;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.5); /* Semi-transparent black overlay */
  z-index: 1; /* Above slideshow, below content */
  display: none; /* Hidden by default on large screens */
}

/* Show overlay on small screens */
@media (max-width: 768px) {
  .welcome-page::after {
    display: block;
  }
}

.welcome-title {
  font-size: 2.5rem;
  font-weight: 700;
  margin-bottom: 1rem;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.welcome-message {
  font-size: 1.2rem;
  margin-bottom: 0.5rem;
  max-width: 600px;
  line-height: 1.6;
}

.slogan {
  font-size: 1.4rem;
  font-weight: 600;
  margin-bottom: 2rem;
  font-style: italic;
  color: #ffd700; /* Or pour faire ressortir le slogan */
}

.fashion-showcase {
  width: 100%;
  margin: 2rem 0;
  overflow: hidden;
  position: relative;
}

.fashion-scroll-container {
  width: 100%;
  overflow: hidden;
}

.fashion-scroll-content {
  display: flex;
  width: max-content;
  animation: scroll 80s ease-in-out infinite; /* Even slower for more noticeable smoothness */
}

.fashion-scroll-content img {
  width: 200px;
  height: 200px;
  object-fit: cover;
  margin: 0 10px;
  border-radius: 8px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
  flex-shrink: 0;
}

@keyframes scroll {
  0% {
    transform: translateX(0);
  }
  100% {
    transform: translateX(-50%);
  }
}

/* Masquer le défilement sur les écrans de 768px et moins */
@media (max-width: 768px) {
  .fashion-showcase {
    display: none;
  }
}

/* Afficher le défilement sur les écrans plus larges que 768px */
@media (min-width: 769px) {
  .fashion-showcase {
    display: block;
  }

  .fashion-scroll-content {
    animation: scroll 80s ease-in-out infinite;
  }
}

@media (min-width: 769px) and (max-width: 1024px) {
  .fashion-scroll-content {
    animation: scroll 70s ease-in-out infinite;
  }
}

@media (min-width: 769px) and (max-width: 1200px) {
  .fashion-scroll-content {
    animation: scroll 60s ease-in-out infinite;
  }
}

.explore-btn {
  background: var(--welcome-text);
  color: var(--accent);
  border: none;
  padding: 15px 30px;
  font-size: 1.1rem;
  font-weight: 600;
  border-radius: 50px;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
  margin-top: 2rem;
}

.explore-btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
  background: #f0f0f0;
}

/* Responsive pour la page d'accueil */
@media (max-width: 768px) {
  .welcome-title {
    font-size: 2rem;
  }

  .welcome-message {
    font-size: 1rem;
  }

  .slogan {
    font-size: 1.2rem;
  }

  .fashion-scroll-content img {
    width: 150px;
    height: 150px;
  }

  .explore-btn {
    padding: 12px 25px;
    font-size: 1rem;
  }
}

@media (max-width: 480px) {
  .welcome-title {
    font-size: 1.6rem;
  }

  .welcome-message {
    font-size: 0.9rem;
  }

  .slogan {
    font-size: 1.1rem;
  }

  .fashion-scroll-content img {
    width: 100px;
    height: 100px;
    margin: 0 5px;
  }

  .explore-btn {
    padding: 10px 20px;
    font-size: 0.9rem;
  }

  .welcome-content {
    padding: 10px;
  }

  .welcome-message,
  .slogan {
    padding: 0 10px;
  }
}

/* Pour les écrans très petits */
@media (max-width: 360px) {
  .welcome-title {
    font-size: 1.4rem;
  }

  .welcome-message {
    font-size: 0.8rem;
  }

  .slogan {
    font-size: 1rem;
  }

  .fashion-scroll-content img {
    width: 80px;
    height: 80px;
    margin: 0 3px;
  }

  .fashion-showcase {
    margin: 1rem 0;
  }

  .explore-btn {
    padding: 8px 16px;
    font-size: 0.8rem;
  }
}

/* Styles pour la page principale (tissus) */
.main-page {
  display: none;
  min-height: 100vh;
  background: var(--welcome-bg);
  padding: 0;
  margin: 0;
}

.main-page header {
  background: var(--welcome-bg);
  border-bottom: none;
  color: var(--welcome-text);
}

.main-page .title,
.main-page .subtitle {
  color: var(--welcome-text);
}

.main-page .intro h1 {
  color: var(--welcome-text);
}

/* Pour conserver le style des cartes sur fond violet */
.main-page .card {
  background: var(--card);
  color: var(--dark);
}

.main-page .desc {
  color: var(--muted);
}

/* Responsive */
@media (max-width: 520px) {
  header {
    padding: 12px;
  }

  .brand {
    gap: 8px;
  }

  .logo {
    width: 38px;
    height: 38px;
    font-size: 16px;
  }

  .title {
    font-size: 18px;
  }

  .subtitle {
    font-size: 12px;
  }

  .cart {
    font-size: 16px;
  }

  .categories {
    padding: 12px;
    gap: 8px;
  }

  .category {
    padding: 6px 12px;
    font-size: 13px;
  }

  .container {
    margin: 1rem auto;
    padding: 0 12px;
  }

  .grid {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
  }

  .card {
    padding: 10px;
    gap: 8px;
  }

  .card img {
    height: 120px;
  }

  .card h3 {
    font-size: 15px;
  }

  .desc {
    font-size: 12px;
    min-height: 30px;
  }

  .price {
    font-size: 16px;
  }

  button.btn {
    padding: 8px 12px;
    font-size: 13px;
  }

  .modal .inner,
  .cart-modal .inner {
    padding: 18px;
  }

  .cart-item img {
    width: 60px;
    height: 60px;
  }

  .cart-total-amount {
    font-size: 20px;
  }

  .cart-actions {
    gap: 8px;
  }

  footer {
    padding: 15px;
    font-size: 12px;
  }
}