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

:root {
  --gold:   #f0b429;
  --violet: #9b72f5;
  --green:  #34d399;
  --blue:   #60a5fa;
}
[data-theme="dark"] {
  --bg:      #13151f;
  --surface: #1a1d2b;
  --border:  #272b3d;
  --text:    #e2e4f0;
  --muted:   #6b7280;
  --shadow:  rgba(0,0,0,0.6);
}
[data-theme="light"] {
  --bg:      #f0f2f7;
  --surface: #ffffff;
  --border:  #dde1ea;
  --text:    #1a1d2b;
  --muted:   #6b7280;
  --shadow:  rgba(0,0,0,0.1);
}

html, body { height: 100%; overflow: hidden; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  transition: background .2s, color .2s;
}

/* ══ Header ══ */
#header {
  height: 54px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 10px var(--shadow);
  position: relative;
  z-index: 1000;
  transition: background .2s, border-color .2s;
}

.logo { font-size: 1.05rem; font-weight: 700; letter-spacing: -.4px; white-space: nowrap; }
.logo em { color: var(--gold); font-style: normal; }
.sep { width: 1px; height: 20px; background: var(--border); flex-shrink: 0; }

/* ── Search ── */
.search-wrap { position: relative; flex: 1; max-width: 420px; }
.search-icon {
  position: absolute; left: 10px; top: 50%;
  transform: translateY(-50%);
  color: var(--muted); pointer-events: none; font-size: .85rem;
}
#search-input {
  width: 100%;
  background: var(--bg); border: 1.5px solid var(--border);
  border-radius: 8px; color: var(--text);
  padding: 7px 12px 7px 32px; font-size: .875rem;
  outline: none; transition: border-color .15s, background .2s;
}
#search-input:focus { border-color: var(--gold); }
#search-input::placeholder { color: var(--muted); }

#search-dropdown {
  position: absolute;
  top: calc(100% + 6px); left: 0; right: 0;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; box-shadow: 0 8px 32px var(--shadow);
  display: none; z-index: 9999;
  max-height: 400px; overflow-y: auto;
}
#search-dropdown.show { display: block; }
#search-dropdown::-webkit-scrollbar { width: 4px; }
#search-dropdown::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.dd-section + .dd-section { border-top: 1px solid var(--border); }
.dd-label { padding: 8px 14px 3px; font-size: .67rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.dd-item { display: flex; align-items: center; gap: 10px; padding: 8px 14px; cursor: pointer; transition: background .1s; }
.dd-item:hover { background: rgba(128,128,128,.07); }
.dd-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.dd-poster { width: 28px; height: 40px; object-fit: cover; border-radius: 3px; background: var(--bg); flex-shrink: 0; }
.dd-poster-ph { width: 28px; height: 40px; background: var(--bg); border-radius: 3px; display: flex; align-items: center; justify-content: center; font-size: 1rem; flex-shrink: 0; }
.dd-main { font-size: .85rem; line-height: 1.3; }
.dd-sub  { font-size: .74rem; color: var(--muted); margin-top: 1px; }
.dd-empty { padding: 16px; text-align: center; color: var(--muted); font-size: .82rem; }

/* ── Filters ── */
.filters { display: flex; align-items: center; gap: 6px; margin-left: auto; flex-shrink: 0; }

.select-wrap { position: relative; }
.select-wrap::after {
  content: '▾'; position: absolute; right: 8px; top: 50%;
  transform: translateY(-50%); pointer-events: none;
  color: var(--muted); font-size: .7rem;
}
#dept-filter {
  appearance: none; -webkit-appearance: none;
  background: var(--bg); border: 1.5px solid var(--border);
  color: var(--text); padding: 6px 26px 6px 10px;
  border-radius: 8px; font-size: .82rem; font-weight: 500;
  cursor: pointer; outline: none;
  transition: border-color .15s, background .2s;
}
#dept-filter:hover { border-color: var(--muted); }
#dept-filter:focus { border-color: var(--gold); }

