/* ==========================================================================
   Sitefan — CSS Mobile-First
   Thème sombre par défaut, thème clair complet
   ========================================================================== */

/* --- Variables — Dark theme (default) --- */
:root {
  --bg: #0e0f12;
  --bg-soft: #151720;
  --text: #e8e9ee;
  --muted: #a8adbb;
  --brand-1: #6f42c1;
  --brand-2: #d63384;
  --accent: #9f59d0;
  --border: #252a36;
  --card: #141824;
  --success: #16a34a;
  --success-soft: #14351f;
  --success-text: #d1fae5;
  --warning: #f59e0b;
  --warning-soft: #422006;
  --warning-text: #fef3c7;
  --danger: #ef4444;
  --danger-soft: #2a1212;
  --danger-text: #fecaca;
  --info-soft: #101a2d;
  --info-text: #c7d2fe;
  --info-border: #1e3a8a;
  --nav-bg: #0f1422;
  --nav-hover: #1b2030;
  --header-bg: rgba(10,12,18,0.85);
  --link: #c4b5d9;
  --link-hover: #e0d4f0;
  --footer-bg: #0e1018;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
}

/* --- Variables — Light theme --- */
body[data-theme="light"] {
  --bg: #f7f7fb;
  --bg-soft: #ffffff;
  --text: #0f1422;
  --muted: #4b5563;
  --brand-1: #6f42c1;
  --brand-2: #d63384;
  --accent: #7c3aed;
  --border: #e5e7eb;
  --card: #ffffff;
  --success: #16a34a;
  --success-soft: #dcfce7;
  --success-text: #14532d;
  --warning: #f59e0b;
  --warning-soft: #fef9c3;
  --warning-text: #713f12;
  --danger: #ef4444;
  --danger-soft: #fee2e2;
  --danger-text: #991b1b;
  --info-soft: #e0e7ff;
  --info-text: #3730a3;
  --info-border: #a5b4fc;
  --nav-bg: #ffffff;
  --nav-hover: #f3f4f6;
  --header-bg: rgba(255,255,255,0.85);
  --link: #5a5370;
  --link-hover: #3d3556;
  --footer-bg: #f3f4f6;
}

/* ==========================================================================
   Reset & Base
   ========================================================================== */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body.layout {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  line-height: 1.5;
  display: flex;
  flex-direction: column;
}

/* ==========================================================================
   Layout
   ========================================================================== */
.container { width: 100%; max-width: 1100px; margin: 0 auto; padding: 0 16px; }
.content { padding: 16px 0 56px; flex: 1; }
.content > :first-child { margin-top: 12px; }

/* ==========================================================================
   Header & Navigation — Mobile-first
   ========================================================================== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--header-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  padding-top: var(--safe-top);
}
.header-inner {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  min-height: 48px;
}
.brand {
  color: var(--text);
  font-weight: 700;
  letter-spacing: .2px;
  text-decoration: none;
  font-size: 16px;
  white-space: nowrap;
  flex-shrink: 0;
}

/* Nav toggle — visible by default (mobile-first), hidden on desktop */
.nav-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: auto;
  background: var(--nav-hover);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  z-index: 52;
}

/* Nav dropdown — hidden by default on mobile */
.site-nav {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: var(--nav-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  flex-direction: column;
  gap: 4px;
  z-index: 51;
  box-shadow: 0 14px 30px rgba(0,0,0,.3);
}
.site-nav.open { display: flex; }
.site-nav ul { display: flex; flex-direction: column; gap: 2px; padding: 0; margin: 0; list-style: none; }
.site-nav a {
  display: block;
  color: var(--text);
  text-decoration: none;
  padding: 10px 12px;
  border-radius: 8px;
  transition: background .15s ease;
  font-size: 15px;
}
.site-nav a:hover { background: var(--nav-hover); }
.site-nav .nav-right { border-top: 1px solid var(--border); margin-top: 4px; padding-top: 4px; }

/* Desktop nav — min-width 901px */
@media (min-width: 901px) {
  .nav-toggle { display: none; }
  .site-nav {
    display: flex;
    position: static;
    background: none;
    border: none;
    border-radius: 0;
    padding: 0;
    flex-direction: row;
    gap: 8px;
    align-items: center;
    margin-left: auto;
    box-shadow: none;
  }
  .site-nav ul { flex-direction: row; gap: 4px; }
  .site-nav a { padding: 6px 10px; font-size: 14px; }
  .site-nav .nav-right { border-top: none; margin-top: 0; padding-top: 0; }
  .header-inner { padding: 14px 0; }
  .brand { font-size: 18px; }
}

/* ==========================================================================
   Secondary nav & Subnav
   ========================================================================== */
.secondary-nav { border-bottom: 1px solid var(--border); background: var(--bg-soft); }
.secondary-nav .container { padding-top: 8px; padding-bottom: 8px; }
.subnav { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 0; margin: 0; list-style: none; }
.subnav a { color: var(--muted); text-decoration: none; padding: 4px 8px; border-radius: 6px; font-size: 14px; }
.subnav a:hover { color: var(--text); background: var(--nav-hover); }

/* ==========================================================================
   Typography
   ========================================================================== */
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 12px; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.1rem; }
p { margin: 0 0 12px; color: var(--muted); }

