/* ============================================================
   MODALS (CORRECTIONS MOBILE)
   ============================================================ */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.7);
  z-index: 300;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  backdrop-filter: blur(4px);
  animation: fadeIn .15s ease;
  overflow-y: auto;
}

.modal.open {
  display: flex;
}

@keyframes fadeIn {
  from { opacity: 0 }
  to { opacity: 1 }
}

.modal-box {
  background: var(--card-bg);
  border: 1px solid var(--border2);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
  animation: slideUp .2s ease;
  margin: auto;
}

.modal-box.modal-lg {
  max-width: 700px;
}

.modal-box.modal-full {
  max-width: 900px;
  max-height: 95vh;
}

/* Modal PDF preview — presque plein écran */
.modal-box.modal-pdf {
  max-width: 92vw;
  width: 92vw;
  max-height: 94vh;
  height: 94vh;
  display: flex;
  flex-direction: column;
}
.modal-box.modal-pdf .modal-body {
  flex: 1;
  padding: 0;
  overflow: hidden;
}
.modal-box.modal-pdf #pdf-iframe {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(10px) }
  to { opacity: 1; transform: translateY(0) }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  position: sticky;
  top: 0;
  background: var(--card-bg);
  z-index: 10;
}

.modal-header h3 {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-weight: 700;
  font-size: 15px;
  flex: 1;
  min-width: 0;
}

.modal-close {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  flex-shrink: 0;
  margin-left: 8px;
}

.modal-close:hover {
  background: var(--hover);
  color: var(--text);
}

.modal-body {
  padding: 16px 20px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  flex-shrink: 0;
  flex-wrap: wrap;
  position: sticky;
  bottom: 0;
  background: var(--card-bg);
  z-index: 10;
}

.modal-hint {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 12px;
  line-height: 1.6;
}

.modal-body textarea {
  width: 100%;
}

/* Toasts */
.toast {
  background: var(--card-bg);
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 13px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(8px);
  transition: all .25s ease;
  max-width: 360px;
  word-break: break-word;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast-success {
  border-left: 3px solid var(--green);
}

.toast-error {
  border-left: 3px solid var(--red);
}

.toast-info {
  border-left: 3px solid var(--blue);
}

#toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--muted);
}

.empty-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

.empty-state p {
  font-size: 14px;
  margin-bottom: 6px;
}

.empty-sub {
  font-size: 12px;
  color: var(--sub);
  margin-bottom: 16px;
}

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 16px 0;
  margin-top: 8px;
}

.pagination-btn {
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border2);
  background: var(--input-bg);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  transition: all .15s;
}

.pagination-btn:hover {
  background: var(--hover);
}

.pagination-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #0f1117;
}

.pagination-btn:disabled {
  opacity: .4;
  cursor: not-allowed;
}

.pagination-info {
  font-size: 12px;
  color: var(--muted);
}


