/* ==========================================================================
   JD-SERVICES — FEUILLE DE STYLE RESPONSIVE OPTIMISÉE (responsive.css)
   Adaptation rigoureuse multi-écrans : Desktop HD (1920px) -> Tablettes -> Mobiles (320px)
   ========================================================================== */

/* --------------------------------------------------------------------------
   0. RÈGLES UNIVERSELLES DE SÉCURITÉ RESPONSIVE (Anti-débordement & Anti-chevauchement)
   -------------------------------------------------------------------------- */
html, body {
  max-width: 100%;
  width: 100%;
  overflow-x: hidden !important;
  position: relative;
}

/* Empêche les longs mots techniques en français de traverser l'écran */
h1, h2, h3, h4, h5, h6, .lead, p, span, strong, a {
  overflow-wrap: break-word;
  word-break: normal;
}

/* Images, canvas et SVG toujours fluides */
img, svg, video, iframe {
  max-width: 100%;
}

/* --------------------------------------------------------------------------
   1. LAPTOPS & PETITS DESKTOPS (1200px - 1025px)
   -------------------------------------------------------------------------- */
@media (max-width: 1200px) {
  .hero-grid {
    grid-template-columns: 1fr;
    gap: 3.5rem;
    min-width: 0;
  }

  .hero-content {
    max-width: 100%;
    min-width: 0;
    width: 100%;
    text-align: center;
  }

  .hero-badge-pill {
    margin-left: auto;
    margin-right: auto;
  }

  .hero-ctas {
    justify-content: center;
  }

  .hero-indicators {
    justify-content: center;
  }

  .hero-visual {
    max-width: 560px;
    margin: 0 auto;
    width: 100%;
  }

  .timeline-flow {
    grid-template-columns: repeat(4, 1fr);
  }

  .footer-grid {
    grid-template-columns: 1.6fr repeat(3, 1fr);
    gap: 2.5rem;
  }
}

/* --------------------------------------------------------------------------
   2. TABLETTES & IPAD (1024px - 769px)
   -------------------------------------------------------------------------- */
@media (max-width: 1024px) {
  :root {
    --header-height: 75px;
  }

  /* Header & Navigation Mobile/Tablette */
  .site-header {
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--color-border);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
  }

  /* Sur tablette & mobile, le header a un fond opaque propre : logo sombre */
  .site-header .header-logo-img.logo-white {
    display: none !important;
  }
  .site-header .header-logo-img.logo-dark {
    display: block !important;
  }
  .site-header .mobile-toggle span {
    background-color: var(--color-text-dark) !important;
  }

  .mobile-toggle {
    display: flex;
    z-index: 10001;
  }

  /* Animation burger -> croix */
  .mobile-toggle[aria-expanded="true"] span:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
  }
  .mobile-toggle[aria-expanded="true"] span:nth-child(2) {
    opacity: 0;
    transform: scaleX(0);
  }
  .mobile-toggle[aria-expanded="true"] span:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
  }

  /* Menu coulissant latéral */
  .nav-menu {
    position: fixed;
    top: var(--header-height);
    left: 0;
    width: 100%;
    height: calc(100vh - var(--header-height));
    height: calc(100dvh - var(--header-height));
    background: var(--color-white);
    flex-direction: column;
    align-items: stretch;
    padding: 1.5rem 1.5rem 3.5rem;
    gap: 0.5rem;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    transform: translateX(100%);
    transition: transform var(--transition-normal);
    box-shadow: var(--shadow-xl);
    z-index: 10000;
    white-space: normal !important;
  }

  .nav-menu.is-open {
    transform: translateX(0);
  }

  .nav-item {
    width: 100%;
    flex-shrink: 0;
  }

  .nav-link {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--color-text-dark) !important;
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.9rem 0.5rem;
    border-bottom: 1px solid var(--color-border);
    white-space: normal !important;
  }

  .nav-link-chevron {
    color: var(--color-text-muted) !important;
    transition: transform var(--transition-normal);
  }

  .nav-item.is-expanded .nav-link-chevron {
    transform: rotate(180deg);
  }

  /* Méga-menu déroulant en accordéon */
  .mega-menu {
    position: static !important;
    transform: none !important;
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
    min-width: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    box-shadow: none !important;
    border: none !important;
    padding: 0.5rem 0.5rem 0.75rem 0.75rem !important;
    margin: 0.25rem 0 0.5rem !important;
    display: none;
    background: #F8FAFC !important;
    border-radius: var(--radius-md) !important;
    white-space: normal !important;
  }

  .nav-item.is-expanded .mega-menu {
    display: block !important;
  }

  .mega-menu-grid {
    grid-template-columns: 1fr !important;
    gap: 0.4rem !important;
  }

  .mega-item {
    padding: 0.65rem 0.5rem !important;
    border-radius: var(--radius-sm);
    white-space: normal !important;
  }

  .mega-title {
    font-size: 0.95rem;
    color: var(--color-text-dark);
  }

  .mega-desc {
    font-size: 0.82rem;
    color: var(--color-text-muted);
    line-height: 1.4;
  }

  /* Bouton d'action dans le header sur tablette */
  .header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
  }

  .header-actions .btn {
    display: inline-flex;
    padding: 0.55rem 1.15rem;
    font-size: 0.85rem;
  }

  /* Grilles sur tablette */
  .intro-grid {
    grid-template-columns: 1fr;
    gap: 2.5rem;
  }

  .services-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
  }

  .industries-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
  }

  .packages-grid {
    grid-template-columns: 1fr;
    max-width: 520px;
    margin: 0 auto;
    gap: 2rem;
  }

  .timeline-flow {
    grid-template-columns: repeat(3, 1fr);
    gap: 1.25rem;
  }

  .footer-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 2.5rem;
  }

  .footer-brand-col {
    grid-column: 1 / -1;
    max-width: 100%;
  }

  /* Table comparative sur tablette : défilement fluide sans cassure */
  .table-responsive-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .comparison-table {
    min-width: 640px;
  }
}

