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

:root {
  --blue:    #2563eb;
  --blue-dk: #1d4ed8;
  --blue-lt: #eff6ff;
  --border:  #e5e7eb;
  --bg:      #f0f2f5;
  --text:    #111827;
  --muted:   #6b7280;
  --radius:  12px;
}

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

/* ── Flash ───────────────────────────────────────────────────────────── */
.flash {
  display: flex; align-items: center; justify-content: space-between;
  padding: .85rem 1.5rem; font-size: .9rem; font-weight: 500;
  border-left: 4px solid currentColor;
  animation: slideDown .2s ease;
}
.flash-success { background: #f0fdf4; color: #166534; }
.flash-error, .flash-message { background: #fef2f2; color: #991b1b; }
.flash-close {
  background: none; border: none; cursor: pointer; font-size: 1rem;
  color: inherit; opacity: .5; padding: 0 .25rem; flex-shrink: 0;
}
.flash-close:hover { opacity: 1; }
@keyframes slideDown { from { transform: translateY(-6px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ── Login ───────────────────────────────────────────────────────────── */
.login-box {
  max-width: 360px; margin: 8rem auto; background: #fff;
  padding: 2.5rem; border-radius: 16px; box-shadow: 0 4px 32px rgba(0,0,0,.08);
}
.login-box h1 { font-size: 1.4rem; margin-bottom: 1.75rem; color: var(--blue); font-weight: 700; }
.login-box label { display: block; margin-bottom: 1rem; font-size: .875rem; color: #555; font-weight: 500; }
.login-box input {
  display: block; width: 100%; margin-top: .35rem;
  padding: .65rem .9rem; border: 1px solid var(--border);
  border-radius: 8px; font-size: .95rem; outline: none; transition: border .15s;
}
.login-box input:focus { border-color: var(--blue); }
.login-box button {
  width: 100%; padding: .75rem; background: var(--blue); color: #fff;
  border: none; border-radius: 8px; font-size: 1rem; cursor: pointer;
  margin-top: .75rem; font-weight: 600; transition: background .15s;
}
.login-box button:hover { background: var(--blue-dk); }

/* ── Topbar ──────────────────────────────────────────────────────────── */
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--blue); color: #fff;
  padding: .8rem 1.75rem; position: sticky; top: 0; z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
}
.topbar-brand { display: flex; align-items: center; gap: .5rem; font-weight: 700; font-size: 1rem; letter-spacing: -.01em; }
.topbar-logo { font-size: 1rem; }
.topbar-nav { display: flex; gap: .15rem; }
.topbar-link {
  color: rgba(255,255,255,.75); text-decoration: none;
  font-size: .875rem; font-weight: 500; padding: .3rem .75rem;
  border-radius: 6px; transition: background .15s, color .15s;
}
.topbar-link:hover { background: rgba(255,255,255,.12); color: #fff; }
.topbar-link.active { background: rgba(255,255,255,.18); color: #fff; }
.topbar-logout { color: rgba(255,255,255,.8); text-decoration: none; font-size: .85rem; }
.topbar-logout:hover { color: #fff; }

/* ── Container ──────────────────────────────────────────────────────── */
.container { max-width: 980px; margin: 0 auto; padding: 2rem 1.5rem 4rem; }

/* ── List header ─────────────────────────────────────────────────────── */
.list-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  margin-bottom: 1.75rem; gap: 1rem; flex-wrap: wrap;
}
.list-header-actions { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.list-header h2 { font-size: 1.4rem; font-weight: 800; letter-spacing: -.02em; }
.list-count { font-size: .85rem; color: var(--muted); margin-top: .25rem; }

/* ── Buttons ─────────────────────────────────────────────────────────── */
.btn-primary {
  display: inline-block; padding: .6rem 1.3rem; background: var(--blue);
  color: #fff; border: none; border-radius: 8px; font-size: .9rem;
  font-weight: 600; cursor: pointer; text-decoration: none;
  transition: background .15s; white-space: nowrap;
}
.btn-primary:hover { background: var(--blue-dk); }
.btn-submit { padding: .8rem 2rem; font-size: .95rem; }
.btn-secondary {
  display: inline-block; padding: .6rem 1.3rem; background: #fff;
  color: #374151; border: 1px solid var(--border); border-radius: 8px;
  font-size: .9rem; font-weight: 600; cursor: pointer;
  text-decoration: none; transition: background .15s;
}
.btn-secondary:hover { background: #f9fafb; }
.btn-sm {
  display: inline-block; padding: .3rem .8rem; background: #f3f4f6;
  color: #374151; border: none; border-radius: 6px; font-size: .78rem;
  font-weight: 500; cursor: pointer; text-decoration: none;
  transition: background .15s; white-space: nowrap;
}
.btn-sm:hover { background: #e5e7eb; }
.btn-sm.btn-green { background: #dcfce7; color: #166534; }
.btn-sm.btn-green:hover { background: #bbf7d0; }
.btn-sm.btn-red { background: #fee2e2; color: #991b1b; }
.btn-sm.btn-red:hover { background: #fecaca; }
.btn-sm.btn-orange { background: #fef3c7; color: #92400e; }
.btn-sm.btn-orange:hover { background: #fde68a; }

/* ── Site cards ──────────────────────────────────────────────────────── */
.sites-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1rem;
}
.site-card {
  background: #fff; border-radius: var(--radius);
  box-shadow: 0 1px 3px rgba(0,0,0,.07), 0 1px 8px rgba(0,0,0,.04);
  border: 1px solid var(--border);
  display: flex; overflow: hidden;
  transition: box-shadow .15s, transform .15s;
}
.site-card:hover { box-shadow: 0 6px 24px rgba(0,0,0,.1); transform: translateY(-2px); }
.site-card-accent { width: 4px; flex-shrink: 0; }
.site-card-body { padding: 1.1rem 1.25rem; flex: 1; display: flex; flex-direction: column; gap: .8rem; min-width: 0; }
.site-card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: .5rem; }
.site-info { min-width: 0; flex: 1; }
.site-name { font-size: 1rem; font-weight: 700; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.site-badges { display: flex; gap: .3rem; flex-wrap: wrap; margin-top: .4rem; }
.badge {
  display: inline-block; padding: .15rem .55rem;
  background: var(--blue-lt); color: var(--blue-dk);
  border-radius: 20px; font-size: .72rem; font-weight: 600;
}
.badge-sector { background: #f3f4f6; color: #4b5563; }
.badge-inactive { background: #fee2e2; color: #991b1b; }
.color-dot {
  width: 26px; height: 26px; border-radius: 50%; flex-shrink: 0;
  border: 2px solid rgba(0,0,0,.1); box-shadow: inset 0 1px 2px rgba(0,0,0,.1);
}
.site-url { font-size: .8rem; color: var(--blue); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.site-url:hover { text-decoration: underline; }
.site-card-actions { display: flex; gap: .35rem; flex-wrap: wrap; }

/* ── Empty state ─────────────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 5rem 1rem; color: var(--muted); }
.empty-icon { font-size: 2.5rem; margin-bottom: 1rem; }
.empty-state p { margin-bottom: 1.25rem; font-size: 1rem; }

/* ── Form layout ─────────────────────────────────────────────────────── */
.form-page-header { margin-bottom: 1.5rem; }
.form-page-header h2 { font-size: 1.4rem; font-weight: 800; letter-spacing: -.02em; }

.site-form { max-width: 680px; }

/* ── Accordion (details/summary) ─────────────────────────────────────── */
.form-section {
  background: #fff; border-radius: var(--radius);
  border: 1px solid var(--border);
  margin-bottom: .6rem;
  box-shadow: 0 1px 3px rgba(0,0,0,.05);
  overflow: hidden;
}

details.form-section[open] { box-shadow: 0 2px 8px rgba(0,0,0,.07); }

.section-summary {
  display: flex; justify-content: space-between; align-items: center;
  padding: .9rem 1.25rem;
  cursor: pointer;
  list-style: none;
  user-select: none;
  background: #fafafa;
  border-bottom: 1px solid transparent;
  transition: background .15s;
}
.section-summary::-webkit-details-marker { display: none; }
details.form-section[open] > .section-summary { border-bottom-color: var(--border); background: #f5f7ff; }
.section-summary:hover { background: #f0f2ff; }

.section-summary h3 {
  font-size: .9rem; font-weight: 700; color: #1f2937;
  display: flex; align-items: center; gap: .5rem;
}

.section-chevron {
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--border); color: var(--muted);
  display: flex; align-items: center; justify-content: center;
  font-size: .6rem; flex-shrink: 0;
  transition: transform .2s, background .15s;
}
details.form-section[open] .section-chevron { transform: rotate(180deg); background: var(--blue-lt); color: var(--blue); }

.section-body { padding: 1.25rem; }

/* ── Fields ──────────────────────────────────────────────────────────── */
.field { margin-bottom: 1.1rem; }
.field:last-child { margin-bottom: 0; }

.field label {
  display: block; font-size: .82rem; font-weight: 600;
  color: #374151; margin-bottom: .45rem;
}

.field input[type="text"],
.field input[type="tel"],
.field input[type="url"],
.field textarea {
  width: 100%; padding: .6rem .9rem;
  border: 1.5px solid var(--border);
  border-radius: 8px; font-size: .95rem;
  font-family: inherit; outline: none;
  transition: border-color .15s, box-shadow .15s;
  background: #fff; color: var(--text);
}
.field input:focus,
.field textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}
.field input.disabled { background: #f9fafb; color: #9ca3af; cursor: not-allowed; }
.field input[type="file"] { font-size: .875rem; color: #374151; padding: .4rem 0; }
.field textarea { resize: vertical; min-height: 90px; }

.fields-row { display: grid; grid-template-columns: 1fr 1fr; gap: .85rem; }
@media (max-width: 560px) { .fields-row { grid-template-columns: 1fr; } }

.hint { font-size: .78rem; color: #9ca3af; font-weight: 400; }
.current-img { display: flex; align-items: center; gap: .75rem; margin-bottom: .5rem; }
.current-img img { border-radius: 8px; border: 1px solid var(--border); }

/* ── Horaires ────────────────────────────────────────────────────────── */
.hours-grid { display: grid; gap: .45rem; }
.hour-row { display: grid; grid-template-columns: 115px 1fr; align-items: center; gap: .75rem; }
.hour-row label { font-size: .85rem; color: #374151; font-weight: 500; }
.hour-row input {
  padding: .5rem .75rem; border: 1.5px solid var(--border);
  border-radius: 7px; font-size: .875rem; outline: none;
  transition: border-color .15s;
}
.hour-row input:focus { border-color: var(--blue); }

/* ── Template choice ─────────────────────────────────────────────────── */
.template-choice { display: flex; gap: .5rem; flex-wrap: wrap; }
.template-option { cursor: pointer; }
.template-option input { display: none; }
.template-option span {
  display: inline-block; padding: .5rem 1.25rem;
  border: 2px solid var(--border); border-radius: 8px;
  font-size: .875rem; font-weight: 500;
  transition: all .15s; color: #374151;
}
.template-option input:checked + span { border-color: var(--blue); background: var(--blue-lt); color: var(--blue-dk); }
.template-option:hover span { border-color: #93c5fd; }

/* ── Color ────────────────────────────────────────────────────────────── */
.color-row { display: flex; align-items: center; gap: .85rem; flex-wrap: wrap; }
.color-row input[type="color"] {
  width: 46px; height: 36px; border: 1.5px solid var(--border);
  border-radius: 8px; cursor: pointer; padding: 2px;
}
.color-preview {
  padding: .3rem .9rem; border-radius: 7px;
  font-size: .8rem; font-weight: 700; color: #fff;
  min-width: 80px; text-align: center;
  text-shadow: 0 1px 2px rgba(0,0,0,.35);
}

/* ── Checkbox ─────────────────────────────────────────────────────────── */
.checkbox-label {
  display: flex; align-items: center; gap: .5rem;
  font-size: .875rem; margin-bottom: .5rem;
  cursor: pointer; color: #374151;
}

/* ── Form actions ─────────────────────────────────────────────────────── */
.form-actions {
  display: flex; gap: .75rem;
  margin-top: 1.25rem; padding-bottom: 2rem;
  flex-wrap: wrap;
}

/* ── Secteur ─────────────────────────────────────────────────────────── */
.sector-choice { display: flex; gap: .4rem; flex-wrap: wrap; }
.sector-option { cursor: pointer; }
.sector-option input { display: none; }
.sector-option span {
  display: inline-block; padding: .45rem 1rem;
  border: 2px solid var(--border); border-radius: 20px;
  font-size: .875rem; font-weight: 500;
  transition: all .15s; color: #374151; white-space: nowrap;
}
.sector-option input:checked + span {
  border-color: var(--blue); background: var(--blue-lt); color: var(--blue-dk);
}
.sector-option:hover span { border-color: #93c5fd; }

/* ── Menu builder ────────────────────────────────────────────────────── */
.menu-category {
  background: #f8faff; border: 1px solid #dbeafe;
  border-radius: 9px; padding: .9rem; margin-bottom: .65rem;
}
.menu-cat-header { display: flex; gap: .5rem; align-items: center; margin-bottom: .6rem; }
.menu-cat-header .cat-name {
  flex: 1; padding: .45rem .7rem;
  border: 1.5px solid var(--border); border-radius: 7px;
  font-size: .9rem; font-weight: 600; outline: none;
  transition: border-color .15s;
}
.menu-cat-header .cat-name:focus { border-color: var(--blue); }

.menu-item-row {
  display: grid; grid-template-columns: 1fr 110px 30px;
  gap: .4rem; margin-bottom: .35rem; align-items: center;
}
.menu-item-row input {
  padding: .4rem .6rem; border: 1.5px solid var(--border);
  border-radius: 6px; font-size: .875rem; outline: none;
  transition: border-color .15s;
}
.menu-item-row input:focus { border-color: var(--blue); }

.btn-add-item {
  margin-top: .4rem; background: none; border: 1.5px dashed #93c5fd;
  color: var(--blue); border-radius: 6px; padding: .3rem .75rem;
  font-size: .8rem; cursor: pointer; transition: background .15s;
}
.btn-add-item:hover { background: var(--blue-lt); }

.btn-add-block {
  margin-top: .25rem; background: none; border: 2px dashed #d1d5db;
  color: var(--muted); border-radius: 9px; padding: .6rem 1rem;
  font-size: .875rem; cursor: pointer; transition: all .15s; width: 100%;
}
.btn-add-block:hover { border-color: var(--blue); color: var(--blue); background: var(--blue-lt); }

.btn-remove {
  background: #fee2e2; border: none; color: #991b1b;
  border-radius: 6px; width: 30px; height: 30px;
  cursor: pointer; font-size: .85rem; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s;
}
.btn-remove:hover { background: #fecaca; }
.btn-remove-sm {
  background: #fee2e2; border: none; color: #991b1b;
  border-radius: 5px; width: 28px; height: 28px;
  cursor: pointer; font-size: .8rem;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s;
}
.btn-remove-sm:hover { background: #fecaca; }

/* ── Services ────────────────────────────────────────────────────────── */
.service-row {
  display: grid; grid-template-columns: 1fr 100px 100px 30px;
  gap: .4rem; margin-bottom: .45rem; align-items: center;
}
.service-row input {
  padding: .45rem .65rem; border: 1.5px solid var(--border);
  border-radius: 7px; font-size: .875rem; outline: none;
  transition: border-color .15s;
}
.service-row input:focus { border-color: var(--blue); }

/* ── Gallery link (formulaire) ────────────────────────────────────────── */
.gallery-link {
  font-size: .75rem; font-weight: 500; color: var(--blue);
  text-decoration: none; margin-left: .5rem;
}
.gallery-link:hover { text-decoration: underline; }

/* ── Template gallery page ───────────────────────────────────────────── */
.tmpl-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 1.5rem;
  margin-top: 1.5rem;
}
.tmpl-card {
  background: #fff; border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: 0 1px 4px rgba(0,0,0,.07);
  overflow: hidden;
  transition: box-shadow .2s, transform .2s;
}
.tmpl-card:hover { box-shadow: 0 8px 28px rgba(0,0,0,.12); transform: translateY(-3px); }

/* ── Mini-preview ─────────────────────────────────────────────────────── */
.tmpl-preview {
  height: 170px;
  position: relative;
  overflow: hidden;
  border-bottom: 1px solid var(--border);
}
.mp-hero { position: absolute; top: 0; left: 0; right: 0; height: 65%; }
.mp-section { position: absolute; bottom: 0; left: 0; right: 0; height: 35%; padding: 10px 14px; display: flex; flex-direction: column; gap: 6px; justify-content: center; }
.mp-logo { position: absolute; top: 16px; left: 14px; width: 22px; height: 22px; border-radius: 50%; }
.mp-tag  { position: absolute; top: 14px; left: 14px; width: 42px; height: 8px; border-radius: 2px; }
.mp-h1   { position: absolute; top: 46px; left: 14px; right: 45px; height: 10px; border-radius: 3px; }
.mp-sub  { position: absolute; top: 64px; left: 14px; right: 75px; height: 6px; border-radius: 3px; opacity: .65; }
.mp-btn  { position: absolute; bottom: 12px; left: 14px; width: 65px; height: 18px; border-radius: 20px; }
.mp-line { height: 5px; border-radius: 3px; }
.mp-line.short { width: 55%; }

/* Moderne (colorful hero) */
.tmpl-preview.tmpl-moderne .mp-hero { background: #2563eb; }
.tmpl-preview.tmpl-moderne .mp-logo { background: rgba(255,255,255,.3); }
.tmpl-preview.tmpl-moderne .mp-h1   { background: rgba(255,255,255,.9); }
.tmpl-preview.tmpl-moderne .mp-sub  { background: rgba(255,255,255,.5); }
.tmpl-preview.tmpl-moderne .mp-btn  { background: #fff; }
.tmpl-preview.tmpl-moderne .mp-section { background: #fff; }
.tmpl-preview.tmpl-moderne .mp-line { background: #e5e7eb; }

/* Chic (dark elegant) */
.tmpl-preview.tmpl-chic { background: #111; }
.tmpl-preview.tmpl-chic .mp-hero { background: #111; border-top: 3px solid #b8860b; }
.tmpl-preview.tmpl-chic .mp-logo { background: rgba(184,134,11,.25); border: 1px solid #b8860b; border-radius: 3px; }
.tmpl-preview.tmpl-chic .mp-h1   { background: rgba(255,255,255,.85); }
.tmpl-preview.tmpl-chic .mp-sub  { background: rgba(255,255,255,.35); }
.tmpl-preview.tmpl-chic .mp-btn  { background: transparent; border: 1.5px solid rgba(184,134,11,.75); border-radius: 2px; }
.tmpl-preview.tmpl-chic .mp-section { background: #1a1a1a; }
.tmpl-preview.tmpl-chic .mp-line { background: rgba(255,255,255,.1); }

/* Coloré (warm gradient) */
.tmpl-preview.tmpl-colore .mp-hero { background: linear-gradient(135deg, #e67e22 0%, #e74c3c 100%); }
.tmpl-preview.tmpl-colore .mp-logo { background: rgba(255,255,255,.25); }
.tmpl-preview.tmpl-colore .mp-h1   { background: rgba(255,255,255,.9); }
.tmpl-preview.tmpl-colore .mp-sub  { background: rgba(255,255,255,.5); }
.tmpl-preview.tmpl-colore .mp-btn  { background: #fff; border-radius: 8px; }
.tmpl-preview.tmpl-colore .mp-section { background: #fff8f0; }
.tmpl-preview.tmpl-colore .mp-line { background: #fddcb5; }

/* Minimal (white clean) */
.tmpl-preview.tmpl-minimal { background: #fff; }
.tmpl-preview.tmpl-minimal .mp-hero { background: #fff; border-bottom: 1px solid #e8e8e8; }
.tmpl-preview.tmpl-minimal .mp-logo { background: #fff; border: 1px solid #e8e8e8; border-radius: 6px; }
.tmpl-preview.tmpl-minimal .mp-h1   { background: #d1d5db; height: 7px; top: 50px; right: 80px; }
.tmpl-preview.tmpl-minimal .mp-sub  { background: #e5e7eb; top: 65px; }
.tmpl-preview.tmpl-minimal .mp-btn  { background: transparent; border: 1.5px solid #2563eb; border-radius: 6px; width: 58px; height: 16px; }
.tmpl-preview.tmpl-minimal .mp-section { background: #fafafa; border-top: 1px solid #e8e8e8; }
.tmpl-preview.tmpl-minimal .mp-line { background: #e8e8e8; }

/* Bold (dark dramatic) */
.tmpl-preview.tmpl-bold { background: #0f0f0f; }
.tmpl-preview.tmpl-bold .mp-hero { background: linear-gradient(135deg, #0f0f0f 0%, #1a0b30 100%); }
.tmpl-preview.tmpl-bold .mp-logo { background: rgba(255,255,255,.1); border-radius: 8px; }
.tmpl-preview.tmpl-bold .mp-tag  { background: #2563eb; }
.tmpl-preview.tmpl-bold .mp-h1   { background: rgba(255,255,255,.9); height: 14px; top: 30px; right: 25px; }
.tmpl-preview.tmpl-bold .mp-sub  { background: rgba(255,255,255,.4); top: 52px; }
.tmpl-preview.tmpl-bold .mp-btn  { background: #2563eb; border-radius: 4px; }
.tmpl-preview.tmpl-bold .mp-section { background: #1a1a1a; }
.tmpl-preview.tmpl-bold .mp-line { background: rgba(255,255,255,.08); }

/* ── Template card info ────────────────────────────────────────────────── */
.tmpl-info { padding: 1.1rem 1.25rem; }
.tmpl-name { font-size: 1rem; font-weight: 700; color: var(--text); margin-bottom: .3rem; }
.tmpl-desc { font-size: .82rem; color: var(--muted); line-height: 1.55; margin-bottom: .75rem; }
.tmpl-tags { display: flex; gap: .3rem; flex-wrap: wrap; margin-bottom: 1rem; }
.tmpl-tag  {
  display: inline-block; padding: .18rem .55rem;
  background: #f3f4f6; color: #4b5563;
  border-radius: 20px; font-size: .7rem; font-weight: 600;
}
.btn-use-tmpl {
  display: block; padding: .55rem 1.1rem;
  background: var(--blue); color: #fff;
  border-radius: 8px; font-size: .875rem; font-weight: 600;
  text-align: center; text-decoration: none;
  transition: background .15s;
}
.btn-use-tmpl:hover { background: var(--blue-dk); color: #fff; }

/* ── Mobile overrides ────────────────────────────────────────────────── */
@media (max-width: 700px) {
  .container { padding: 1rem .9rem 3rem; }
  .site-form { max-width: 100%; }
  .list-header { flex-direction: column; gap: .75rem; }
  .sites-grid { grid-template-columns: 1fr; }
  .form-actions { flex-direction: column; }
  .btn-submit { text-align: center; }
  .service-row { grid-template-columns: 1fr 30px; row-gap: .4rem; }
  .service-row input:nth-child(2),
  .service-row input:nth-child(3) { grid-column: 1; }
  .service-row .btn-remove-sm { grid-row: 1; grid-column: 2; }
  .menu-item-row { grid-template-columns: 1fr 90px 28px; }
  .hour-row { grid-template-columns: 95px 1fr; }
}
