/* mapsio Client Space — shared styles.
   Brand colors from strategy/DESIGN-BRIEF.md: primary #2563EB, accent #F97316,
   dark #0F172A, light #F1F5F9. Mobile-first (clients validate from their phone). */

:root {
  --primary: #2563EB;
  --primary-dark: #1D4ED8;
  --accent: #F97316;
  --dark: #0F172A;
  --light: #F1F5F9;
  --muted: #64748B;
  --border: #CBD5E1;
  --ok: #16A34A;
  --ok-bg: #DCFCE7;
  --err: #DC2626;
  --err-bg: #FEE2E2;
  --warn: #D97706;
  --warn-bg: #FEF3C7;
  --radius: 12px;
  --shadow: 0 4px 24px rgba(15, 23, 42, .08);
}

* { box-sizing: border-box; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--light);
  color: var(--dark);
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Top bar ────────────────────────────────────────────────────────────── */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  background: #fff;
  border-bottom: 1px solid var(--border);
}
.topbar .logo {
  font-family: 'Poppins', sans-serif;
  font-weight: 800;
  font-size: 20px;
  color: var(--primary);
  text-decoration: none;
}
.topbar nav { display: flex; align-items: center; gap: 14px; }
.topbar .who { color: var(--muted); font-size: 14px; }
.topbar .nav-link { color: var(--dark); text-decoration: none; font-weight: 600; font-size: 14px; }
.topbar .inline { display: inline; }
.topbar .link-btn {
  background: none; border: none; color: var(--muted); cursor: pointer;
  font-size: 14px; padding: 4px 8px; text-decoration: underline;
}

/* ── Layout ─────────────────────────────────────────────────────────────── */
main { flex: 1; width: 100%; max-width: 980px; margin: 0 auto; padding: 24px 20px 48px; }
.foot { text-align: center; color: var(--muted); font-size: 12px; padding: 20px; }

/* ── Cards & generic ────────────────────────────────────────────────────── */
.card {
  background: #fff; border-radius: var(--radius); padding: 24px;
  box-shadow: var(--shadow);
}
.stack { display: flex; flex-direction: column; gap: 12px; }
.muted { color: var(--muted); }
.micro { font-size: 12px; }
.empty { text-align: center; padding: 48px 24px; }