/* Date pills */
.date-picker {
  display: flex; align-items: center; gap: 3px;
  background: var(--bg); border: 1.5px solid var(--border);
  border-radius: 8px; padding: 3px;
  transition: border-color .15s, background .2s;
}
.date-picker:focus-within { border-color: var(--gold); }
.dp-pill {
  padding: 3px 9px; border-radius: 5px; font-size: .78rem; font-weight: 500;
  cursor: pointer; border: none; background: none;
  color: var(--muted); white-space: nowrap;
  transition: background .12s, color .12s;
}
.dp-pill:hover { background: rgba(128,128,128,.12); color: var(--text); }
.dp-pill.active { background: var(--gold); color: #1a1200; }
.dp-sep { width: 1px; height: 14px; background: var(--border); }
.dp-input {
  padding: 2px 6px; background: none; border: none;
  color: var(--text); font-size: .78rem;
  cursor: pointer; outline: none; width: 108px;
}
.dp-input::-webkit-calendar-picker-indicator { opacity: .5; cursor: pointer; }

/* Art & Essai */
.aae-btn {
  display: flex; align-items: center; gap: 6px;
  background: var(--bg); border: 1.5px solid var(--border);
  border-radius: 8px; padding: 5px 10px;
  cursor: pointer; font-size: .8rem; color: var(--muted);
  font-weight: 500; transition: border-color .15s, color .15s, background .15s;
  white-space: nowrap; user-select: none;
}
.aae-btn:hover { border-color: var(--muted); color: var(--text); }
.aae-btn.on { border-color: var(--violet); color: var(--violet); background: rgba(155,114,245,.1); }
.aae-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--violet); opacity: .35; transition: opacity .15s; }
.aae-btn.on .aae-dot { opacity: 1; }

.badge {
  background: var(--bg); border: 1.5px solid var(--border);
  padding: 5px 10px; border-radius: 8px; font-size: .78rem;
  color: var(--muted); font-weight: 500; white-space: nowrap;
}
.badge strong { color: var(--gold); }

.theme-btn {
  background: var(--bg); border: 1.5px solid var(--border);
  width: 34px; height: 34px; border-radius: 8px;
  cursor: pointer; font-size: 1rem;
  display: flex; align-items: center; justify-content: center;
  transition: border-color .15s, background .2s; flex-shrink: 0;
}
.theme-btn:hover { border-color: var(--gold); }

/* ══ Body layout ══ */
#body-wrap {
  position: relative;
  flex: 1;
  display: flex;
  min-height: 0;
}

#map {
  flex: 1;
  min-width: 0;
  min-height: 0;
}

/* ══ Panel ══ */
#panel {
  width: 340px; flex-shrink: 0;
  background: var(--surface); border-left: 1px solid var(--border);
  display: flex; flex-direction: column; overflow: hidden;
  transform: translateX(100%);
  transition: transform .22s cubic-bezier(.4,0,.2,1), background .2s, border-color .2s;
  z-index: 500;
  position: relative;
}
#panel.open { transform: translateX(0); }

.ph { padding: 14px 16px 10px; border-bottom: 1px solid var(--border); flex-shrink: 0; position: relative; }
.ph h2 { font-size: .95rem; font-weight: 600; padding-right: 26px; line-height: 1.35; }
.ph-meta { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 7px; }
.tag { font-size: .72rem; background: var(--bg); border: 1px solid var(--border); padding: 2px 8px; border-radius: 20px; color: var(--muted); }
.tag.aae { border-color: var(--violet); color: var(--violet); }

.close-btn {
  position: absolute; top: 12px; right: 12px;
  background: none; border: none; color: var(--muted);
  font-size: 1rem; cursor: pointer;
  width: 22px; height: 22px; display: flex; align-items: center; justify-content: center;
  border-radius: 4px; transition: background .1s, color .1s;
}
.close-btn:hover { background: rgba(128,128,128,.1); color: var(--text); }

