/* ============================================
   🎨 STYLES GÉNÉRAUX
   ============================================ */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root{
  --bg-grad-start: #667eea;
  --bg-grad-end: #764ba2;
  --card: #ffffff;
  --muted: #64748b;
  --text-primary: #0f172a;
  --accent: #0da119;
  --accent-strong: #09ac24;
  --filter-primary: #3b82f6;
  --border: #e2e8f0;
  --radius: 10px;
}

body {
  font-family: Inter, system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial;
  background: linear-gradient(135deg,var(--bg-grad-start) 0%, var(--bg-grad-end) 100%);
  min-height: 100vh;
  padding: 1rem 0.75rem;
}

.container {
  max-width: 1600px;
  margin: 0 auto;
}

h1 {
  color: white;
  text-align: center;
  margin-bottom: 1.5rem;
  font-size: 2rem;
  text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
}

/* ============================================
   🎛️ CONTRÔLES (RECHERCHE + FILTRE)
   ============================================ */
.controls {
  background: rgba(255,255,255,0.95);
  padding: 0.75rem;
  border-radius: 12px;
  margin-bottom: 1.2rem;
  border: 1px solid rgba(255,255,255,0.3);
  box-shadow: 0 8px 20px rgba(2,6,23,0.08);
  display:flex;
  gap:0.75rem;
  flex-wrap:wrap;
}

.search-box {
  flex:1;
  min-width:160px;
  padding:0.6rem 0.8rem;
  border:1px solid var(--border);
  border-radius:10px;
  font-size:0.95rem;
  background:var(--card);
  color:var(--text-primary);
}

