/* ============================================================
   Variables & Reset
   ============================================================ */
:root {
  --primary: #1E40AF;
  --primary-dark: #1E3A8A;
  --primary-light: #EFF6FF;
  --accent: #EA580C;
  --accent-dark: #C2410C;
  --accent-light: #FFF7ED;
  --bg: #F1F5F9;
  --surface: #FFFFFF;
  --text: #1E293B;
  --text-muted: #64748B;
  --border: #E2E8F0;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.05);
  --shadow-lg: 0 10px 25px rgba(0,0,0,.12), 0 4px 10px rgba(0,0,0,.08);

  --type-networking: #2563EB;
  --type-formation: #7C3AED;
  --type-conférence: #059669;
  --type-atelier: #D97706;
  --type-salon: #DC2626;
  --type-autre: #6B7280;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 15px;
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
  min-height: 100vh;
}

/* ============================================================
   Header
   ============================================================ */
.site-header {
  background: var(--primary);
  color: white;
  box-shadow: var(--shadow-md);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 1.25rem;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: .75rem;
  flex-shrink: 0;
}

.brand-icon { font-size: 1.5rem; }

.brand-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: white;
  line-height: 1.2;
}

.brand-sub {
  font-size: .75rem;
  color: rgba(255,255,255,.7);
  font-weight: 400;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: .75rem;
}

/* View toggle */
.view-toggle {
  display: flex;
  background: rgba(255,255,255,.15);
  border-radius: var(--radius);
  padding: 3px;
}

.btn-view {
  padding: .3rem .75rem;
  border: none;
  background: transparent;
  color: rgba(255,255,255,.8);
  border-radius: 6px;
  font-size: .85rem;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s, color .15s;
}

.btn-view:hover { background: rgba(255,255,255,.15); color: white; }
.btn-view.active { background: white; color: var(--primary); }

/* Filters toggle button */
.btn-filters-toggle {
  display: none;
  align-items: center;
  gap: .4rem;
  padding: .4rem .85rem;
  border: 1.5px solid rgba(255,255,255,.4);
  border-radius: var(--radius);
  background: transparent;
  color: white;
  font-size: .85rem;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s;
  position: relative;
}

.btn-filters-toggle:hover { background: rgba(255,255,255,.15); }

.filters-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  background: var(--accent);
  color: white;
  font-size: .65rem;
  font-weight: 700;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--primary);
}

.filters-badge.hidden { display: none; }

/* ============================================================
   Layout
   ============================================================ */
.layout {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1.25rem;
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 1.25rem;
  align-items: start;
}

/* ============================================================
   Filters Panel
   ============================================================ */
.filters-panel {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 1.1rem;
  position: sticky;
  top: 76px;
}

.filters-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.1rem;
}

.filters-title {
  font-weight: 700;
  font-size: .95rem;
  color: var(--text);
}

.btn-reset {
  border: none;
  background: none;
  font-size: .8rem;
  color: var(--accent);
  cursor: pointer;
  font-weight: 500;
  padding: 0;
  transition: color .15s;
}

.btn-reset:hover { color: var(--accent-dark); }

.filter-group { margin-bottom: 1.1rem; }

.filter-group-label {
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  margin-bottom: .5rem;
}

.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
}

.filter-chip {
  border: 1.5px solid var(--border);
  background: var(--bg);
  color: var(--text-muted);
  border-radius: 20px;
  padding: .25rem .65rem;
  font-size: .78rem;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s;
  line-height: 1.4;
}

.filter-chip:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}

.filter-chip.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

/* ============================================================
   Main Calendar Area
   ============================================================ */
.main-area {
  min-width: 0;
}

.calendar-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  gap: .75rem;
}

.nav-controls {
  display: flex;
  align-items: center;
  gap: .5rem;
}

.nav-label {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  min-width: 200px;
  text-align: center;
}

.btn-nav {
  width: 36px;
  height: 36px;
  border-radius: var(--radius);
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all .15s;
}

.btn-nav:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}

.btn-today {
  padding: .4rem 1rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text-muted);
  font-size: .85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s;
}

.btn-today:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}

.event-count {
  font-size: .82rem;
  color: var(--text-muted);
  margin-bottom: .75rem;
  min-height: 1.2em;
}

/* ============================================================
   Month View
   ============================================================ */
.month-grid {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.weekdays-header {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  border-bottom: 1.5px solid var(--border);
}

.weekday-label {
  padding: .6rem 0;
  text-align: center;
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
}

.days-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
}