/* ── Buttons ────────────────────────────────────────────────────────────── */
.btn {
  border: none; border-radius: 8px; padding: 12px 18px; font-weight: 600;
  font-size: 14px; cursor: pointer; font-family: inherit; transition: background .15s;
}
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn-approve { background: var(--ok); color: #fff; }
.btn-approve:hover:not(:disabled) { background: #15803D; }
.btn-reject { background: var(--err); color: #fff; }
.btn-reject:hover:not(:disabled) { background: #B91C1C; }
.btn-revise { background: var(--warn-bg); color: var(--warn); border: 1px solid var(--warn); }
.btn-revise:hover:not(:disabled) { background: #FDE68A; }
.btn-small { padding: 8px 12px; font-size: 13px; }
.btn-ghost { background: none; color: var(--muted); border: 1px solid var(--border); }
.link { color: var(--primary); text-decoration: none; font-weight: 600; font-size: 14px; }

.alert { padding: 10px 14px; border-radius: 8px; font-size: 14px; margin-bottom: 12px; }
.alert-error { background: var(--err-bg); color: var(--err); }
.alert-ok { background: var(--ok-bg); color: var(--ok); }

/* ── Profile form (settings) ────────────────────────────────────────────── */
.profile-form { display: flex; flex-direction: column; gap: 18px; max-width: 720px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 14px; font-weight: 600; color: var(--dark); }
.field input, .field textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 14px; font-family: inherit; background: #fff; color: var(--dark);
}
.field input:focus, .field textarea:focus {
  outline: 2px solid var(--primary); outline-offset: -1px; border-color: var(--primary);
}
.field textarea { resize: vertical; }
.field .hint { font-size: 12px; color: var(--muted); margin: 0; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-actions { display: flex; gap: 10px; align-items: center; }
.form-actions .btn-ghost { text-decoration: none; display: inline-block; text-align: center; }

/* ── Auth pages ─────────────────────────────────────────────────────────── */
.auth-card { max-width: 420px; margin: 40px auto; text-align: center; }
.auth-card h1 { font-family: 'Poppins', sans-serif; margin: 0 0 8px; font-size: 24px; }
.auth-card .check-icon { font-size: 40px; margin-bottom: 8px; }
.auth-card form { margin-top: 20px; text-align: left; }
.label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.auth-card input {
  width: 100%; padding: 12px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 15px; font-family: inherit;
}
.auth-card input:focus { outline: 2px solid var(--primary); outline-offset: -1px; border-color: var(--primary); }

/* ── Dashboard ──────────────────────────────────────────────────────────── */
.page-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 16px; margin-bottom: 24px; flex-wrap: wrap;
}
.page-head h1 { font-family: 'Poppins', sans-serif; margin: 0 0 4px; font-size: 22px; }
.back-link { color: var(--muted); text-decoration: none; font-size: 13px; }
.campaign-list { display: flex; flex-direction: column; gap: 12px; }
.campaign-row {
  display: flex; justify-content: space-between; align-items: center;
  text-decoration: none; color: inherit; transition: transform .1s;
}
.campaign-row:hover { transform: translateY(-1px); }
.camp-week { font-weight: 600; font-size: 15px; }
.camp-stats { font-size: 13px; color: var(--muted); display: flex; gap: 6px; margin-top: 4px; }

/* ── Badges ─────────────────────────────────────────────────────────────── */
.badge {
  display: inline-block; padding: 3px 10px; border-radius: 20px;
  font-size: 12px; font-weight: 600;
}
.badge-generating { background: var(--light); color: var(--muted); }
.badge-draft { background: var(--warn-bg); color: var(--warn); }
.badge-ready { background: var(--ok-bg); color: var(--ok); }
.badge-archived { background: #E2E8F0; color: var(--muted); }

/* ── Banner (generation in progress) ────────────────────────────────────── */
.banner {
  display: flex; align-items: center; gap: 12px;
  background: #fff; border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 18px; margin-bottom: 20px;
  color: var(--muted); font-size: 14px;
}
.spinner {
  width: 16px; height: 16px; border: 2px solid var(--border);
  border-top-color: var(--primary); border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Posts grid (campaign review) ───────────────────────────────────────── */
.posts-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
}
.post-card {
  background: #fff; border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow); display: flex; flex-direction: column;
  border: 2px solid transparent; transition: border-color .15s;
}
.post-card.is-approved { border-color: var(--ok); }
.post-card.is-rejected { border-color: var(--err); opacity: .65; }
.post-card.is-revision_requested { border-color: var(--warn); }

.post-img-wrap { aspect-ratio: 1; background: var(--light); overflow: hidden; }
.post-img-wrap img { width: 100%; height: 100%; object-fit: cover; display: block; }
.img-skeleton {
  width: 100%; height: 100%; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(90deg, #E2E8F0 25%, #F1F5F9 50%, #E2E8F0 75%);
  background-size: 200% 100%; animation: shimmer 1.5s infinite; color: var(--muted); font-size: 13px;
}
@keyframes shimmer { to { background-position: -200% 0; } }

.post-body { padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.post-type {
  font-size: 11px; text-transform: uppercase; letter-spacing: .5px;
  color: var(--accent); font-weight: 700;
}
.post-caption { margin: 0; font-size: 14px; line-height: 1.5; white-space: pre-wrap; }
.post-tags { margin: 0; font-size: 12px; color: var(--primary); }
.post-cta { margin: 0; font-size: 13px; font-weight: 600; color: var(--dark); }

.post-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.post-actions button { flex: 1; min-width: 90px; padding: 8px 6px; font-size: 12px; }
/* Hide actions once a decision is made (show the verdict instead). */
.post-card.is-approved .post-actions,
.post-card.is-rejected .post-actions,
.post-card.is-revision_requested .post-actions { display: none; }

.revise-box { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.revise-box textarea {
  width: 100%; border: 1px solid var(--border); border-radius: 8px; padding: 8px;
  font-size: 13px; font-family: inherit; resize: vertical; min-height: 60px;
}
.revise-actions { display: flex; gap: 8px; }

.post-verdict { margin: 8px 0 0; font-size: 13px; font-weight: 600; }
.post-verdict.v-approved { color: var(--ok); }
.post-verdict.v-rejected { color: var(--err); }
.post-verdict.v-revision_requested { color: var(--warn); }

/* ── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .page-head { flex-direction: column; }
  .posts-grid { grid-template-columns: 1fr; }
  .field-row { grid-template-columns: 1fr; }
}

/* ── AI Assist (profile) ─────────────────────────────────────────────────── */
.btn-ai {
  background: #fff; color: var(--primary); border: 1.5px solid var(--primary);
  white-space: nowrap;
}
.btn-ai:hover:not(:disabled) {
  background: #EFF6FF;
}
/* Champ pré-rempli par l'IA — surligné vert pour distinguer du contenu saisi. */
.ai-filled {
  border-color: #22c55e;
  background-color: #f0fdf4;
  transition: background-color 0.5s ease;
}

/* ── Assets (photo gallery + upload) ────────────────────────────────────── */
.assets-bar { margin-bottom: 16px; color: var(--muted); font-size: 14px; font-weight: 600; }
.upload-zone {
  border: 2px dashed var(--border); text-align: center; cursor: pointer;
  transition: border-color .15s, background .15s; margin-bottom: 24px;
}
.upload-zone:hover { border-color: var(--primary); background: #F8FAFC; }
.upload-zone.drag { border-color: var(--primary); background: #EFF6FF; }
.upload-inner { padding: 28px; }
.upload-icon { font-size: 32px; margin-bottom: 8px; }
.upload-progress { padding: 8px; color: var(--primary); font-size: 14px; }
.gallery {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 14px;
}
.gallery-item {
  position: relative; aspect-ratio: 1; border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow); background: var(--light);
}
.gallery-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gallery-label {
  position: absolute; bottom: 0; left: 0; right: 0; background: rgba(15,23,42,.75);
  color: #fff; font-size: 12px; padding: 4px 8px;
}
.gallery-delete {
  position: absolute; top: 6px; right: 40px; width: 28px; height: 28px; border-radius: 50%;
  background: rgba(220,38,38,.9); color: #fff; border: none; cursor: pointer; font-size: 14px;
  display: flex; align-items: center; justify-content: center; opacity: 0; transition: opacity .15s;
}
.gallery-edit {
  position: absolute; top: 6px; right: 6px; width: 28px; height: 28px; border-radius: 50%;
  background: rgba(37,99,235,.9); color: #fff; border: none; cursor: pointer; font-size: 14px;
  display: flex; align-items: center; justify-content: center; opacity: 0; transition: opacity .15s;
}
.gallery-item:hover .gallery-delete,
.gallery-item:hover .gallery-edit { opacity: 1; }
.edit-preview {
  width: 100%; max-height: 240px; object-fit: cover; border-radius: 8px; margin-bottom: 12px;
}
.gallery-tags {
  position: absolute; top: 6px; left: 6px; background: rgba(37,99,235,.85); color: #fff;
  font-size: 10px; padding: 2px 6px; border-radius: 4px; text-transform: uppercase; letter-spacing: .3px;
}

/* ── Tag chips (upload default tags) ────────────────────────────────────── */
.tag-hint { margin-bottom: 20px; padding: 14px 18px; }
.tag-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.tag-chip {
  background: var(--light); border: 1px solid var(--border); border-radius: 20px;
  padding: 5px 12px; font-size: 13px; cursor: pointer; font-family: inherit;
  color: var(--muted); transition: all .12s;
}
.tag-chip:hover { border-color: var(--primary); color: var(--primary); }
.tag-chip.selected { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ── Photo picker (post reassignment) ───────────────────────────────────── */
.photo-picker {
  position: fixed; inset: 0; background: rgba(15,23,42,.6); z-index: 100;
  display: none; align-items: center; justify-content: center; padding: 20px;
}
.photo-picker.open { display: flex; }
.photo-picker-inner {
  background: #fff; border-radius: var(--radius); padding: 24px; max-width: 600px;
  width: 100%; max-height: 85vh; overflow-y: auto;
}
.photo-picker h3 { margin: 0 0 4px; }
.photo-picker-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; margin-top: 16px;
}
.picker-thumb {
  aspect-ratio: 1; border-radius: 8px; overflow: hidden; cursor: pointer;
  border: 3px solid transparent; transition: border-color .12s;
}
.picker-thumb:hover { border-color: var(--primary); }
.picker-thumb.selected { border-color: var(--ok); }
.picker-thumb img { width: 100%; height: 100%; object-fit: cover; }

/* ── Prepare page (pre-generation) ──────────────────────────────────────── */
.prepare-form { display: flex; flex-direction: column; gap: 22px; max-width: 760px; }
.prepare-gallery {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px;
  margin-top: 8px;
}
.prepare-photo {
  position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; cursor: pointer;
  border: 3px solid transparent; transition: border-color .12s, transform .12s; background: var(--light);
}
.prepare-photo:hover { transform: scale(1.02); }
.prepare-photo.selected { border-color: var(--ok); }
.prepare-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.prepare-photo-check {
  position: absolute; top: 6px; right: 6px; width: 28px; height: 28px; border-radius: 50%;
  background: var(--ok); color: #fff; display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 700; opacity: 0; transition: opacity .12s;
}
.prepare-photo.selected .prepare-photo-check { opacity: 1; }
.prepare-photo-label {
  position: absolute; bottom: 0; left: 0; right: 0; background: rgba(15,23,42,.7);
  color: #fff; font-size: 11px; padding: 3px 6px;
}
.empty-inline { padding: 14px; background: var(--light); border-radius: 8px; text-align: center; }

/* ── Public homepage ─────────────────────────────────────────────────────── */
.hero {
  text-align: center; padding: 56px 20px 40px;
}
.hero h1 {
  font-family: 'Poppins', sans-serif;
  font-size: clamp(28px, 5vw, 44px); line-height: 1.15; margin: 0 auto 16px;
  max-width: 16ch; color: var(--dark);
}
.hero h1 .accent { color: var(--primary); }
.hero .lead {
  font-size: clamp(16px, 2.5vw, 20px); color: var(--muted); max-width: 52ch;
  margin: 0 auto 28px; line-height: 1.5;
}
.hero-cta { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.hero-cta .btn { font-size: 16px; padding: 14px 24px; }

.home-section { margin: 40px 0; }
.home-section h2 {
  font-family: 'Poppins', sans-serif; font-size: 22px; text-align: center;
  margin: 0 0 8px;
}
.home-section .section-sub { text-align: center; color: var(--muted); margin: 0 0 24px; }

.steps {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px;
}
.step {
  background: #fff; border-radius: var(--radius); padding: 24px;
  box-shadow: var(--shadow);
}
.step-num {
  width: 36px; height: 36px; border-radius: 50%; background: var(--primary);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-family: 'Poppins', sans-serif; margin-bottom: 12px;
}
.step h3 { margin: 0 0 6px; font-size: 16px; }
.step p { margin: 0; font-size: 14px; color: var(--muted); line-height: 1.5; }

.niche-chips {
  display: flex; flex-wrap: wrap; gap: 10px; justify-content: center;
}
.niche-chip {
  background: #fff; border: 1px solid var(--border); border-radius: 20px;
  padding: 8px 16px; font-size: 14px; font-weight: 600; color: var(--dark);
}

.home-cta {
  text-align: center; padding: 40px 20px; margin-top: 24px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border-radius: var(--radius); color: #fff;
}
.home-cta h2 { color: #fff; margin: 0 0 8px; }
.home-cta p { margin: 0 0 20px; opacity: .9; }
.home-cta .btn {
  background: #fff; color: var(--primary);
}
.home-cta .btn:hover:not(:disabled) { background: var(--light); }

@media (max-width: 700px) {
  .steps { grid-template-columns: 1fr; }
}