.search-box:focus {
  outline: none;
  border-color: var(--filter-primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.filter-select {
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 0.95rem;
  background: var(--card);
  color: var(--text-primary);
  cursor: pointer;
}

.filter-select:focus {
  outline: none;
  border-color: var(--filter-primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* ============================================
   📍 SECTIONS PAR ADRESSE
   ============================================ */
.address-section {
  margin-bottom: 2rem;
}

.address-header {
  background: white;
  padding: 0.75rem 1rem;
  border-radius: 8px 8px 0 0;
  margin-bottom: 0.75rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.address-header h2 {
  color: #333;
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.address-stats {
  display: flex;
  gap: 0.75rem;
  font-size: 0.85rem;
  color: #666;
}

.stat-badge {
  background: #f0f0f0;
  padding: 0.2rem 0.6rem;
  border-radius: 16px;
  font-weight: 500;
}

/* ============================================
   🃏 GRILLE DES VCARDS - PLUS COMPACTE
   ============================================ */
.locations-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

/* ============================================
   🎴 VCARD - STRUCTURE COMPACTE
   ============================================ */
.vcard {
  background: var(--card);
  border-radius: var(--radius);
  overflow:hidden;
  box-shadow: 0 12px 30px rgba(2,6,23,0.06);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  font-size:0.95rem;
}

.vcard:hover {
  transform: translateY(-3px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.vcard-image {
  width:100%;
  height:200px;
  object-fit:cover;
  background: linear-gradient(135deg,#b6f0d6 0%, #bfe9ff 100%);
  cursor: pointer;
  transition: opacity 0.2s;
}

.vcard-image:hover {
  opacity: 0.9;
}

.vcard-header {
  padding: 0.75rem;
  border-bottom: 1px solid #f0f0f0;
}

.vcard-title {
  font-size: 1rem;
  font-weight: bold;
  color: #333;
  margin-bottom: 0.35rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.vcard-meta {
  color: #666;
  font-size: 0.8rem;
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* ============================================
   📦 SECTIONS CULTURES & RÉCOLTES
   ============================================ */
.vcard-section {
  padding: 0.75rem;
  border-bottom: 1px solid #f8f9fa;
}

.vcard-section:last-child {
  border-bottom: none;
}

.section-title {
  font-weight: 600;
  color: #555;
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

/* ============================================
   🌱 ITEMS (CULTURES & RÉCOLTES) - COMPACTS
   ============================================ */
.item-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem;
  background: #f8f9fa;
  border-radius: 6px;
  transition: background 0.2s;
}

.item:hover {
  background: #e9ecef;
}

.item-image {
  width: 56px;
  height: 56px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
  background: #ddd;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.item-image:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.item-info {
  flex: 1;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.item-name {
  font-weight: 500;
  color: #333;
  font-size: 0.85rem;
}

.item-quantity {
  background: linear-gradient(90deg, var(--filter-primary), #2563eb);
  color: white;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  font-size:0.8rem;
  font-weight:700;
}

/* ============================================
   🎭 ÉTATS SPÉCIAUX
   ============================================ */
.empty-state {
  text-align: center;
  color: #999;
  padding: 1rem;
  font-style: italic;
  font-size: 0.85rem;
}

.loading {
  text-align: center;
  color: white;
  font-size: 1.25rem;
  padding: 2rem;
}

.error {
  background: #ff6b6b;
  color: white;
  padding: 1rem;
  border-radius: 8px;
  margin: 1rem 0;
  box-shadow: 0 4px 6px rgba(0,0,0,0.2);
}

.type-icon {
  display: inline-block;
  font-size: 1rem;
}

/* ============================================
   📱 RESPONSIVE MOBILE
   ============================================ */
@media (max-width: 768px) {
  body {
    padding: 0.75rem 0.5rem;
  }

  h1 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
  }

  .controls {
    flex-direction: column;
    padding: 0.6rem;
  }

  .search-box,
  .filter-select {
    width: 100%;
    min-width: 0;
  }

  .locations-grid {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  .address-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.75rem;
  }

  .address-header h2 {
    font-size: 1.1rem;
  }

  .address-stats {
    flex-wrap: wrap;
    gap: 0.5rem;
    font-size: 0.8rem;
  }

  .vcard-image {
    height:160px;
  }

  .vcard-header,
  .vcard-section {
    padding: 0.6rem;
  }

  .item {
    padding: 0.35rem;
  }

  .item-image {
    width: 48px;
    height: 48px;
  }

  .item-name {
    font-size: 0.8rem;
  }

  .item-quantity {
    font-size: 0.7rem;
    padding: 0.15rem 0.5rem;
  }
}

/* ============================================
   💻 RESPONSIVE TABLET (2 colonnes)
   ============================================ */
@media (min-width: 769px) and (max-width: 1024px) {
  .locations-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ============================================
   🖥️ RESPONSIVE DESKTOP (4-5 colonnes)
   ============================================ */
@media (min-width: 1400px) {
  .locations-grid {
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  }
}

@media (min-width: 1800px) {
  .locations-grid {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  }
  
  .container {
    max-width: 1900px;
  }
}

/* ============================================
   🖨️ PRINT STYLES
   ============================================ */
@media print {
  body {
    background: white;
    padding: 0;
  }

  .controls {
    display: none;
  }

  .vcard {
    break-inside: avoid;
    box-shadow: none;
    border: 1px solid #ddd;
    page-break-inside: avoid;
  }

  .vcard:hover {
    transform: none;
  }

  .vcard-image {
    height: 80px;
  }

  .locations-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
  }
}

/* ============================================
   🔍 LIGHTBOX - VISUALISATION PLEIN ÉCRAN
   ============================================ */
.lightbox {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.92);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.lightbox.active {
  opacity: 1;
  visibility: visible;
}

.lightbox-content {
  position: relative;
  max-width: 90vw;
  max-height: 90vh;
}

.lightbox-image {
  max-width: 90vw;
  max-height: 85vh;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  animation: lightbox-zoom 0.3s ease;
}

@keyframes lightbox-zoom {
  from {
    transform: scale(0.8);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

.lightbox-caption {
  position: absolute;
  bottom: -40px;
  left: 0;
  right: 0;
  text-align: center;
  color: white;
  font-size: 1.1rem;
  font-weight: 500;
  text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

.lightbox-close {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 50px;
  height: 50px;
  background: rgba(255, 255, 255, 0.15);
  border: none;
  border-radius: 50%;
  color: white;
  font-size: 28px;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: background 0.2s, transform 0.2s;
}

.lightbox-close:hover {
  background: rgba(255, 255, 255, 0.25);
  transform: scale(1.1);
}

.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 50px;
  height: 50px;
  background: rgba(255, 255, 255, 0.15);
  border: none;
  border-radius: 50%;
  color: white;
  font-size: 24px;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: background 0.2s;
}

.lightbox-nav:hover {
  background: rgba(255, 255, 255, 0.25);
}

.lightbox-prev {
  left: 20px;
}

.lightbox-next {
  right: 20px;
}