/* ── Panneau options résumé ───────────────────────────────── */
.resume-options-panel {
  animation: fadeIn .2s ease;
}
.resume-options-panel.hidden { display: none !important; }
/* ── Responsive ───────────────────────────────────────────── */
@media(max-width: 900px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    z-index: 200;
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .hamburger {
    display: flex !important;
  }

  /* ── Éditeur CV mobile — scroll vertical ── */
  .editor-layout {
    flex-direction: column;
  }
  .editor-panel {
    height: auto !important;
    min-height: 60vh;
    max-height: 70vh;
    overflow-y: auto;
  }
  .editor-preview { min-height: 50vh; }

  /* ── Lettre de motivation mobile ── */
  .lettre-layout {
    flex-direction: column;
    height: auto;         /* Scroll vertical sur mobile */
    min-height: 100vh;
    overflow: visible;
  }
  #section-lettre {
    overflow-y: auto;
    height: calc(100vh - var(--topbar-h));
    height: calc(100dvh - var(--topbar-h));
  }
  .lettre-panel {
    width: 100%;
    flex-shrink: 0;
    border-right: none;
    border-bottom: 1px solid var(--border);
    max-height: 60vh;
  }
  .lettre-scroll {
    max-height: calc(60vh - 52px); /* 60vh - toolbar height */
  }
  .lettre-preview-panel {
    flex: 1;              /* Conserver flex:1 même sur mobile */
    min-height: 500px;
    height: 500px;
    overflow: hidden;
  }

  .dash-stats {
    grid-template-columns: repeat(2, 1fr);
  }

  .config-stats {
    grid-template-columns: repeat(2, 1fr);
  }

  .famille-secteurs-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .cand-stats {
    grid-template-columns: repeat(3, 1fr);
  }

  .emails-table {
    font-size: 12px;
  }

  .competence-score-row {
    grid-template-columns: 1fr 100px 60px;
  }

  /* Modals adaptés tablette */
  .modal {
    padding: 12px;
  }

  .modal-box {
    max-height: 92vh;
  }

  .modal-header,
  .modal-footer {
    padding: 14px 16px;
  }

  .modal-body {
    padding: 14px 16px;
  }

  /* ───────────────────────────────────────────────────────
     CORRECTIONS SCROLL MOBILE — ajoutées ciblées
     Desktop inchangé, overrides uniquement ici
  ─────────────────────────────────────────────────────── */

  /* 🔴 FIX 1 — Permettre le scroll au doigt sur mobile */
  html, body {
    overflow: visible;
  }

  /* 🔴 FIX 2 — App wrapper : scroll vertical autorisé */
  .app-wrapper {
    overflow-x: hidden;
    overflow-y: visible;
  }

  /* 🔴 FIX 3 — Main content : scroll vertical */
  .main-content {
    overflow-x: hidden;
    overflow-y: auto;
    padding-bottom: calc(60px + env(safe-area-inset-bottom, 0px));
  }

  /* 🔴 FIX 4 — Sections : hauteur auto (plus de hauteur fixe) */
  .section {
    height: auto;
    min-height: calc(100vh - var(--topbar-h) - 60px);
    overflow-y: visible;
  }

  /* 🟠 FIX 5 — Editor panel : supprimer la limite de hauteur */
  .editor-panel {
    max-height: none;
    height: auto;
    overflow-y: auto;
  }

  /* 🟠 FIX 6 — Boutons éditeur : retour à la ligne */
  .editor-btns {
    flex-wrap: wrap;
    gap: 4px;
  }

  /* 🟡 FIX 7 — Section lettre : scroll libre */
  #section-lettre {
    height: auto;
    min-height: calc(100vh - var(--topbar-h) - 60px);
    overflow-y: auto;
  }

  /* 🟡 FIX 8 — Wizard portfolio : navigation scrollable */
  .wizard-nav {
    flex-wrap: wrap;
    gap: 6px;
  }

  .wizard-steps {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 6px;
    flex-wrap: nowrap;
  }

  .wizard-content {
    overflow-y: auto;
  }

  /* Sections profil, candidatures, offres : scroll libre */
  #section-profil,
  #section-offres,
  #section-candidatures,
  #section-mes-cvs,
  #section-portfolio,
  #section-dashboard,
  #section-config {
    overflow-y: auto;
  }

  /* Editor preview scrollable sur mobile */
  .editor-preview {
    overflow-y: auto;
  }

  /* Panel lettre de motivation : pas de hauteur max */
  .lettre-panel {
    max-height: none;
    height: auto;
  }
  .lettre-scroll {
    overflow-y: visible;
    max-height: none;
  }

  /* Boutons section header : wrap sur petits écrans */
  .section-header {
    flex-wrap: wrap;
    gap: 8px;
  }


  /* ══════════════════════════════════════════════════════════
     CORRECTIONS SCROLL MOBILE COMPLÉMENTAIRES
     Ces règles corrigent les zones figées identifiées
     Desktop : INCHANGÉ — overrides uniquement dans ce bloc
  ════════════════════════════════════════════════════════════ */

  /* 1. Éditeur CV — lever le verrouillage de hauteur */
  #section-editeur {
    overflow: visible !important;
  }

  .editor-layout {
    height: auto !important;
    overflow: visible !important;
  }

  /* editor-scroll ne peut pas être flex:1 quand parent est height:auto */
  .editor-scroll {
    flex: none !important;
    overflow-y: visible !important;
    min-height: 50vh;
    height: auto !important;
  }

  .editor-preview {
    overflow-y: visible !important;
    height: auto !important;
    min-height: 40vh;
  }

  /* 2. Lettre de motivation — lever le verrouillage de hauteur */
  #section-lettre {
    height: auto !important;
    min-height: calc(100vh - var(--topbar-h));
    overflow-y: visible !important;
  }

  .lettre-preview-panel {
    height: auto !important;
    min-height: 300px;
    overflow: visible !important;
  }

  /* 3. Portfolio / Wizard — scroll libre */
  .wizard-content {
    overflow-y: visible !important;
    height: auto !important;
  }

  #section-portfolio {
    overflow-y: visible;
  }

  .slides-preview-grid {
    max-height: none !important;
    overflow-y: visible !important;
  }

  /* 4. iOS : scroll fluide avec inertie sur les éléments scrollables */
  .main-content,
  .modal-body,
  .editor-panel,
  .lettre-panel {
    -webkit-overflow-scrolling: touch;
  }

  /* 5. Toutes les sections avec conteneurs à hauteur fixe */
  .profil-photo-col,
  .profil-infos-layout {
    height: auto !important;
    overflow: visible;
  }

  /* 6. Cards et grilles — pas de dépassement latéral */
  .offres-grid,
  .cv-list,
  .entreprises-grid,
  .portfolios-grid {
    overflow-x: hidden;
  }

  /* 7. Tableaux : scroll horizontal sur mobile */
  .emails-table,
  .cand-table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* 8. Section header : empiler boutons sur très petits écrans */
  .section-header {
    flex-wrap: wrap;
    gap: 8px;
  }

  .section-header > div,
  .section-header > button {
    flex-shrink: 0;
  }

  /* 9. ATS panel sur mobile — fermé par défaut, s'ouvre au clic comme sur desktop */
  .ats-panel.open {
    max-height: 320px;
  }

  /* ── Topbar sticky sur mobile ── */
  .topbar {
    position: sticky;
    top: 0;
    z-index: 150;
  }

  /* ── Tableau sites scraping : scroll horizontal sur mobile ── */
  #sites-list {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .sites-table {
    min-width: 580px;
  }

  /* ── Actions offres : scroll horizontal (bookmark toujours visible) ── */
  .offre-card-actions {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
  }
  .offre-card-actions button {
    flex-shrink: 0;
  }
  .btn-bookmark {
    margin-left: 0;
  }

  .offre-match-badge .match-source-label { display: none; }

}

