/* ── Reset & variables ────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --green:      #1D9E75;
  --green-dark: #158a63;
  --green-light:#e8f7f2;
  --dark:       #2C2C2A;
  --gray:       #6b6b69;
  --gray-light: #f4f4f3;
  --border:     #ddddd9;
  --white:      #ffffff;
  --red:        #d94f3d;
  --orange:     #e07b29;
  --shadow:     0 2px 12px rgba(44,44,42,.09);
  --radius:     10px;
  --font:       'Segoe UI', system-ui, -apple-system, sans-serif;
}

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: var(--font);
  color: var(--dark);
  background: var(--gray-light);
  min-height: 100vh;
  line-height: 1.6;
}

/* ── Layout ───────────────────────────────────────────────────────────────── */
.container { max-width: 820px; margin: 0 auto; padding: 0 16px; }

/* ── Header ───────────────────────────────────────────────────────────────── */
header {
  background: var(--white);
  border-bottom: 3px solid var(--green);
  padding: 16px 0;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--dark);
}

.logo-icon {
  width: 36px;
  height: 36px;
  background: var(--green);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.logo-text { font-size: 1.25rem; font-weight: 700; letter-spacing: -.3px; }
.logo-text span { color: var(--green); }

.header-tagline {
  font-size: 0.78rem;
  color: var(--gray);
  text-align: right;
  max-width: 180px;
}

/* ── Main ─────────────────────────────────────────────────────────────────── */
main { padding: 28px 0 60px; }

/* ── Section titres ───────────────────────────────────────────────────────── */
.section-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--dark);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-title::before {
  content: '';
  display: block;
  width: 4px;
  height: 18px;
  background: var(--green);
  border-radius: 2px;
}

/* ── Card ─────────────────────────────────────────────────────────────────── */
.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 20px;
  border: 1px solid var(--border);
}

/* ── Profil utilisateur ───────────────────────────────────────────────────── */
.profil-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--gray);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: .4px;
}

.form-group select,
.form-group input[type="text"] {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: 7px;
  font-size: 0.9rem;
  font-family: var(--font);
  color: var(--dark);
  background: var(--white);
  transition: border-color .2s;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%236b6b69' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
}

.form-group select:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(29,158,117,.15);
}

/* Outils checkboxes */
.outils-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.outil-check {
  display: none;
}

.outil-label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  border: 1.5px solid var(--border);
  border-radius: 20px;
  font-size: 0.82rem;
  cursor: pointer;
  transition: all .2s;
  user-select: none;
  color: var(--gray);
  background: var(--white);
}

.outil-label:hover { border-color: var(--green); color: var(--green); }

.outil-check:checked + .outil-label {
  background: var(--green-light);
  border-color: var(--green);
  color: var(--green);
  font-weight: 600;
}

.outil-label .icon { font-size: 14px; }

/* Sauvegarde profil */
.profil-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.btn-save-profil {
  padding: 7px 16px;
  background: transparent;
  border: 1.5px solid var(--green);
  color: var(--green);
  border-radius: 7px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .2s;
}

.btn-save-profil:hover { background: var(--green); color: var(--white); }

.profil-saved-msg {
  font-size: 0.8rem;
  color: var(--green);
  opacity: 0;
  transition: opacity .3s;
}

.profil-saved-msg.visible { opacity: 1; }

/* ── Zone de saisie ───────────────────────────────────────────────────────── */
.input-area { position: relative; }

textarea#probleme {
  width: 100%;
  min-height: 110px;
  padding: 14px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-family: var(--font);
  color: var(--dark);
  resize: vertical;
  transition: border-color .2s;
  line-height: 1.5;
}

textarea#probleme:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(29,158,117,.12);
}

.input-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 12px;
  gap: 12px;
  flex-wrap: wrap;
}

.char-count {
  font-size: 0.78rem;
  color: var(--gray);
}

.char-count.warn { color: var(--orange); }
.char-count.over { color: var(--red); }

/* ── Bouton principal ─────────────────────────────────────────────────────── */
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 28px;
  background: var(--green);
  color: var(--white);
  border: none;
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: background .2s, transform .1s;
  font-family: var(--font);
}

.btn-primary:hover:not(:disabled) { background: var(--green-dark); }
.btn-primary:active:not(:disabled) { transform: scale(.97); }

.btn-primary:disabled {
  opacity: .55;
  cursor: not-allowed;
}

