/* ============================================
   CALENDRIER DES INSTALLATIONS - STYLES
   ============================================ */

.eco-calendar-container {
  width: 100%;
  height: 100%;
  min-height: 360px;
  background: #fff;
  border-radius: 0;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
}

.eco-calendar {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
}

/* Header du calendrier */
.eco-calendar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid var(--border-light, #e5e7eb);
  background: #fafbfc;
}

.eco-calendar-nav {
  display: flex;
  align-items: center;
  gap: 12px;
}

.eco-calendar-nav button {
  background: transparent;
  border: 1px solid var(--border, #d1d5db);
  width: 36px;
  height: 36px;
  border-radius: 6px;
  cursor: pointer;
  color: var(--muted, #6b7280);
  font-size: 16px;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.eco-calendar-nav button:hover {
  background: #f3f4f6;
  color: var(--ink, #111827);
  border-color: var(--muted, #9ca3af);
}

.eco-calendar-month {
  font-weight: 600;
  color: var(--ink, #111827);
  font-size: 15px;
  min-width: 150px;
  text-align: center;
}

/* Grille du calendrier */
.eco-calendar-body {
  flex: 1;
  overflow: hidden;
  padding: 16px;
  display: flex;
  flex-direction: column;
}

.eco-calendar-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.eco-calendar-weekday {
  text-align: center;
  font-weight: 600;
  color: var(--muted, #9ca3af);
  font-size: 12px;
  padding: 8px 0;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.eco-calendar-days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
  flex: 1;
}

/* Jour du calendrier */
.eco-calendar-day {
  background: #f9fafb;
  border: 1px solid var(--border-light, #e5e7eb);
  border-radius: 6px;
  padding: 8px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  position: relative;
  min-height: 80px;
}

.eco-calendar-day:hover {
  background: #f0f9ff;
  border-color: var(--color-info, #3b82f6);
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.1);
}

.eco-calendar-day.other-month {
  background: #fafbfc;
  color: var(--border, #d1d5db);
  cursor: default;
}

.eco-calendar-day.other-month:hover {
  background: #fafbfc;
  border-color: var(--border-light, #e5e7eb);
  box-shadow: none;
}

.eco-calendar-day.today {
  background: #eff6ff;
  border: 2px solid var(--color-info, #3b82f6);
  font-weight: bold;
}

.eco-calendar-day.has-installations {
  background: #f0f9ff;
  border-color: #bfdbfe;
}

/* Numéro du jour */
.eco-calendar-day-number {
  font-weight: 700;
  font-size: 13px;
  color: var(--ink, #111827);
  margin-bottom: 4px;
}

.eco-calendar-day.other-month .eco-calendar-day-number {
  color: var(--border, #d1d5db);
}

/* Badge de compte */
.eco-calendar-day-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  background: var(--color-info, #3b82f6);
  color: white;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  border: 1px solid white;
}

/* Points d'installation (statut) */
.eco-calendar-day-dots {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  margin-top: auto;
}

.eco-calendar-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.eco-calendar-status-dot.done {
  background: #10b981;
}

.eco-calendar-status-dot.run {
  background: var(--color-warning, #f59e0b);
}

.eco-calendar-status-dot.block {
  background: var(--color-danger, #ef4444);
}

.eco-calendar-status-dot.todo {
  background: #8b5cf6;
}

/* ============================================
   POPOVER D'INSTALLATION
   ============================================ */

.eco-calendar-popover {
  position: fixed;
  background: white;
  border-radius: 8px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.15);
  z-index: 9000;
  min-width: min(300px, 90vw);
  max-width: min(420px, 92vw);
  max-height: 500px;
  border: 1px solid var(--border-light, #e5e7eb);
  animation: popoverSlideIn 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  overflow: hidden;
}

@keyframes popoverSlideIn {
  from {
    opacity: 0;
    transform: translateY(-8px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.eco-calendar-popover-header {
  padding: 14px;
  border-bottom: 1px solid var(--border-light, #e5e7eb);
  background: linear-gradient(135deg, #f9fafb 0%, #f3f4f6 100%);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  position: sticky;
  top: 0;
}

.eco-calendar-popover-title {
  font-weight: 600;
  color: var(--ink, #111827);
  font-size: 13px;
}

.eco-calendar-popover-close {
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--muted, #9ca3af);
  font-size: 18px;
  padding: 0;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: all 0.15s;
}

.eco-calendar-popover-close:hover {
  background: var(--border-light, #e5e7eb);
  color: var(--ink, #111827);
}

.eco-calendar-popover-body {
  overflow-y: auto;
  max-height: 450px;
}

/* Carte d'installation */
.eco-calendar-installation-card {
  padding: 12px;
  border-bottom: 1px solid #f3f4f6;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.eco-calendar-installation-card:last-child {
  border-bottom: none;
}

.eco-calendar-installation-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.eco-calendar-installation-client {
  font-weight: 600;
  color: var(--ink, #111827);
  font-size: 13px;
  flex: 1;
}

.eco-calendar-installation-status {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  white-space: nowrap;
  flex-shrink: 0;
}

.eco-calendar-installation-status.done {
  background: #d1fae5;
  color: #065f46;
}

.eco-calendar-installation-status.run {
  background: #fef3c7;
  color: #92400e;
}

.eco-calendar-installation-status.block {
  background: #fee2e2;
  color: #991b1b;
}

.eco-calendar-installation-status.todo {
  background: #e9d5ff;
  color: #581c87;
}

.eco-calendar-installation-time {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--ink, #374151);
  font-weight: 500;
}

.eco-calendar-installation-time-dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  flex-shrink: 0;
}

.eco-calendar-installation-details {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-top: 8px;
  border-top: 1px solid #f3f4f6;
}

.eco-calendar-detail-row {
  display: grid;
  grid-template-columns: 70px 1fr;
  gap: 8px;
  font-size: 11px;
}

.eco-calendar-detail-label {
  color: var(--muted, #6b7280);
  font-weight: 600;
  white-space: nowrap;
}

.eco-calendar-detail-value {
  color: var(--ink, #374151);
  word-break: break-word;
}

.eco-calendar-detail-value a {
  color: var(--color-info, #3b82f6);
  text-decoration: none;
  font-weight: 500;
}

.eco-calendar-detail-value a:hover {
  text-decoration: underline;
}

.eco-calendar-no-installations {
  padding: 24px 12px;
  text-align: center;
  color: var(--muted, #9ca3af);
  font-size: 12px;
}

/* ============================================
   MODE PLEIN ÉCRAN
   ============================================ */

.eco-calendar.fullscreen {
  position: fixed;
  inset: 0 0 0 0;
  z-index: 10000;
  background: white;
  border-radius: 0;
  padding: 0;
}

.eco-calendar.fullscreen .eco-calendar-body {
  padding: 24px;
}

.eco-calendar.fullscreen .eco-calendar-days {
  gap: 12px;
}

.eco-calendar.fullscreen .eco-calendar-day {
  min-height: 120px;
  font-size: 14px;
}

.eco-calendar.fullscreen .eco-calendar-day-number {
  font-size: 16px;
}

/* ============================================
   LÉGENDE
   ============================================ */

.eco-calendar-legend {
  padding: 12px 16px;
  border-top: 1px solid var(--border-light, #e5e7eb);
  background: #f9fafb;
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 11px;
  color: var(--muted, #6b7280);
}

.eco-calendar-legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.eco-calendar-legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (width <= 900px) {
  .eco-calendar-body {
    padding: 12px;
  }

  .eco-calendar-days {
    gap: 6px;
  }

  .eco-calendar-day {
    min-height: 70px;
    padding: 6px;
  }

  .eco-calendar-day-number {
    font-size: 12px;
  }
}

@media (width <= 640px) {
  .eco-calendar-body {
    padding: 10px;
  }

  .eco-calendar-days {
    gap: 4px;
  }

  .eco-calendar-day {
    min-height: 60px;
    padding: 4px;
    font-size: 10px;
  }

  .eco-calendar-day-number {
    font-size: 11px;
    margin-bottom: 2px;
  }

  .eco-calendar-popover {
    min-width: 280px;
    max-width: 90vw;
  }

  .eco-calendar-detail-row {
    grid-template-columns: 60px 1fr;
    font-size: 10px;
  }
}

/* Tablet + mobile: bottom-sheet popover + touch targets */
@media (width <= 900px) {
  .eco-calendar-popover {
    position: fixed !important;
    inset: auto 0 0 0 !important;
    width: 100% !important; max-width: 100% !important;
    min-width: 100% !important;
    border-radius: 16px 16px 0 0;
    max-height: 60vh;
    animation: calBottomSheet 0.2s ease;
  }
  @keyframes calBottomSheet { from { transform: translateY(100%); } to { transform: translateY(0); } }
  .eco-calendar-nav button { min-width: 44px; min-height: 44px; }
  .eco-calendar-popover-close { min-width: 44px; min-height: 44px; }
}

@media (prefers-reduced-motion: reduce) {
  .eco-calendar-nav button,
  .eco-calendar-day,
  .eco-calendar-popover,
  .eco-calendar-popover-close {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}