.day-cell {
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  min-height: 100px;
  padding: .4rem;
  vertical-align: top;
}

.day-cell:nth-child(7n) { border-right: none; }

.day-cell.other-month { background: #FAFAFA; }
.day-cell.other-month .day-number { color: #CBD5E1; }

.day-number {
  font-size: .82rem;
  font-weight: 600;
  color: var(--text-muted);
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  margin-bottom: .25rem;
  flex-shrink: 0;
}

.day-cell.today .day-number {
  background: var(--accent);
  color: white;
  font-weight: 700;
}

.day-cell.has-events .day-number { color: var(--text); }

.day-events { display: flex; flex-direction: column; gap: 2px; }

.event-pill {
  display: block;
  width: 100%;
  padding: 2px 5px;
  border-radius: 4px;
  font-size: .72rem;
  font-weight: 500;
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border: none;
  cursor: pointer;
  text-align: left;
  transition: filter .15s, transform .1s;
}

.event-pill:hover { filter: brightness(.93); transform: scale(1.01); }

.more-events {
  font-size: .7rem;
  color: var(--text-muted);
  padding: 1px 4px;
  cursor: pointer;
  font-weight: 500;
}

.more-events:hover { color: var(--primary); }

/* ============================================================
   Week View
   ============================================================ */
.week-grid {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
}

.week-day-col {
  border-right: 1px solid var(--border);
  min-height: 200px;
}

.week-day-col:last-child { border-right: none; }

.week-day-header {
  padding: .75rem .5rem .5rem;
  text-align: center;
  border-bottom: 1.5px solid var(--border);
  background: var(--bg);
}

.week-day-name {
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  display: block;
}

.week-day-num {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text);
  display: block;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: .15rem auto 0;
}

.week-day-col.today .week-day-num {
  background: var(--accent);
  color: white;
}

.week-day-events { padding: .5rem; display: flex; flex-direction: column; gap: .35rem; }

.week-event-card {
  padding: .45rem .6rem;
  border-radius: 6px;
  font-size: .78rem;
  line-height: 1.3;
  cursor: pointer;
  border: none;
  text-align: left;
  width: 100%;
  transition: filter .15s, transform .1s;
}

.week-event-card:hover { filter: brightness(.93); transform: scale(1.01); }

.week-event-time {
  font-size: .68rem;
  font-weight: 700;
  opacity: .8;
  display: block;
  margin-bottom: 1px;
}

.week-event-title {
  font-weight: 600;
  display: block;
}

/* ============================================================
   List View
   ============================================================ */
.list-view { display: flex; flex-direction: column; gap: 1.5rem; }

.list-date-group {}

.list-date-label {
  font-size: .8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-muted);
  margin-bottom: .6rem;
  padding-bottom: .4rem;
  border-bottom: 1.5px solid var(--border);
}

.list-events { display: flex; flex-direction: column; gap: .6rem; }

.list-event-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 1rem 1.1rem;
  cursor: pointer;
  border: 1.5px solid transparent;
  border-left: 4px solid transparent;
  transition: box-shadow .15s, border-color .15s, transform .1s;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: .5rem;
  align-items: center;
  width: 100%;
  text-align: left;
}

.list-event-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.list-event-info {}

.list-event-header {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin-bottom: .3rem;
  flex-wrap: wrap;
}

.type-badge {
  font-size: .68rem;
  font-weight: 700;
  padding: .15rem .55rem;
  border-radius: 20px;
  text-transform: capitalize;
}

.list-event-title {
  font-size: .97rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: .3rem;
  line-height: 1.3;
}

.list-event-meta {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem 1rem;
  font-size: .8rem;
  color: var(--text-muted);
}

.list-event-meta span { display: flex; align-items: center; gap: .25rem; }

.list-event-arrow {
  color: var(--text-muted);
  flex-shrink: 0;
  font-size: 1.1rem;
}