/* --------------------------------------------------------------------------
   3. SMARTPHONES & PETITES PHABLETTES (768px - 481px)
   -------------------------------------------------------------------------- */
@media (max-width: 768px) {
  :root {
    --header-height: 68px;
  }

  /* Réduction propre des espacements de sections */
  .section-spacing {
    padding: 4rem 0;
  }

  .section-spacing-sm {
    padding: 2.75rem 0;
  }

  .section-header {
    margin-bottom: 2.5rem;
  }

  .section-header h2 {
    font-size: clamp(1.6rem, 5.5vw, 2.1rem);
  }

  /* Header actions sur mobile : conserver le bouton original unique */
  .header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
  }

  .header-actions .btn {
    display: inline-flex;
    padding: 0.42rem 0.75rem;
    font-size: 0.75rem;
    white-space: nowrap;
  }

  .btn-text-desktop {
    display: none !important;
  }

  .btn-text-mobile {
    display: inline !important;
  }

  .header-logo-img {
    height: 32px;
  }

  /* Hero Section */
  .hero-section {
    padding: 6.25rem 0 3.75rem;
    min-height: auto;
  }

  .hero-grid {
    grid-template-columns: 100% !important;
    min-width: 0 !important;
    width: 100% !important;
  }

  .hero-content {
    min-width: 0 !important;
    max-width: 100% !important;
    width: 100% !important;
  }

  .hero-badge-pill {
    max-width: 100% !important;
    white-space: normal !important;
    text-align: center !important;
    font-size: 0.72rem !important;
    line-height: 1.35 !important;
    display: inline-flex !important;
    justify-content: center !important;
    box-sizing: border-box !important;
    padding: 0.35rem 0.75rem !important;
  }

  .hero-badge-pill span:not(.pulse-dot) {
    white-space: normal !important;
    word-break: break-word !important;
    line-height: 1.35 !important;
  }

  .hero-title {
    font-size: clamp(2rem, 6.5vw, 2.75rem);
    line-height: 1.2;
  }

  .hero-subtitle {
    font-size: 1.05rem;
    line-height: 1.6;
  }

  .hero-ctas {
    flex-direction: column;
    gap: 1rem;
    width: 100%;
  }

  .hero-ctas .btn {
    width: 100%;
    justify-content: center;
    white-space: normal !important;
    text-align: center;
    line-height: 1.35;
  }

  .hero-indicators {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    text-align: left;
  }

  .hero-indicator-item {
    font-size: 0.74rem;
  }

  /* Schéma Réseau Hero sur mobile */
  .tech-window {
    padding: 1.15rem 0.85rem;
    border-radius: var(--radius-lg);
  }

  .tech-window-header {
    gap: 0.5rem;
    padding-bottom: 0.75rem;
    margin-bottom: 1rem;
    min-height: 32px;
  }

  .window-title {
    font-size: 0.65rem;
    letter-spacing: 0.02em;
  }

  .window-status {
    font-size: 0.62rem;
    padding: 3px 6px;
    gap: 4px;
  }

  #hero-topology-svg {
    display: block;
    width: 100%;
    height: auto;
    max-width: 100%;
  }

  /* Métriques d'enjeux */
  .intro-metrics-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.85rem;
  }

  .intro-metric-item {
    text-align: center;
  }

  .intro-metric-value {
    font-size: 1.85rem !important;
  }

  .intro-metric-label {
    font-size: 0.74rem !important;
  }

  .intro-graphic-card .btn {
    width: 100%;
    justify-content: center;
  }

  /* Schéma d'Architecture Réseau Mobile */
  .architecture-desktop-view {
    display: none !important;
  }

  .architecture-mobile-view {
    display: flex !important;
    flex-direction: column;
    align-items: center;
    width: 100%;
    gap: 0;
  }

  .architecture-window {
    padding: 1.25rem 0.85rem;
    border-radius: var(--radius-lg);
  }

  .architecture-diagram-header {
    font-size: 0.72rem;
    margin-bottom: 1.25rem;
    line-height: 1.4;
  }

  .architecture-cta-btn {
    white-space: normal !important;
    max-width: 100% !important;
    word-break: break-word !important;
    text-align: center !important;
    line-height: 1.35 !important;
    font-size: 0.85rem !important;
    padding: 0.85rem 1.25rem !important;
  }

  /* Grille des services en 1 colonne sur mobile */
  .services-grid {
    grid-template-columns: 1fr;
    gap: 1.25rem;
  }

  .service-card-body {
    padding: 1.35rem;
  }

  /* Grille des secteurs en 1 colonne sur mobile */
  .industries-grid {
    grid-template-columns: 1fr;
    gap: 1.25rem;
  }

  .industry-card {
    height: 240px;
    padding: 1.35rem;
  }

  /* Méthodologie : disposition carte claire en colonne */
  .timeline-flow {
    grid-template-columns: 1fr;
    gap: 1rem;
    margin-top: 2rem;
  }

  .timeline-step {
    text-align: left;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.35rem;
    padding: 1.25rem 1.5rem;
  }

  .timeline-number {
    font-size: 1.3rem;
    margin-bottom: 0.2rem;
  }

  /* Formulaire de contact */
  .form-grid {
    grid-template-columns: 1fr;
    gap: 1.25rem;
  }

  .form-card {
    padding: 1.5rem 1.25rem;
    border-radius: var(--radius-lg);
  }

  .form-control {
    font-size: 16px !important; /* Empêche le zoom automatique sur iOS */
  }

  .form-card .btn-lg {
    width: 100%;
    justify-content: center;
  }

  /* Modal de confirmation */
  .jd-modal-dialog {
    padding: 1.5rem 1.25rem;
    max-width: 95%;
  }

  /* Footer */
  .footer-grid {
    grid-template-columns: 1fr;
    gap: 2rem;
    margin-bottom: 2.5rem;
  }

  .footer-bottom {
    flex-direction: column;
    gap: 1rem;
    text-align: center;
  }

  .footer-bottom-links {
    flex-wrap: wrap;
    justify-content: center;
    gap: 1rem;
  }

  /* Transformation ergonomique du tableau comparatif sur mobile */
  .comparison-table {
    display: block;
    min-width: 0;
  }

  .table-responsive-wrap {
    border: none;
    box-shadow: none;
    background: transparent;
    padding: 0;
  }

  .comparison-table thead {
    display: none;
  }

  .comparison-table tbody,
  .comparison-table tr,
  .comparison-table td {
    display: block;
    width: 100%;
  }

  .comparison-table tr {
    background: var(--color-white);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    margin-bottom: 1.25rem;
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
  }

  .comparison-table td {
    padding: 0.65rem 0;
    border-bottom: 1px dashed var(--color-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    font-size: 0.9rem;
  }

  .comparison-table td:last-child {
    border-bottom: none;
  }

  .comparison-table td.col-service {
    font-weight: 700;
    font-size: 1rem;
    color: var(--color-text-dark);
    border-bottom: 2px solid var(--color-border);
    padding-bottom: 0.75rem;
    margin-bottom: 0.5rem;
    justify-content: flex-start;
  }

  .comparison-table td::before {
    content: attr(data-label);
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--color-text-muted);
    font-weight: 600;
    flex-shrink: 0;
  }

  .comparison-table td.col-service::before {
    display: none;
  }

  /* Sécurisation universelle des grilles subpages */
  [style*="grid-template-columns: 1fr 1fr"],
  [style*="grid-template-columns: repeat(3, 1fr)"],
  [style*="minmax(320px"],
  [style*="minmax(340px"],
  [style*="minmax(360px"] {
    grid-template-columns: 1fr !important;
    gap: 1.25rem !important;
  }
}

