/* ==========================================================================
   UltraPC – Page « Nos magasins » (templates/cms/stores.tpl)
   Tout est préfixé .upc-mag pour ne rien casser dans le thème / Bootstrap.
   Chargé uniquement sur la page Magasins (hors bundle CCC) : changer le
   paramètre ?v= dans stores.tpl après modification.
   ========================================================================== */

/* Variables : aussi sur la modal, déplacée dans <body> par le JS */
.upc-mag, .upc-mag-modal {
  --mag-navy: #002B49;
  --mag-navy-2: #00335a;
  --mag-navy-50: #eef4f9;
  --mag-navy-100: #d6e4ef;
  --mag-orange: #f39200;
  --mag-orange-dark: #d98200;
  --mag-bg: #f1f5f9;
  --mag-border: #e2e8f0;
  --mag-text: #334155;
  --mag-muted: #64748b;
  --mag-green: #059669;
  --mag-amber: #b45309;
  --mag-red: #dc2626;
  --mag-radius: 16px;
}
.upc-mag-modal { font-size: 14px; line-height: 1.5; }
.upc-mag-modal *, .upc-mag-modal *::before, .upc-mag-modal *::after { box-sizing: border-box; }
.upc-mag-modal p { margin: 0; }

.upc-mag {
  background: var(--mag-bg);
  border-radius: var(--mag-radius);
  padding: 0 0 24px;
  margin: 0 0 24px;
  color: var(--mag-text);
  font-size: 14px;
  line-height: 1.5;
}
.upc-mag *, .upc-mag *::before, .upc-mag *::after { box-sizing: border-box; }
.upc-mag p { margin: 0; }
.upc-mag svg { flex-shrink: 0; }

/* Éléments qui n'ont de sens qu'avec JavaScript */
.upc-mag:not(.is-ready) .upc-mag-js-only { display: none !important; }