.date-nav { display: flex; align-items: center; padding: 8px 14px; gap: 8px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.date-nav button { background: var(--bg); border: 1px solid var(--border); color: var(--text); width: 26px; height: 26px; border-radius: 6px; cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: .9rem; flex-shrink: 0; transition: border-color .15s; }
.date-nav button:hover { border-color: var(--gold); }
.date-nav span { flex: 1; text-align: center; font-size: .8rem; color: var(--muted); text-transform: capitalize; }

.panel-body { flex: 1; overflow-y: auto; min-height: 0; }
.panel-body::-webkit-scrollbar { width: 3px; }
.panel-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.empty-msg { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 160px; color: var(--muted); font-size: .82rem; gap: 8px; padding: 20px; text-align: center; }
.empty-msg .icon { font-size: 2rem; opacity: .35; }

.movie-card { display: flex; gap: 11px; padding: 10px 14px; border-bottom: 1px solid var(--border); transition: background .1s; }
.movie-card:hover { background: rgba(128,128,128,.04); }
.poster { width: 48px; height: 68px; object-fit: cover; border-radius: 4px; background: var(--bg); flex-shrink: 0; }
.poster-ph { width: 48px; height: 68px; background: var(--bg); border-radius: 4px; display: flex; align-items: center; justify-content: center; font-size: 1.3rem; flex-shrink: 0; }
.movie-info { flex: 1; min-width: 0; }
.movie-title { font-size: .83rem; font-weight: 500; line-height: 1.35; margin-bottom: 7px; }
.times { display: flex; flex-wrap: wrap; gap: 4px; }
.chip { display: inline-flex; align-items: center; gap: 3px; background: var(--bg); border: 1px solid var(--border); border-radius: 5px; padding: 2px 6px; font-size: .72rem; font-variant-numeric: tabular-nums; }
.ver { font-size: .62rem; font-weight: 700; padding: 1px 3px; border-radius: 3px; }
.ver.vo { background: rgba(52,211,153,.15); color: var(--green); }
.ver.vf { background: rgba(96,165,250,.15); color: var(--blue); }

/* ══ Leaflet ══ */
[data-theme="dark"]  .leaflet-popup-content-wrapper,
[data-theme="dark"]  .leaflet-popup-tip  { background: #1a1d2b; color: #e2e4f0; }
[data-theme="light"] .leaflet-popup-content-wrapper,
[data-theme="light"] .leaflet-popup-tip  { background: #fff; color: #1a1d2b; }
.leaflet-popup-content-wrapper { border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 4px 20px var(--shadow); font-family: inherit; }
[data-theme="dark"]  .leaflet-control-zoom a { background: #1a1d2b; color: #e2e4f0; border-color: #272b3d; }
[data-theme="light"] .leaflet-control-zoom a { background: #fff; color: #1a1d2b; border-color: #dde1ea; }
.leaflet-control-zoom a:hover { border-color: var(--gold) !important; }

/* ── Panel accueil ── */
#welcome {
  flex: 1; overflow-y: auto; padding: 16px 14px;
  display: flex; flex-direction: column; gap: 16px;
}
#welcome::-webkit-scrollbar { width: 3px; }
#welcome::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.w-stats {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.w-stat {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 10px; padding: 12px 14px;
}
.w-stat .val { font-size: 1.5rem; font-weight: 700; color: var(--gold); line-height: 1; }
.w-stat .lbl { font-size: .72rem; color: var(--muted); margin-top: 4px; }

.w-section-title {
  font-size: .72rem; font-weight: 600; letter-spacing: .07em;
  text-transform: uppercase; color: var(--muted);
  padding-bottom: 6px; border-bottom: 1px solid var(--border);
}

.w-movie {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 0; border-bottom: 1px solid var(--border);
  cursor: pointer; transition: opacity .15s;
}
.w-movie:last-child { border-bottom: none; }
.w-movie:hover { opacity: .75; }
.w-poster {
  width: 36px; height: 52px; object-fit: cover;
  border-radius: 4px; background: var(--bg); flex-shrink: 0;
}
.w-poster-ph {
  width: 36px; height: 52px; background: var(--bg);
  border-radius: 4px; display: flex; align-items: center;
  justify-content: center; font-size: 1.1rem; flex-shrink: 0;
}
.w-movie-info { flex: 1; min-width: 0; }
.w-movie-title { font-size: .83rem; font-weight: 500; line-height: 1.3; }
.w-movie-sub { font-size: .74rem; color: var(--muted); margin-top: 3px; }
.w-rank {
  font-size: .72rem; font-weight: 700; color: var(--muted);
  flex-shrink: 0; width: 18px; text-align: right;
}

/* ── Bannière filtre actif ── */
#filter-bar {
  display: none;
  position: absolute;
  top: 12px; left: 50%; transform: translateX(-50%);
  z-index: 900;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 6px 8px 6px 14px;
  box-shadow: 0 4px 16px var(--shadow);
  align-items: center;
  gap: 8px;
  font-size: .82rem;
  white-space: nowrap;
  max-width: calc(100% - 120px);
}
#filter-bar.show { display: flex; }
#filter-bar .fb-label { color: var(--muted); }
#filter-bar .fb-title {
  font-weight: 600; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; max-width: 240px;
}
#filter-bar .fb-count {
  background: var(--gold); color: #1a1200;
  font-size: .72rem; font-weight: 700;
  padding: 1px 6px; border-radius: 10px;
}
#filter-bar .fb-reset {
  background: none; border: 1px solid var(--border);
  border-radius: 14px; padding: 3px 10px;
  cursor: pointer; font-size: .78rem; color: var(--muted);
  transition: border-color .15s, color .15s;
  flex-shrink: 0;
}
#filter-bar .fb-reset:hover { border-color: var(--text); color: var(--text); }