/* Event type color helpers */
.color-networking  { background: #EFF6FF; color: var(--type-networking);  border-left-color: var(--type-networking) !important; }
.color-formation   { background: #F5F3FF; color: var(--type-formation);   border-left-color: var(--type-formation) !important; }
.color-conférence  { background: #ECFDF5; color: var(--type-conférence);  border-left-color: var(--type-conférence) !important; }
.color-atelier     { background: #FFFBEB; color: var(--type-atelier);     border-left-color: var(--type-atelier) !important; }
.color-salon       { background: #FEF2F2; color: var(--type-salon);       border-left-color: var(--type-salon) !important; }
.color-autre       { background: #F9FAFB; color: var(--type-autre);       border-left-color: var(--type-autre) !important; }

/* ============================================================
   Empty / Error states
   ============================================================ */
.empty-state, .error-state {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 3rem 2rem;
  text-align: center;
  color: var(--text-muted);
}

.empty-state-icon, .error-state-icon { font-size: 2.5rem; margin-bottom: .75rem; }
.empty-state p, .error-state p { margin-bottom: .4rem; }
.empty-state strong { color: var(--text); }
.error-state .hint { font-size: .82rem; margin-top: .5rem; }

/* ============================================================
   Modal
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.45);
  backdrop-filter: blur(2px);
  z-index: 200;
  transition: opacity .2s;
}

.modal-overlay.hidden { display: none; }

.modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 201;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: min(560px, calc(100vw - 2rem));
  max-height: calc(100vh - 4rem);
  overflow-y: auto;
  animation: modal-in .2s ease-out;
}

.modal.hidden { display: none; }

@keyframes modal-in {
  from { opacity: 0; transform: translate(-50%, calc(-50% + 12px)); }
  to   { opacity: 1; transform: translate(-50%, -50%); }
}

.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  border: none;
  background: var(--bg);
  border-radius: var(--radius);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-muted);
  transition: background .15s, color .15s;
}

.modal-close:hover { background: var(--border); color: var(--text); }

.modal-body { padding: 1.75rem; }

.modal-type-badge {
  display: inline-block;
  padding: .2rem .75rem;
  border-radius: 20px;
  font-size: .75rem;
  font-weight: 700;
  text-transform: capitalize;
  margin-bottom: .85rem;
}

.modal-title {
  font-size: 1.25rem;
  font-weight: 800;
  line-height: 1.25;
  margin-bottom: 1.1rem;
  color: var(--text);
  padding-right: 2rem;
}

.modal-meta {
  display: flex;
  flex-direction: column;
  gap: .55rem;
  margin-bottom: 1.1rem;
  padding: 1rem;
  background: var(--bg);
  border-radius: var(--radius);
}

.modal-meta-item {
  display: flex;
  align-items: flex-start;
  gap: .6rem;
  font-size: .88rem;
  color: var(--text);
}

.meta-icon { flex-shrink: 0; font-size: .95rem; }

.format-badge {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .15rem .6rem;
  border-radius: 20px;
  font-size: .75rem;
  font-weight: 600;
}

.format-presentiel  { background: #ECFDF5; color: #047857; }
.format-en-ligne    { background: #EFF6FF; color: #1D4ED8; }
.format-hybride     { background: #F5F3FF; color: #6D28D9; }

.modal-description {
  font-size: .9rem;
  line-height: 1.65;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.modal-tags {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
  margin-bottom: 1.25rem;
}

.tag {
  background: var(--bg);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: .2rem .65rem;
  font-size: .75rem;
}

.modal-actions {
  display: flex;
  gap: .75rem;
  flex-wrap: wrap;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.btn-primary {
  flex: 1;
  min-width: 140px;
  padding: .65rem 1.1rem;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: .88rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s;
}

.btn-primary:hover { background: var(--primary-dark); }

.btn-secondary {
  flex: 1;
  min-width: 140px;
  padding: .65rem 1.1rem;
  background: var(--surface);
  color: var(--text);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: .88rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  transition: border-color .15s, background .15s;
}

.btn-secondary:hover {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary);
}

body.modal-open { overflow: hidden; }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
    padding: 1rem;
  }

  .filters-panel {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 150;
    border-radius: 0;
    overflow-y: auto;
    transform: translateX(-100%);
    transition: transform .25s ease;
    max-width: 320px;
    box-shadow: var(--shadow-lg);
  }

  .filters-panel.open {
    transform: translateX(0);
  }

  .btn-filters-toggle { display: flex; }

  .filters-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15,23,42,.4);
    z-index: 149;
    display: none;
  }

  .filters-overlay.visible { display: block; }
}

@media (max-width: 640px) {
  .brand-sub { display: none; }
  .nav-label { font-size: .95rem; min-width: 150px; }
  .day-cell { min-height: 72px; }
  .week-grid { grid-template-columns: repeat(7, 1fr); }
  .week-event-title { display: none; }
  .week-day-header { padding: .5rem .25rem .4rem; }
  .week-day-num { font-size: 1rem; width: 28px; height: 28px; }
  .modal-body { padding: 1.25rem; }
  .modal-actions { flex-direction: column; }
  .btn-primary, .btn-secondary { flex: none; width: 100%; }
}