/* Links — neutre, pas de bleu flashy */
a { color: var(--link); text-decoration: none; transition: color .15s ease; }
a:hover { color: var(--link-hover); }
a:visited { color: var(--link); }

@media (min-width: 681px) {
  h1 { font-size: 1.75rem; }
  h2 { font-size: 1.4rem; }
  h3 { font-size: 1.2rem; }
}
@media (min-width: 1001px) {
  h1 { font-size: 2rem; }
}

/* ==========================================================================
   Buttons
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 10px;
  padding: 10px 14px;
  font-weight: 600;
  font-size: 14px;
  text-decoration: none;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background .15s ease, border-color .15s ease, filter .15s ease;
}
.btn:active { transform: translateY(1px); }
.btn + .btn { margin-left: 4px; }
.btn-small { padding: 8px 12px; font-size: 13px; }
.btn-primary { background: linear-gradient(135deg, var(--brand-1), var(--brand-2)); color: #fff; border-color: var(--brand-1); }
.btn-primary:hover { filter: brightness(1.1); }
.btn-secondary { background: var(--nav-hover); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { filter: brightness(1.1); }
.btn-outline { background: transparent; color: var(--text); border-color: var(--border); }
.btn-outline:hover { background: var(--nav-hover); }
.btn-success { background: var(--success-soft); color: var(--success-text); border-color: var(--success); }
.btn-danger { background: var(--danger-soft); color: var(--danger-text); border-color: var(--danger); }

@media (prefers-reduced-motion: no-preference) {
  .btn { transition: transform .1s ease, background .15s ease, border-color .15s ease, filter .15s ease; }
}
@media (hover: none) {
  .btn:active { transform: scale(0.97); }
}

/* ==========================================================================
   Cards
   ========================================================================== */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(0,0,0,.15);
}
body[data-theme="light"] .card { box-shadow: 0 2px 12px rgba(0,0,0,.06); }
.card-body { padding: 14px; }
.card-media { object-fit: cover; width: 100%; max-height: 360px; display: block; }
.photo-full { max-width: 100%; width: 100%; height: auto; max-height: 85vh; object-fit: contain; display: block; margin: 0 auto; }
.card-title { margin-bottom: 8px; }

@media (min-width: 681px) {
  .card { border-radius: 16px; }
  .card-body { padding: 16px; }
}

/* ==========================================================================
   Grids
   ========================================================================== */
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: 1fr; }
.grid-3 { grid-template-columns: 1fr; }

@media (min-width: 681px) {
  .grid-2 { grid-template-columns: 2fr 1fr; }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 1001px) {
  .grid-3 { grid-template-columns: repeat(3, 1fr); }
}

/* ==========================================================================
   Lists / Blocks
   ========================================================================== */
.list { display: flex; flex-direction: column; gap: 8px; }
.list-item {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  color: var(--text);
  text-decoration: none;
  transition: background .15s ease;
}
.list-item:hover { background: var(--nav-hover); }

/* ==========================================================================
   Forms
   ========================================================================== */
form { display: grid; gap: 12px; }

input[type="text"], input[type="email"], input[type="password"],
input[type="url"], input[type="search"], input[type="tel"],
input[type="number"], input[type="time"], input[type="datetime-local"],
input[type="file"], input[type="date"], textarea, select {
  background: var(--bg-soft);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  width: 100%;
  font-family: inherit;
  font-size: 15px;
  line-height: 1.4;
  transition: border-color .15s ease, box-shadow .15s ease;
}
input[type]:hover, textarea:hover, select:hover { border-color: var(--accent); }
input[type]:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--brand-1);
  box-shadow: 0 0 0 3px rgba(111,66,193,0.25);
}
input[disabled], textarea[disabled], select[disabled] {
  opacity: .5;
  cursor: not-allowed;
}
::placeholder { color: var(--muted); opacity: .8; }
label { color: var(--muted); font-size: 14px; }

/* Select custom caret */
select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 20 20'%3E%3Cpath fill='%23a8adbb' d='M5.5 7.5L10 12l4.5-4.5h-9z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 14px;
  padding-right: 34px;
}
body[data-theme="light"] select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 20 20'%3E%3Cpath fill='%234b5563' d='M5.5 7.5L10 12l4.5-4.5h-9z'/%3E%3C/svg%3E");
}

/* Date input WebKit tweaks */
input[type="date"]::-webkit-calendar-picker-indicator {
  filter: invert(1) opacity(0.85);
  cursor: pointer;
}
body[data-theme="light"] input[type="date"]::-webkit-calendar-picker-indicator {
  filter: none;
}
input[type="date"]::-webkit-calendar-picker-indicator:hover { opacity: 1; }
input[type="date"]::-webkit-datetime-edit,
input[type="date"]::-webkit-datetime-edit-text,
input[type="date"]::-webkit-datetime-edit-year-field,
input[type="date"]::-webkit-datetime-edit-month-field,
input[type="date"]::-webkit-datetime-edit-day-field {
  color: var(--text);
}
input[type="date"]::-webkit-datetime-edit-fields-wrapper { background: transparent; }
input[type="date"]::-webkit-inner-spin-button { display: none; }