/* ---------- Hero ---------- */
.upc-mag-hero {
  position: relative;
  overflow: hidden;
  display: grid;
  gap: 28px;
  align-items: end;
  padding: 36px 32px 44px;
  border-radius: var(--mag-radius) var(--mag-radius) 0 0;
  background: linear-gradient(180deg, var(--mag-navy), var(--mag-navy-2));
  color: #fff;
}
.upc-mag-hero::before { /* trame discrète */
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(#fff 1px, transparent 1px);
  background-size: 22px 22px;
  opacity: .06;
  pointer-events: none;
}
.upc-mag-hero::after { /* liseré arc-en-ciel du logo */
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 4px;
  background: linear-gradient(90deg, #e63b2e 0 25%, #f5b800 25% 50%, #3fae49 50% 75%, #1e88e5 75% 100%);
}
.upc-mag-hero > * { position: relative; }
@media (min-width: 992px) {
  .upc-mag-hero { grid-template-columns: 1fr 360px; padding: 48px 40px 52px; }
}

.upc-mag-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px;
  border-radius: 999px;
  background: rgba(255,255,255,.1);
  color: var(--mag-orange);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.upc-mag-eyebrow span { width: 6px; height: 6px; border-radius: 50%; background: var(--mag-orange); }

.upc-mag .upc-mag-title {
  margin: 14px 0 0;
  color: #fff;
  font-size: 30px;
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -.01em;
  text-transform: none;
}
@media (min-width: 768px) { .upc-mag .upc-mag-title { font-size: 40px; } }

.upc-mag-lead { max-width: 640px; margin-top: 12px !important; color: rgba(255,255,255,.78); font-size: 15px; }
.upc-mag-lead strong { color: #fff; }

.upc-mag-stats { display: flex; flex-wrap: wrap; gap: 12px 32px; margin: 22px 0 0; }
.upc-mag-stats dt { color: rgba(255,255,255,.6); font-size: 12px; font-weight: 500; }
.upc-mag-stats dd { margin: 0; color: #fff; font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }

/* Bouton géolocalisation */
.upc-mag-geo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 15px 20px;
  border: 0;
  border-radius: 12px;
  background: var(--mag-orange);
  box-shadow: 0 10px 24px -8px rgba(243,146,0,.55);
  color: #fff;
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: transform .15s, background-color .15s;
}
.upc-mag-geo:hover { background: var(--mag-orange-dark); transform: translateY(-2px); }
.upc-mag-geo:focus-visible { outline: 3px solid rgba(243,146,0,.45); outline-offset: 2px; }
.upc-mag-geo[disabled] { cursor: wait; opacity: .85; transform: none; }
.upc-mag-geo svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.2; }
.upc-mag-geo-spin { display: none; animation: upc-mag-spin .8s linear infinite; }
.upc-mag-geo.is-loading .upc-mag-geo-spin { display: block; }
.upc-mag-geo.is-loading .upc-mag-geo-icon { display: none; }
.upc-mag-geo-spin circle, .upc-mag-geo-spin path { stroke-width: 3; stroke-linecap: round; }

.upc-mag-geo-msg { min-height: 20px; margin-top: 10px !important; color: rgba(255,255,255,.72); font-size: 13px; text-align: center; }
.upc-mag-geo-msg strong { color: #fff; }

.upc-mag-support {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 14px;
  padding: 10px 14px;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 10px;
  color: rgba(255,255,255,.85) !important;
  font-size: 13px;
  text-decoration: none !important;
  transition: background-color .15s;
}
.upc-mag-support:hover { background: rgba(255,255,255,.08); }
.upc-mag-support strong { color: #fff; font-variant-numeric: tabular-nums; }
.upc-mag-support svg { width: 16px; height: 16px; fill: none; stroke: var(--mag-orange); stroke-width: 2; }

/* ---------- Barre de filtres ---------- */
.upc-mag-toolbar {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: -22px 16px 22px;
  padding: 10px;
  border: 1px solid var(--mag-border);
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 1px 3px rgba(15,23,42,.06);
}
@media (min-width: 768px) {
  .upc-mag-toolbar { flex-direction: row; align-items: center; justify-content: space-between; margin: -24px 24px 24px; }
}
.upc-mag-chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.upc-mag-chips::-webkit-scrollbar { display: none; }
.upc-mag-chip {
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: #475569;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color .15s, color .15s;
}
.upc-mag-chip:hover { background: #f1f5f9; }
.upc-mag-chip span { padding: 0 6px; border-radius: 5px; background: #f1f5f9; color: var(--mag-muted); font-size: 11px; }
.upc-mag-chip.is-active { background: var(--mag-navy); color: #fff; }
.upc-mag-chip.is-active span { background: rgba(255,255,255,.15); color: #fff; }
.upc-mag-chip:focus-visible { outline: 2px solid var(--mag-navy); outline-offset: 1px; }

.upc-mag-switch { display: flex; flex-shrink: 0; align-items: center; gap: 8px; margin: 0; padding: 0 4px; color: #475569; font-size: 13px; font-weight: 600; cursor: pointer; }
.upc-mag-switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.upc-mag-switch-track { position: relative; width: 36px; height: 20px; border-radius: 999px; background: #cbd5e1; transition: background-color .15s; }
.upc-mag-switch-track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.2); transition: transform .15s; }
.upc-mag-switch input:checked + .upc-mag-switch-track { background: #10b981; }
.upc-mag-switch input:checked + .upc-mag-switch-track::after { transform: translateX(16px); }
.upc-mag-switch input:focus-visible + .upc-mag-switch-track { outline: 2px solid #6ee7b7; outline-offset: 2px; }

/* Sans JS, la grille démarre juste sous le hero */
.upc-mag:not(.is-ready) .upc-mag-grid { margin-top: 24px; }

/* ---------- Grille ---------- */
.upc-mag-grid { display: grid; gap: 22px; padding: 0 16px; }
@media (min-width: 640px)  { .upc-mag-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 768px)  { .upc-mag-grid { padding: 0 24px; } }
@media (min-width: 1200px) { .upc-mag-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

/* ---------- Carte magasin ---------- */
.upc-mag-card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--mag-border);
  border-radius: var(--mag-radius);
  background: #fff;
  box-shadow: 0 1px 2px rgba(15,23,42,.04), 0 1px 3px rgba(15,23,42,.06);
  transition: transform .3s, box-shadow .3s, border-color .3s;
  scroll-margin-top: 120px;
}
.upc-mag-card:hover { transform: translateY(-4px); box-shadow: 0 14px 32px -10px rgba(0,43,73,.22); }
.upc-mag-card.is-nearest { border-color: var(--mag-orange); box-shadow: 0 0 0 3px rgba(243,146,0,.25); }
.upc-mag-card.is-targeted { animation: upc-mag-flash 1.6s ease-out; }
.upc-mag-card[hidden] { display: none !important; }

.upc-mag-photo { position: relative; overflow: hidden; aspect-ratio: 16 / 10; background: linear-gradient(135deg, var(--mag-navy), #003a63); }
.upc-mag-photo::after { content: ""; position: absolute; inset: 0; background: linear-gradient(0deg, rgba(15,23,42,.5), transparent 45%, rgba(15,23,42,.12)); pointer-events: none; }
.upc-mag-photo-fallback { position: absolute; top: 50%; left: 50%; width: 50%; height: auto; opacity: .3; transform: translate(-50%, -50%); }
.upc-mag-photo-img { position: relative; display: block; width: 100%; height: 100%; object-fit: cover; transition: transform .5s ease-out; }
.upc-mag-card:hover .upc-mag-photo-img { transform: scale(1.05); }

.upc-mag-city, .upc-mag-badge, .upc-mag-distance {
  position: absolute;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.4;
  box-shadow: 0 1px 3px rgba(0,0,0,.12);
}
.upc-mag-city { top: 12px; left: 12px; background: rgba(255,255,255,.95); color: var(--mag-navy); letter-spacing: .04em; text-transform: uppercase; }
.upc-mag-city svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; }
.upc-mag-badge-slot { position: absolute; top: 12px; right: 12px; z-index: 1; }
.upc-mag-badge { position: static; }
.upc-mag-distance { bottom: 12px; left: 12px; background: rgba(0,43,73,.92); color: #fff; }
.upc-mag-card.is-nearest .upc-mag-distance { background: var(--mag-orange); }
.upc-mag-distance svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 2.4; }

/* Badges de statut */
.upc-mag-badge.is-open   { background: #ecfdf5; color: #047857; box-shadow: inset 0 0 0 1px #a7f3d0, 0 1px 3px rgba(0,0,0,.12); }
.upc-mag-badge.is-soon   { background: #fffbeb; color: var(--mag-amber); box-shadow: inset 0 0 0 1px #fde68a, 0 1px 3px rgba(0,0,0,.12); }
.upc-mag-badge.is-closed { background: #fef2f2; color: #b91c1c; box-shadow: inset 0 0 0 1px #fecaca, 0 1px 3px rgba(0,0,0,.12); }
.upc-mag-dot { position: relative; display: inline-flex; width: 8px; height: 8px; }
.upc-mag-dot::before, .upc-mag-dot::after { content: ""; position: absolute; inset: 0; border-radius: 50%; background: currentColor; }
.upc-mag-badge.is-open .upc-mag-dot { color: #10b981; }
.upc-mag-badge.is-soon .upc-mag-dot { color: #f59e0b; }
.upc-mag-badge.is-closed .upc-mag-dot { color: #ef4444; }
.upc-mag-badge.is-open .upc-mag-dot::before,
.upc-mag-badge.is-soon .upc-mag-dot::before { animation: upc-mag-ping 1.4s cubic-bezier(0,0,.2,1) infinite; opacity: .75; }

/* Corps */
.upc-mag-body { display: flex; flex: 1; flex-direction: column; padding: 20px; }
.upc-mag .upc-mag-name { margin: 0; color: var(--mag-navy); font-size: 18px; font-weight: 700; line-height: 1.3; text-transform: none; }
.upc-mag-status-detail { display: flex; align-items: center; gap: 6px; margin-top: 4px !important; font-size: 13px; font-weight: 500; }
.upc-mag-status-detail svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; }
.upc-mag-status-detail.is-open { color: var(--mag-green); }
.upc-mag-status-detail.is-soon { color: var(--mag-amber); }
.upc-mag-status-detail.is-closed { color: var(--mag-red); }

.upc-mag-info { margin: 16px 0 0; font-style: normal; color: #475569; }
.upc-mag-info p { display: flex; gap: 8px; margin-top: 8px; }
.upc-mag-info p:first-child { margin-top: 0; }
.upc-mag-info svg { width: 16px; height: 16px; margin-top: 2px; fill: none; stroke: var(--mag-orange); stroke-width: 2; }
.upc-mag-info a { color: var(--mag-navy); word-break: break-word; }
.upc-mag-info a:hover { color: var(--mag-orange); text-decoration: underline; }
.upc-mag-tel { font-weight: 700; font-variant-numeric: tabular-nums; }
.upc-mag-note { padding-left: 24px; color: var(--mag-muted); font-size: 13px; }

/* Boutons */
.upc-mag-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 18px; }
.upc-mag-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 10px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.3;
  text-align: center;
  text-decoration: none !important;
  cursor: pointer;
  transition: background-color .15s, border-color .15s, color .15s;
}
.upc-mag-btn svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; }
.upc-mag-actions .upc-mag-btn { gap: 6px; padding: 10px 8px; white-space: nowrap; }
.upc-mag-btn-outline { border-color: var(--mag-border); background: #fff; color: var(--mag-navy) !important; }
.upc-mag-btn-outline:hover { border-color: var(--mag-navy); background: var(--mag-navy); color: #fff !important; }
.upc-mag-btn-solid { background: var(--mag-orange); color: #fff !important; }
.upc-mag-btn-solid:hover { background: var(--mag-orange-dark); }
.upc-mag-btn:focus-visible { outline: 2px solid var(--mag-navy); outline-offset: 2px; }

/* Horaires */
.upc-mag-hours { margin-top: 18px; padding-top: 14px; border-top: 1px solid #f1f5f9; }
.upc-mag-hours-title { margin-bottom: 8px !important; color: #94a3b8; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.upc-mag-hours ul { margin: 0; padding: 0; list-style: none; font-size: 13px; }
.upc-mag-hours li { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 2px; padding: 5px 10px; border-radius: 7px; color: #475569; }
.upc-mag-hours li.is-weekend { background: #f8fafc; }
.upc-mag-hours li.is-closed { background: rgba(254,242,242,.6); color: var(--mag-muted); }
.upc-mag-hours li.is-closed .upc-mag-time { color: var(--mag-red); font-weight: 600; }
.upc-mag-hours li.is-today { background: var(--mag-navy-50); box-shadow: inset 0 0 0 1px var(--mag-navy-100); color: var(--mag-navy); font-weight: 700; }
.upc-mag-day { display: flex; align-items: center; gap: 8px; }
.upc-mag-time { text-align: right; font-variant-numeric: tabular-nums; }
.upc-mag-today { padding: 1px 6px; border-radius: 4px; background: var(--mag-orange); color: #fff; font-size: 10px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }

/* État vide */
.upc-mag-empty { margin: 0 16px; padding: 40px 20px; border: 1px dashed #cbd5e1; border-radius: var(--mag-radius); background: #fff; text-align: center; }
.upc-mag-empty-title { color: var(--mag-navy); font-size: 17px; font-weight: 700; }
.upc-mag-empty p + p { margin-top: 4px; color: var(--mag-muted); }
.upc-mag-empty .upc-mag-btn { margin-top: 16px; }
@media (min-width: 768px) { .upc-mag-empty { margin: 0 24px; } }

/* ---------- Modal carte ---------- */
.upc-mag-modal { position: fixed; inset: 0; z-index: 100000; display: flex; align-items: flex-end; justify-content: center; }
.upc-mag-modal[hidden] { display: none !important; }
.upc-mag-modal-backdrop { position: absolute; inset: 0; background: rgba(15,23,42,.6); backdrop-filter: blur(3px); }
.upc-mag-modal-box {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 900px;
  max-height: 100%;
  overflow: hidden;
  border-radius: 16px 16px 0 0;
  background: #fff;
  box-shadow: 0 25px 50px -12px rgba(0,0,0,.35);
  animation: upc-mag-in .25s ease-out;
}
@media (min-width: 640px) {
  .upc-mag-modal { align-items: center; padding: 24px; }
  .upc-mag-modal-box { border-radius: 16px; }
}
.upc-mag-modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 16px 20px; border-bottom: 1px solid var(--mag-border); }
.upc-mag-modal-head > div { min-width: 0; }
.upc-mag-modal-title { overflow: hidden; color: var(--mag-navy); font-size: 18px; font-weight: 700; white-space: nowrap; text-overflow: ellipsis; }
.upc-mag-modal-address { margin-top: 2px !important; color: var(--mag-muted); font-size: 13px; }
.upc-mag-modal-close { flex-shrink: 0; width: 36px; height: 36px; margin: -4px -6px 0 0; border: 0; border-radius: 9px; background: transparent; color: #94a3b8; font-size: 26px; line-height: 1; cursor: pointer; }
.upc-mag-modal-close:hover { background: #f1f5f9; color: #334155; }
.upc-mag-modal-close:focus-visible { outline: 2px solid var(--mag-navy); }
.upc-mag-modal-map { position: relative; aspect-ratio: 4 / 3; background: #f1f5f9; }
@media (min-width: 640px) { .upc-mag-modal-map { aspect-ratio: 16 / 9; } }
.upc-mag-modal-map span { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #94a3b8; font-size: 13px; }
.upc-mag-modal-map iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.upc-mag-modal-foot { display: flex; flex-direction: column; gap: 8px; padding: 14px 20px; }
@media (min-width: 640px) { .upc-mag-modal-foot { flex-direction: row; justify-content: flex-end; } }
body.upc-mag-lock { overflow: hidden; }

/* ---------- Animations ---------- */
@keyframes upc-mag-ping { 75%, 100% { transform: scale(2.2); opacity: 0; } }
@keyframes upc-mag-spin { to { transform: rotate(360deg); } }
@keyframes upc-mag-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes upc-mag-flash { 0%, 40% { box-shadow: 0 0 0 4px rgba(243,146,0,.45); } 100% { box-shadow: 0 1px 3px rgba(15,23,42,.06); } }

@media (prefers-reduced-motion: reduce) {
  .upc-mag *, .upc-mag *::before, .upc-mag *::after { animation: none !important; transition: none !important; }
  .upc-mag-card:hover, .upc-mag-card:hover .upc-mag-photo-img { transform: none; }
}

/* Mobile : marges réduites */
@media (max-width: 575px) {
  .upc-mag { --mag-radius: 12px; }
  .upc-mag-hero { padding: 28px 20px 40px; }
  .upc-mag-body { padding: 16px; }
}
