/* style.css - version finale adaptée */

/* ==================== Reset / Base ==================== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Arial', sans-serif;
}

html, body {
  height: 100%;
}

body {
  background-color: #f9f9f9;
  color: #333;
  line-height: 1.6;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ==================== Header ==================== */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 2rem;
  background-color: #0d6efd;
  color: white;
  position: sticky;
  top: 0;
  z-index: 1000;
}

header h1 {
  font-size: 1.5rem;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.section-title {
  text-align: center; /* centre le texte */
  margin: 20px 0;     /* espace autour du titre */
}

/* Chariot à droite */
.header-right .cart {
  font-size: 1.5rem;
  cursor: pointer;
}

/* ==================== Bouton Google ==================== */
.google-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background-color: #fff;
  color: #0d6efd;
  border: 1px solid #0d6efd;
  padding: 0.4rem 0.8rem;
  border-radius: 5px;
  cursor: pointer;
  text-decoration: none;
  transition: 0.3s;
}

.google-btn:hover {
  background-color: #0d6efd;
  color: #fff;
}

.google-btn .user-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  object-fit: cover;
}

/* ==================== Zone de recherche ==================== */
.search-container {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin: 2rem auto;
}

.search-container input {
  padding: 0.5rem 1rem;
  width: 300px;
  border: 1px solid #ccc;
  border-radius: 5px;
  outline: none;
  font-size: 15px; /* ✅ Taille du texte dans l'input */
}

.search-container button {
  background-color: #0d6efd;
  color: white;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 5px;
  cursor: pointer;
  transition: 0.3s;
  font-size: 15px; /* ✅ Taille du texte dans l'input */
}

.search-container button:hover {
  background-color: #084298;
}

/* ==================== Main / Produits ==================== */
main {
  padding: 2rem;
  flex: 1;
}

.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 1.5rem;
}