@media(max-width: 600px) {
  .section {
    padding: 14px;
  }

  .dash-stats,
  .dash-grid {
    grid-template-columns: 1fr 1fr;
  }

  .dash-grid {
    grid-template-columns: 1fr;
  }

  .form-row,
  .form-row-3 {
    grid-template-columns: 1fr;
  }

  .offres-grid,
  .entreprises-grid,
  .cvs-container {
    grid-template-columns: 1fr;
  }

  .template-grid {
    grid-template-columns: 1fr 1fr;
  }

  .cand-stats {
    grid-template-columns: 1fr 1fr 1fr;
  }

  .auth-container {
    padding: 24px 18px 20px;
  }

  .competence-score-row {
    grid-template-columns: 1fr;
  }

  /* Modals optimisés mobile */
  .modal {
    padding: 8px;
    align-items: flex-start;
  }

  .modal-box {
    max-height: 96vh;
    max-width: 100%;
    border-radius: var(--radius);
    margin-top: 8px;
    margin-bottom: 8px;
  }

  .modal-header {
    padding: 12px 14px;
    position: sticky;
    top: 0;
  }

  .modal-header h3 {
    font-size: 14px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .modal-close {
    font-size: 20px;
    padding: 6px 10px;
  }

  .modal-body {
    padding: 12px 14px;
  }

  .modal-footer {
    padding: 10px 14px;
    position: sticky;
    bottom: 0;
    gap: 6px;
  }

  .modal-footer .btn {
    flex: 1;
    justify-content: center;
  }

  .modal-box.modal-full,
  .modal-box.modal-lg {
    max-width: 100%;
    max-height: 98vh;
    margin: 4px;
  }

  /* ── Scroll mobile petits écrans ── */

  /* Sections : scroll libre */
  .section {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Editor panel : scroll complet */
  .editor-panel {
    max-height: 80vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Editor preview en dessous */
  .editor-preview {
    min-height: 400px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Wizard étapes : scroll horizontal */
  .wizard-steps {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
  }

  .wizard-step .step-label {
    display: none;
  }

  /* Boutons wizard : taille réduite */
  .wizard-nav .btn {
    font-size: 12px;
    padding: 7px 10px;
  }

  /* Slides type grid : 2 colonnes */
  .slides-types-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  /* Portfolio wizard header */
  .section-header h1 {
    font-size: 18px;
  }

  /* Portfolio sections list */
  #portfolios-container {
    overflow-y: auto;
  }
}

/* ── Guide SMTP ─────────────────────────────────────────────── */
.smtp-guide-section-title {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text);
}
.smtp-guide-provider-block {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
  margin-bottom: 14px;
}
.smtp-guide-warning {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  background: rgba(245,158,11,.08);
  border: 1px solid rgba(245,158,11,.25);
  border-radius: 6px;
  padding: 8px 12px;
  margin-bottom: 10px;
  font-size: 12px;
  color: #b45309;
}
.smtp-guide-steps {
  margin: 0;
  padding-left: 20px;
  font-size: 13px;
  color: var(--text);
  line-height: 1.7;
}
.smtp-guide-steps li { margin-bottom: 2px; }


