/* ============================================================
   RESPONSIVE.CSS — Générateur de CV MonSuperCV
   Inclure APRÈS styles.css
   > 1024px = Desktop : comportement original intact
   ≤ 1024px = Tablette/Mobile : nav 3 onglets
   ============================================================ */

:root { --mob-nav-h: 64px; }

@media (min-width: 1025px) {
  .mob-bottom-nav { display: none !important; }
}

@media (max-width: 1024px) {

  body {
    padding-bottom: var(--mob-nav-h) !important;
    overflow-x: hidden !important;
  }

  /* ── Topbar ── */
  .topbar {
    padding: 8px 12px; min-height: 50px;
    position: sticky; top: 0; z-index: 900;
  }
  .brand span { font-size: 14px; }
  .topbar-actions { gap: 6px; flex-wrap: nowrap; }
  .topbar-btn .btn-label { display: none; }
  .topbar-btn { padding: 8px 10px; height: 36px; min-width: 36px; justify-content: center; gap: 0; }
  .topbar-btn svg { width: 16px; height: 16px; }
  .cv-counter-badge .badge-label { display: none; }
  .cv-counter-badge { padding: 6px 10px; }

  /* ── App shell ── */
  .app-shell { grid-template-columns: 1fr !important; gap: 0 !important; padding: 0 !important; }

  /* ── Panneaux masqués par défaut ── */
  .side-panel {
    display: none !important; position: static !important;
    width: 100% !important; height: auto !important;
    max-height: calc(100dvh - 50px - var(--mob-nav-h)) !important;
    overflow-y: auto !important; overflow-x: hidden !important;
    border-radius: 0 !important; border: none !important;
    border-top: 1px solid #e5e7eb !important;
    box-shadow: none !important; margin: 0 !important; top: auto !important;
    -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
  }

  .preview-wrap {
    display: none !important; padding: 12px 0 16px !important;
    width: 100% !important;
    /* overflow-y:auto pour permettre le scroll vertical du CV
       overflow-x:hidden car le .preview-scale-wrapper gère déjà le clip horizontal */
    overflow-y: auto !important;
    overflow-x: hidden !important;
    flex-direction: column !important;
    align-items: center !important;
    min-height: 0 !important;
    box-sizing: border-box !important;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }

  .right-column-stack {
    display: none !important; flex-direction: column !important;
    width: 100% !important; padding: 8px !important; gap: 8px !important;
    max-height: calc(100dvh - 50px - var(--mob-nav-h)) !important;
    overflow-y: auto !important; position: static !important; top: auto !important;
    -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
  }

  /* ── Panneau actif ── */
  .side-panel.mob-active         { display: flex !important; }
  .preview-wrap.mob-active       { display: flex !important; max-height: calc(100dvh - 50px - var(--mob-nav-h)) !important; }
  .right-column-stack.mob-active { display: flex !important; }

  .mob-active { animation: panelIn .15s ease both; }
  @keyframes panelIn { from { opacity:0; transform:translateY(4px); } to { opacity:1; transform:translateY(0); } }

  /* ★ WRAPPER CV — dimensions exactes fixées par JS
     Le JS calcule: width = A4_W * scale, height = cvH * scale
     transform-origin: top left, donc le CV scale depuis le coin haut-gauche
     sans aucun débordement ni coupure sur les côtés.
  */
  .preview-scale-wrapper {
    /* overflow:hidden pour clipper l'éventuel 1px résiduel */
    overflow: hidden;
    flex-shrink: 0;
    /* width + height fixés par JS */
  }

  .cv-preview {
    transform-origin: top left !important;
    flex-shrink: 0;
  }

  /* ── UI interne ── */
  .panel-block { border-radius: 10px; margin-bottom: 8px; }
  .template-modal-trigger { width: calc(100% - 16px); margin: 8px; box-sizing: border-box; }
  .toggle-list { grid-template-columns: 1fr !important; }
  .personnalisation-2-panel, .tips-panel { width: 100% !important; flex: none !important; }
  .color-grid { grid-template-columns: 1fr 1fr !important; }
  .color-presets { grid-template-columns: 1fr 1fr !important; }

  /* ── Modal : bottom sheet ── */
  .template-modal { align-items: flex-end; }
  .template-modal-content {
    width: 100vw !important; max-width: 100vw !important;
    border-radius: 18px 18px 0 0 !important; max-height: 85vh;
  }
  .template-modal-grid { grid-template-columns: repeat(3,1fr) !important; gap:10px; padding:12px; }

  /* ── NAV BOTTOM ── */
  .mob-bottom-nav {
    display: flex !important; position: fixed !important;
    bottom: 0 !important; left: 0 !important; right: 0 !important;
    height: var(--mob-nav-h) !important; z-index: 1000 !important;
    background: #fff !important; border-top: 1px solid #e2e8f0 !important;
    box-shadow: 0 -4px 20px rgba(15,23,42,.10) !important;
    align-items: stretch !important;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .mob-nav-btn {
    flex: 1; display: flex; flex-direction: column;
    align-items: center; justify-content: center; gap: 4px;
    background: none; border: none; cursor: pointer;
    color: #94a3b8; font-size: 11px; font-weight: 600;
    padding: 8px 4px 6px; transition: color .15s;
    position: relative; -webkit-tap-highlight-color: transparent;
    user-select: none; outline: none;
  }
  .mob-nav-btn svg { width: 24px; height: 24px; transition: transform .18s; }
  .mob-nav-btn.mob-active { color: #2563eb; }
  .mob-nav-btn.mob-active svg { transform: translateY(-2px); }
  .mob-nav-btn::after {
    content: ''; position: absolute;
    top: 0; left: 25%; right: 25%; height: 2.5px;
    background: #2563eb; border-radius: 0 0 3px 3px;
    transform: scaleX(0); transition: transform .2s ease;
  }
  .mob-nav-btn.mob-active::after { transform: scaleX(1); }
}

@media (max-width: 1024px) {
  /* ── Cible tactile barres compétences/langues (mobile/tablette uniquement) ──
     La barre de 5px scale à ~2px visuel → trop petit à taper.
     On cache la barre fine (visuelle uniquement sur le CV exporté) et on
     affiche un picker 25/50/75/100 cliquable au doigt.
     Exclu en .pdf-mode pour ne pas déformer la capture. ── */
  body:not(.pdf-mode) .skill-level-container {
    flex-direction: column;
    align-items: stretch;
  }
  body:not(.pdf-mode) .mobile-skill-picker {
    display: grid !important;
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
    margin-top: 4px;
  }
  body:not(.pdf-mode) .mobile-skill-picker button {
    border: 1px solid rgba(0,0,0,0.15);
    background: rgba(255,255,255,0.9);
    color: #334155;
    font-size: 11px;
    font-weight: 700;
    padding: 6px 0;
    border-radius: 6px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: background-color .12s, transform .08s, box-shadow .12s;
  }
  body:not(.pdf-mode) .mobile-skill-picker button:active {
    transform: scale(.96);
  }
  body:not(.pdf-mode) .mobile-skill-picker button.active {
    background: #2563eb;
    border-color: #2563eb;
    color: #ffffff;
    box-shadow: 0 2px 6px rgba(37,99,235,0.3);
  }
  /* Sur panneau gauche sombre, adapter les boutons */
  body:not(.pdf-mode) .cv-left-panel .mobile-skill-picker button {
    background: rgba(255,255,255,0.1);
    color: rgba(255,255,255,0.85);
    border-color: rgba(255,255,255,0.2);
  }
  body:not(.pdf-mode) .cv-left-panel .mobile-skill-picker button.active {
    background: rgba(255,255,255,0.95);
    color: #1e293b;
    border-color: #ffffff;
  }
}

/* Picker mobile masqué en desktop ET pendant la capture PDF */
.mobile-skill-picker { display: none; }
body.pdf-mode .mobile-skill-picker { display: none !important; }

@media (max-width: 480px) {
  .template-modal-grid { grid-template-columns: repeat(2,1fr) !important; }
  .mob-nav-btn { font-size: 10px; }
  .mob-nav-btn svg { width: 22px; height: 22px; }
}
@media (max-width: 360px) {
  .mob-nav-btn { font-size: 9px; gap: 3px; }
  .mob-nav-btn svg { width: 20px; height: 20px; }
  .topbar-btn { padding: 6px 6px; min-width: 30px; }
}