/* --------------------------------------------------------------------------
   4. PETITS SMARTPHONES (480px - 320px)
   -------------------------------------------------------------------------- */
@media (max-width: 480px) {
  :root {
    --header-height: 64px;
  }

  .container {
    padding: 0 1rem;
  }

  .hero-title {
    font-size: 1.85rem;
  }

  .hero-badge-pill {
    font-size: 0.7rem;
    padding: 0.35rem 0.75rem;
    gap: 0.4rem;
    white-space: normal;
    text-align: left;
  }

  .hero-indicators {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  /* Architecture Section Mobile 480px */
  .arch-vlans-mobile-grid {
    grid-template-columns: 1fr !important;
    gap: 0.5rem;
  }

  .arch-vlan-box {
    padding: 0.75rem 0.85rem;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    text-align: left;
  }

  .arch-vlan-box .vlan-tag {
    margin-bottom: 0;
  }

  .arch-vlan-box .vlan-title {
    margin-bottom: 0;
  }

  .arch-vlan-box .vlan-desc {
    text-align: right;
    max-width: 55%;
  }

  .architecture-cta-btn {
    font-size: 0.82rem !important;
    padding: 0.8rem 1rem !important;
  }

  .section-spacing {
    padding: 3.25rem 0;
  }

  .package-card {
    padding: 1.75rem 1rem;
  }

  .package-name {
    font-size: 1.4rem;
  }

  .package-code-tag {
    font-size: 1.3rem;
  }

  .cookie-banner {
    left: 0.75rem;
    right: 0.75rem;
    bottom: 0.75rem;
    max-width: calc(100vw - 1.5rem);
    padding: 1.15rem 1rem;
  }

  .cookie-actions {
    flex-direction: column;
    gap: 0.5rem;
  }

  .cookie-actions .btn {
    width: 100%;
    justify-content: center;
  }

  .intro-metrics-row {
    grid-template-columns: 1fr;
    gap: 1.15rem;
    text-align: left;
  }

  .intro-metric-item {
    text-align: left;
  }

  /* Accordéons FAQ sur mobile */
  .faq-trigger {
    padding: 1rem 0.9rem;
    font-size: 0.92rem;
  }

  .faq-item.is-active .faq-content {
    padding: 0 0.9rem 1.15rem;
  }

  .faq-answer {
    font-size: 0.88rem;
    line-height: 1.55;
  }

  /* Élimination totale de tout débordement de grille sur petits écrans */
  [style*="grid-template-columns: repeat(auto-fit"],
  [style*="grid-template-columns: repeat(auto-fill"] {
    grid-template-columns: 1fr !important;
    gap: 1.25rem !important;
  }
}

/* --------------------------------------------------------------------------
   4b. ULTRA-PETITS SMARTPHONES (<= 380px)
   -------------------------------------------------------------------------- */
@media (max-width: 380px) {
  .site-header .header-logo-img {
    height: 32px;
  }

  .header-actions {
    gap: 0.4rem;
  }

  .header-actions .btn {
    padding: 0.38rem 0.65rem;
    font-size: 0.72rem;
  }

  .hero-title {
    font-size: 1.65rem;
  }

  .btn-lg {
    padding: 0.75rem 1rem;
    font-size: 0.82rem;
  }
}

/* --------------------------------------------------------------------------
   5. ÉCRANS TACTILES & SÉCURITÉS ACCESSIBILITÉ
   -------------------------------------------------------------------------- */
@media (hover: none) and (pointer: coarse) {
  .custom-cursor, .custom-cursor-follower {
    display: none !important;
  }

  /* Améliore la réactivité tactile sans délai */
  a, button, input, select, textarea, .faq-trigger, .nav-link, .mega-item {
    touch-action: manipulation;
  }
}