/* ── Loader ───────────────────────────────────────────────────────────────── */
.spinner {
  width: 18px; height: 18px;
  border: 2.5px solid rgba(255,255,255,.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  display: none;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Résultat ─────────────────────────────────────────────────────────────── */
#result-section { display: none; }

.result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 10px;
}

.result-meta {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: .3px;
}

.badge-facile  { background: #d4f5e7; color: #0e7a52; }
.badge-moyen   { background: #fef3cd; color: #9a6a00; }
.badge-difficile { background: #fde8e6; color: #a33a2e; }
.badge-temps   { background: var(--gray-light); color: var(--gray); border: 1px solid var(--border); }

.result-blocks { display: grid; gap: 16px; }

.result-block {
  background: var(--gray-light);
  border-radius: 8px;
  padding: 18px;
  border-left: 4px solid var(--green);
}

.result-block.pro-block { border-left-color: var(--orange); }
.result-block.pro-block .block-title { color: var(--orange); }
.result-block.pro-null { border-left-color: var(--green); opacity: .7; }

.block-title {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--green);
  margin-bottom: 8px;
}

.result-block p { font-size: 0.95rem; line-height: 1.65; }

.solution-steps { list-style: none; }

.solution-steps li {
  display: flex;
  gap: 12px;
  padding: 7px 0;
  font-size: 0.93rem;
  border-bottom: 1px solid var(--border);
  align-items: flex-start;
}

.solution-steps li:last-child { border-bottom: none; }

.step-num {
  flex-shrink: 0;
  width: 24px; height: 24px;
  background: var(--green);
  color: var(--white);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  margin-top: 1px;
}

/* ── Erreur ───────────────────────────────────────────────────────────────── */
.error-box {
  background: #fde8e6;
  border: 1.5px solid #f5a49d;
  color: var(--red);
  border-radius: var(--radius);
  padding: 14px 18px;
  font-size: 0.9rem;
  display: none;
  margin-top: 14px;
}

/* ── Historique ───────────────────────────────────────────────────────────── */
#history-section { margin-top: 12px; }

.history-list { display: grid; gap: 10px; }

.history-item {
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
  cursor: pointer;
  transition: border-color .2s, box-shadow .2s;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.history-item:hover {
  border-color: var(--green);
  box-shadow: 0 2px 8px rgba(29,158,117,.1);
}

.history-item-text {
  flex: 1;
  min-width: 0;
}

.history-item-probleme {
  font-size: 0.9rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--dark);
}

.history-item-meta {
  font-size: 0.75rem;
  color: var(--gray);
  margin-top: 3px;
}

.history-item-badge { flex-shrink: 0; }

.btn-clear-history {
  background: none;
  border: 1px solid var(--border);
  color: var(--gray);
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 0.78rem;
  cursor: pointer;
  transition: all .2s;
}

.btn-clear-history:hover { border-color: var(--red); color: var(--red); }

.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  flex-wrap: wrap;
  gap: 8px;
}

.empty-history {
  color: var(--gray);
  font-size: 0.88rem;
  text-align: center;
  padding: 20px;
  border: 1.5px dashed var(--border);
  border-radius: var(--radius);
}

/* ── Footer ───────────────────────────────────────────────────────────────── */
footer {
  background: var(--white);
  border-top: 1px solid var(--border);
  padding: 18px 0;
  text-align: center;
  font-size: 0.8rem;
  color: var(--gray);
}

footer a { color: var(--green); text-decoration: none; }
footer a:hover { text-decoration: underline; }

/* ── Exemples rapides ─────────────────────────────────────────────────────── */
.exemples-label {
  font-size: 0.8rem;
  color: var(--gray);
  margin-top: 10px;
  margin-bottom: 6px;
}

.exemples-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.exemple-btn {
  background: none;
  border: 1.5px solid var(--border);
  color: var(--gray);
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.78rem;
  cursor: pointer;
  transition: all .2s;
  font-family: var(--font);
}

.exemple-btn:hover { border-color: var(--green); color: var(--green); }

/* ── Accordion profil ─────────────────────────────────────────────────────── */
.accordion-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
  list-style: none;
}

.accordion-toggle::-webkit-details-marker { display: none; }

.accordion-arrow {
  transition: transform .25s;
  color: var(--gray);
  font-size: 0.85rem;
}

details[open] .accordion-arrow { transform: rotate(180deg); }

.accordion-body { margin-top: 18px; }

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 540px) {
  .profil-grid { grid-template-columns: 1fr 1fr; }
  .btn-primary { width: 100%; justify-content: center; }
  .result-header { flex-direction: column; align-items: flex-start; }
  .header-tagline { display: none; }
}

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

/* ── Publicité contextuelle ───────────────────────────────────────────────── */
#zone-publicite {
  transition: opacity 0.4s ease;
  margin-top: 1.5rem;
}

.ad-card {
  border: 1px dashed #B4B2A9;
  border-radius: 10px;
  padding: 1rem 1.25rem;
  background: #F9F9F7;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ad-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #888780;
  font-weight: 500;
}

.ad-title {
  font-size: 14px;
  font-weight: 500;
  color: #2C2C2A;
  margin: 0;
}

.ad-desc {
  font-size: 13px;
  color: #5F5E5A;
  margin: 0;
}

.ad-btn {
  display: inline-block;
  margin-top: 6px;
  font-size: 13px;
  color: #0F6E56;
  font-weight: 500;
  text-decoration: none;
  border: 1px solid #1D9E75;
  border-radius: 6px;
  padding: 6px 14px;
  width: fit-content;
  transition: background 0.2s;
}

.ad-btn:hover { background: #E1F5EE; }

/* Mention pub dans le footer */
.mention-pub {
  font-size: 0.72rem;
  color: var(--gray);
  margin-top: 6px;
  opacity: .75;
}

.mention-pub a { color: var(--green); }

@media (max-width: 540px) {
  .ad-card { padding: .85rem 1rem; }
  .ad-btn  { width: 100%; text-align: center; }
}

/* ── Blocs Google AdSense ─────────────────────────────────────────────────── */
.ad-adsense {
  margin: 1.5rem 0;
  text-align: center;
  min-height: 90px;
}

.ad-top { margin-bottom: 2rem; }

.ad-footer {
  margin-top: 2rem;
  border-top: 1px solid #E8E8E5;
  padding-top: 1rem;
}

.ad-article-top,
.ad-article-mid {
  margin: 1.5rem 0;
  border-radius: 8px;
  overflow: hidden;
}

/* Masquage global pour les abonnés Premium */
body.user-premium .ad-adsense {
  display: none !important;
}

@media (max-width: 600px) {
  .ad-adsense { margin: 1rem 0; }
}