.product-card {
  background-color: white;
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.product-card img {
  width: 100%;
  height: 200px;
  object-fit: cover;
}

.product-info {
  padding: 1rem;
}

.product-info h3 {
  font-size: 1.2rem;
  margin-bottom: 0.5rem;
}

.product-info .price {
  color: #0d6efd;
  font-weight: bold;
  margin-bottom: 0.5rem;
}

.product-actions {
  display: flex;
  justify-content: space-between;
  margin-top: 0.5rem;
}

.product-actions a.view-btn,
.product-actions button.vote-btn {
  padding: 0.3rem 0.6rem;
  border-radius: 5px;
  border: none;
  cursor: pointer;
  font-size: 0.9rem;
  text-decoration: none;
}

.product-actions a.view-btn {
  background-color: #0d6efd;
  color: white;
}

.product-actions button.vote-btn {
  background-color: #ffc107;
  color: #333;
}

/* ==================== Stars ==================== */
.stars {
  display: flex;
  gap: 2px;
}

.star.full { color: #ffc107; }
.star.half { color: #ffc107; opacity: 0.5; }
.star.empty { color: #ddd; }

/* ==================== Reviews ==================== */
.reviews-section {
  margin-top: 1rem;
}

.reviews-list {
  max-height: 150px;
  overflow-y: auto;
  margin-bottom: 0.5rem;
}

.single-review {
  border-bottom: 1px solid #eee;
  padding: 0.3rem 0;
}

.rev-head {
  font-weight: bold;
  font-size: 0.9rem;
  display: flex;
  justify-content: space-between;
}

.rev-body {
  font-size: 0.85rem;
  margin-top: 0.2rem;
}

textarea {
  width: 100%;
  resize: none;
  padding: 0.4rem;
  margin-bottom: 0.3rem;
  border-radius: 5px;
  border: 1px solid #ccc;
}

/* Bouton Envoyer (reviews) */
button.send-review {
  background-color: #0d6efd;
  color: white;
  border: none;
  padding: 0.4rem 0.8rem;
  border-radius: 5px;
  cursor: pointer;
  transition: 0.3s;
}

button.send-review:hover {
  background-color: #084298;
}

/* Ajouter à votre style.css existant */

/* ==================== Auth Status ==================== */
.auth-status {
  background-color: rgba(255,255,255,0.1);
  padding: 0.3rem 0.8rem;
  border-radius: 15px;
  font-size: 0.8rem;
  margin-right: 1rem;
}

.auth-status.loading { color: #ffc107; }
.auth-status.connected { color: #28a745; }
.auth-status.disconnected { color: #dc3545; }

/* ==================== User Info ==================== */
.user-info {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  background-color: rgba(255,255,255,0.1);
  padding: 0.4rem 0.8rem;
  border-radius: 25px;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
}

.user-details {
  display: flex;
  flex-direction: column;
}

.user-name {
  font-weight: bold;
  font-size: 0.9rem;
}

.user-email {
  font-size: 0.7rem;
  opacity: 0.8;
}

.logout-btn {
  background-color: #dc3545;
  color: white;
  border: none;
  padding: 0.3rem 0.6rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.8rem;
  transition: 0.3s;
}

.logout-btn:hover {
  background-color: #c82333;
}

/* Ajoutez ces styles à votre style.css existant */

/* ==================== Auth Status ==================== */
.auth-status {
  background-color: rgba(255,255,255,0.1);
  padding: 0.3rem 0.8rem;
  border-radius: 15px;
  font-size: 0.8rem;
  margin-right: 1rem;
  white-space: nowrap;
}

.auth-status.loading { color: #ffc107; }
.auth-status.connected { color: #28a745; }
.auth-status.disconnected { color: #dc3545; }

/* ==================== User Info ==================== */
.user-info {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  background-color: rgba(255,255,255,0.1);
  padding: 0.4rem 0.8rem;
  border-radius: 25px;
  max-width: 300px;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255,255,255,0.3);
}

.user-details {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex: 1;
}

.user-name {
  font-weight: bold;
  font-size: 0.9rem;
  color: white;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-email {
  font-size: 0.7rem;
  opacity: 0.8;
  color: rgba(255,255,255,0.8);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.logout-btn {
  background-color: #dc3545;
  color: white;
  border: none;
  padding: 0.3rem 0.6rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.8rem;
  transition: 0.3s;
  white-space: nowrap;
}

.logout-btn:hover {
  background-color: #c82333;
}

/* ==================== Welcome Message ==================== */
.welcome-message {
  background: linear-gradient(135deg, #0d6efd, #28a745);
  color: white;
  padding: 1.5rem;
  border-radius: 10px;
  text-align: center;
  margin-bottom: 2rem;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.welcome-message h2 {
  margin-bottom: 0.5rem;
  font-size: 1.5rem;
}

.welcome-message p {
  opacity: 0.9;
  font-size: 1rem;
}

/* ==================== Notifications ==================== */
.notification {
  position: fixed;
  top: 80px;
  right: 20px;
  padding: 1rem 1.5rem;
  border-radius: 8px;
  color: white;
  font-weight: bold;
  z-index: 1001;
  transform: translateX(400px);
  transition: transform 0.3s ease;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  max-width: 300px;
  word-wrap: break-word;
}

.notification.success { 
  background-color: #28a745;
}

.notification.error { 
  background-color: #dc3545;
}

.notification.show { 
  transform: translateX(0);
}

/* ==================== Responsive Auth ==================== */
@media (max-width: 768px) {
  .header-right {
    flex-direction: column;
    gap: 0.5rem;
    align-items: stretch;
  }
  
  .auth-status {
    margin-right: 0;
    text-align: center;
  }
  
  .user-info {
    max-width: none;
    justify-content: center;
  }
  
  .user-details {
    text-align: center;
  }
  
  .notification {
    right: 10px;
    left: 10px;
    max-width: none;
    transform: translateY(-100px);
  }
  
  .notification.show {
    transform: translateY(0);
  }
}

/* ==================== Disabled Buttons ==================== */
button:disabled, textarea:disabled {
  opacity: 0.5;
  cursor: not-allowed !important;
  background-color: #6c757d !important;
}

button:disabled:hover {
  background-color: #6c757d !important;
}

/* ==================== Loading States ==================== */
.loading-spinner {
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 2px solid rgba(255,255,255,0.3);
  border-radius: 50%;
  border-top-color: #fff;
  animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ==================== Welcome Message ==================== */
.welcome-message {
  background: linear-gradient(135deg, #0d6efd, #28a745);
  color: white;
  padding: 1.5rem;
  border-radius: 10px;
  text-align: center;
  margin-bottom: 2rem;
}

.welcome-message h2 {
  margin-bottom: 0.5rem;
}

/* ==================== Notifications ==================== */
.notification {
  position: fixed;
  top: 80px;
  right: 20px;
  padding: 1rem 1.5rem;
  border-radius: 5px;
  color: white;
  font-weight: bold;
  z-index: 1001;
  transform: translateX(400px);
  transition: transform 0.3s ease;
}

.notification.success { background-color: #28a745; }
.notification.error { background-color: #dc3545; }
.notification.show { transform: translateX(0); }

/* ==================== Footer ==================== */
footer {
  background-color: #0d6efd;
  color: white;
  text-align: center;
  padding: 1rem;
  margin-top: auto;
}

/* ==================== Responsive Auth CORRIGÉ ==================== */
@media (max-width: 768px) {
  header {
    padding: 1rem;
  }
  
  .header-right {
    /* GARDER EN LIGNE même sur mobile */
    flex-direction: row;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
  }
  
  .auth-status {
    margin-right: 0;
    font-size: 0.7rem;
    padding: 0.2rem 0.5rem;
  }
  
  .user-info {
    max-width: 250px;
    padding: 0.3rem 0.6rem;
  }
  
  .user-name {
    font-size: 0.8rem;
  }
  
  .user-email {
    font-size: 0.6rem;
  }
  
  .logout-btn {
    padding: 0.2rem 0.4rem;
    font-size: 0.7rem;
  }
  
  .google-btn {
    padding: 0.3rem 0.6rem;
    font-size: 0.8rem;
  }
  
  /* Notification corrigée pour mobile */
  .notification {
    top: 70px;
    right: 10px;
    left: 10px;
    max-width: none;
    transform: translateX(100%);
    font-size: 0.9rem;
    padding: 0.8rem 1rem;
  }
  
  .notification.show {
    transform: translateX(0);
  }
  
  /* Message de bienvenue responsive */
  .welcome-message {
    margin: 1rem 0;
    padding: 1rem;
  }
  
  .welcome-message h3 {
    font-size: 1.2rem;
  }
}

/* Pour très petits écrans */
@media (max-width: 480px) {
  .header-right {
    justify-content: flex-end;
    width: 100%;
  }
  
  .user-info {
    max-width: 200px;
  }
  
  .user-details {
    min-width: 0; /* Permet la troncature */
  }
}


/* Ajoutez à la fin de style.css */

/* ==================== Optimisations Performance ==================== */
.product-grid {
  contain: layout style paint;
}

.product-card {
  will-change: transform;
  contain: layout style paint;
}

.product-card img {
  content-visibility: auto;
  contain-intrinsic-size: 250px 200px;
}

/* Skeleton plus léger */
.skeleton-card {
  background: #f0f0f0;
  border-radius: 10px;
  height: 400px;
  animation: pulse 1.5s ease-in-out infinite alternate;
}

@keyframes pulse {
  0% { opacity: 1; }
  100% { opacity: 0.7; }
}

.skeleton-image {
  height: 200px;
  background: #e0e0e0;
  border-radius: 10px 10px 0 0;
}

.skeleton-content {
  padding: 1rem;
}

.skeleton-line {
  height: 20px;
  background: #e0e0e0;
  margin-bottom: 10px;
  border-radius: 4px;
}

.skeleton-line.short { width: 60%; }
.skeleton-line.medium { width: 80%; }