/* ==========================================================================
   Tables
   ========================================================================== */
.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: 12px; border: 1px solid var(--border); }
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.table th, .table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.table thead th {
  background: var(--bg-soft);
  color: var(--text);
  font-weight: 600;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .3px;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--nav-hover); }

/* ==========================================================================
   Badges
   ========================================================================== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  background: var(--bg-soft);
  color: var(--muted);
  border: 1px solid var(--border);
}

/* ==========================================================================
   Alerts
   ========================================================================== */
.alert { padding: 12px 14px; border-radius: 12px; border: 1px solid var(--border); font-size: 14px; }
.alert-info { background: var(--info-soft); color: var(--info-text); border-color: var(--info-border); }
.alert-success { background: var(--success-soft); color: var(--success-text); border-color: var(--success); }
.alert-warning { background: var(--warning-soft); color: var(--warning-text); border-color: var(--warning); }
.alert-danger { background: var(--danger-soft); color: var(--danger-text); border-color: var(--danger); }

/* ==========================================================================
   Footer
   ========================================================================== */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 24px 0;
  padding-bottom: calc(24px + var(--safe-bottom));
  color: var(--muted);
  background: var(--footer-bg);
  font-size: 14px;
}
.site-footer a { color: var(--muted); text-decoration: none; }
.site-footer a:hover { color: var(--text); }
.footer-sitemap ul {
  list-style: none;
  padding: 0;
  margin: 0 0 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
}

/* ==========================================================================
   Breadcrumbs
   ========================================================================== */
.breadcrumbs { border-bottom: 1px solid var(--border); background: var(--bg-soft); }
.breadcrumbs .container { padding-top: 8px; padding-bottom: 8px; font-size: 14px; }
.breadcrumbs a { color: var(--muted); text-decoration: none; }
.breadcrumbs a:hover { color: var(--text); }
.breadcrumbs .sep { margin: 0 6px; color: var(--muted); }

/* ==========================================================================
   User menu dropdown
   ========================================================================== */
.user-menu { position: relative; }
.user-menu-panel {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  background: var(--nav-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 10px 24px rgba(0,0,0,.3);
  min-width: 200px;
  padding: 8px;
  z-index: 60;
}
.user-menu.open .user-menu-panel { display: block; }
.user-menu-panel a { display: block; padding: 8px 10px; color: var(--text); text-decoration: none; border-radius: 8px; }
.user-menu-panel a:hover { background: var(--nav-hover); }

/* ==========================================================================
   Error messages
   ========================================================================== */
.errorlist {
  list-style: none;
  margin: 0 0 8px;
  padding: 8px 10px;
  background: var(--danger-soft);
  color: var(--danger-text);
  border: 1px solid var(--danger);
  border-radius: 10px;
  font-size: 14px;
}
.field-error { border-color: var(--danger) !important; box-shadow: 0 0 0 2px rgba(239,68,68,0.2); }

/* ==========================================================================
   Maps
   ========================================================================== */
.map-embed {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}
.map-embed iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

/* ==========================================================================
   Accessibility
   ========================================================================== */
:focus-visible { outline: 3px solid rgba(111,66,193,0.6); outline-offset: 2px; }
.skip-link { position: absolute; left: -9999px; top: -9999px; background: var(--nav-bg); color: var(--text); padding: 8px 12px; border-radius: 8px; z-index: 1000; text-decoration: none; }
.skip-link:focus { left: 16px; top: 16px; position: fixed; }

/* ==========================================================================
   Utilities
   ========================================================================== */
.row { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.row .btn { flex-shrink: 0; }
.content > .row + .row,
.content > .row + .grid,
.content > .grid + .row,
.content > .row + .list,
.content > .grid + .grid { margin-top: 16px; }
.col { flex: 1 1 0; }
.center { max-width: 520px; margin: 0 auto; }
.muted { color: var(--muted); }
.m-0 { margin: 0; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 12px; }
.mb-3 { margin-bottom: 20px; }
.mb-4 { margin-bottom: 28px; }
.sr-only { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0,0,0,0) !important; white-space: nowrap !important; border: 0 !important; }

/* ==========================================================================
   Responsive — Mobile-first (min-width breakpoints)
   ========================================================================== */

/* Tablet and up */
@media (min-width: 681px) {
  .container { padding: 0 24px; }
  .content { padding: 28px 0 48px; }
  .row { gap: 16px; }
}

/* Desktop and up */
@media (min-width: 1001px) {
  .container { padding: 0 24px; }
}

/* Small phones — tighten spacing */
@media (max-width: 420px) {
  h1, h2, h3 { text-align: center; }
  .row { flex-direction: column; align-items: stretch; }
  .btn { width: 100%; justify-content: center; }
}
