/* ==========================================================================
   YOUTECH – Adaptation mobile & tablette du thème PRS050103 (PrestaShop 1.4)
   Chargé APRÈS les autres feuilles de style (voir header.tpl).
   Ordinateur (1024 px et plus) : aucun changement, sauf les noms de produits
   affichés en entier (3 lignes maximum) dans les listes.
   ========================================================================== */

/* Bouton menu : caché sur ordinateur */
#yt-menu-toggle { display: none; }

/* Noms de produits complets dans les listes (au lieu d'être coupés à 29 caractères) */
#in_grid li .product_name, #featured-products_block_center .product_name {
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}

/* ======================= Mobile + tablette (< 1024 px) ==================== */
@media (max-width: 1023px) {
  html { -webkit-text-size-adjust: 100%; }
  body { min-width: 0 !important; overflow-x: hidden; }
  img, iframe, video, object, embed { max-width: 100%; }
  img { height: auto; }

  /* ---------- Gabarit ---------- */
  #page { width: auto !important; max-width: 100%; }
  #columns { display: flex; flex-wrap: wrap; overflow: visible; padding: 0 10px; box-sizing: border-box; width: 100% !important; }
  #left_column, #center_column, #right_column, #index #center_column {
    float: none !important; box-sizing: border-box; min-width: 0 !important; max-width: 100%;
  }

  /* ---------- En-tête : tout repasse dans le flux normal ---------- */
  #header { height: auto !important; position: relative; display: flex; flex-wrap: wrap; align-items: center; padding: 8px 10px 0; box-sizing: border-box; }
  #header_logo { position: static !important; margin: 0 !important; flex: 1 1 100%; text-align: center; min-width: 0 !important; }
  #header_logo img.logo { width: auto !important; height: auto !important; max-width: 100%; }
  #header_right { flex: 1 1 100%; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; min-width: 0 !important; }
  #header_right > * { position: static !important; margin: 0 !important; }
  #header_links {
    display: flex !important; flex-wrap: wrap; justify-content: center; gap: 2px 0;
    width: 100% !important; white-space: normal !important; order: 1; padding: 4px 0; line-height: 2;
  }
  #header_right #search_block_top {
    order: 2; flex: 1 1 220px; width: auto !important; max-width: 100%; height: auto !important;
    background: #fff none !important; border: 1px solid #ccc; border-radius: 4px;
  }
  #header_right #search_block_top form, #header_right #search_block_top p { display: flex; margin: 0; padding: 0; width: 100% !important; box-sizing: border-box; }
  #header_right #search_block_top label { display: none !important; }
  #header_right #search_block_top input.search_query { flex: 1 1 auto; width: auto !important; font-size: 16px; padding: 10px; min-width: 0; }
  #header_right #search_block_top input.button { width: 44px !important; height: 40px !important; margin: 0 !important; background-position: center center; }
  #header_right .cart-bg { order: 3; flex: 1 1 100%; display: flex; justify-content: center; width: auto !important; height: auto !important; min-width: 0; }
  #header_user, #shopping_cart, #header_nav { width: auto !important; max-width: 100%; position: static !important; }
  /* Panier : gros bouton rouge bien visible, toute la zone est cliquable */
  #header_right .cart-bg { justify-content: stretch; }
  #shopping_cart {
    flex: 1 1 100%; position: relative !important; top: auto !important; left: auto !important; right: auto !important; bottom: auto !important; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px;
    min-height: 52px; margin: 0 !important; padding: 10px 16px 10px 56px; box-sizing: border-box;
    background: #a10000 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='9' cy='21' r='1'/%3E%3Ccircle cx='20' cy='21' r='1'/%3E%3Cpath d='M1 1h4l2.7 13.4a2 2 0 0 0 2 1.6h9.7a2 2 0 0 0 2-1.6L23 6H6'/%3E%3C/svg%3E") no-repeat 18px center;
    background-size: 28px 28px; border: 0; border-radius: 6px; color: #fff;
  }
  #shopping_cart, #shopping_cart a, #shopping_cart span { color: #fff !important; font-size: 18px !important; font-weight: bold; text-decoration: none; }
  #shopping_cart a::after { content: ""; position: absolute; top: 0; right: 0; bottom: 0; left: 0; }
  /* le bloc Panier des colonnes fait doublon avec le bouton du haut */
  #cart_block { display: none !important; }

  /* ---------- Menu : bouton « Menu » + liste déroulante ---------- */
  #yt-menu-toggle {
    display: flex; align-items: center; gap: 10px; order: 4;
    width: 100%; min-height: 48px; margin: 4px 0 0 !important; padding: 0 16px;
    border: 0; border-radius: 0; background: #353535; color: #fff;
    font: bold 16px 'Open Sans', Arial, sans-serif; cursor: pointer; text-align: left;
  }
  #yt-menu-toggle .yt-bars, #yt-menu-toggle .yt-bars::before, #yt-menu-toggle .yt-bars::after {
    display: block; width: 22px; height: 2px; background: #fff; position: relative; content: "";
  }
  #yt-menu-toggle .yt-bars::before { position: absolute; top: -7px; }
  #yt-menu-toggle .yt-bars::after { position: absolute; top: 7px; }
  .sf-contener { order: 5; position: static !important; width: 100% !important; height: auto !important; background: #404040 !important; display: none; }
  body.yt-menu-open .sf-contener { display: block; }
  ul#sf-menu { margin: 0; padding: 0; }
  ul#sf-menu li { float: none !important; width: auto !important; }
  ul#sf-menu > li { border-top: 1px solid #555; }
  ul#sf-menu li a { padding: 14px 16px !important; font-size: 15px !important; }
  /* sous-catégories de niveau 2 toujours visibles, en retrait */
  ul#sf-menu > li > ul { display: block !important; visibility: visible !important; position: static !important; background: #4a4a4a !important; padding: 0 0 6px; }
  ul#sf-menu > li > ul > li > a { padding: 10px 16px 10px 32px !important; font-size: 14px !important; font-weight: normal !important; text-shadow: none !important; }
  /* niveau 3 (marques) masqué : accessible depuis la page de la catégorie */
  ul#sf-menu ul ul { display: none !important; }

  /* ---------- Diaporama d'accueil ---------- */
  #TMskitter, .skitter { max-width: 100%; }

  /* ---------- Pied de page ---------- */
  #footer { width: auto !important; box-sizing: border-box; }
  #footer > * { max-width: 100%; }
  #footer .block_various_links li { display: inline-block; float: none !important; margin: 4px 8px; }

  /* ---------- Listes de produits ---------- */
  #center_column .products_block ul { display: flex; flex-wrap: wrap; gap: 10px; }
  #center_column .products_block li { float: none !important; margin: 0 !important; flex: 1 1 140px; min-height: 0 !important; }
  #in_list li, #in_list li .left_block, #in_list li .right_block { float: none !important; width: auto !important; }
  /* grille : les produits se répartissent sur toute la largeur */
  #grid-view[style*="block"] { display: flex !important; flex-wrap: wrap; gap: 10px; }
  #grid-view > ul#in_grid { display: contents !important; }
  ul#in_grid > li { margin: 0 !important; padding: 6px !important; box-sizing: border-box; clear: none !important; float: none !important; }

  /* ---------- Boutons : couleur unie (l'image d'origine, prévue pour une largeur fixe, laissait un coin coupé) ---------- */
  #columns a.exclusive, #columns span.exclusive, #columns input.exclusive, #columns a.button, #columns input.button,
  #columns .button_large, #columns .exclusive_large, #columns .button_mini {
    background: #a10000 none !important; color: #fff !important; border: 0 !important; border-radius: 4px !important;
    height: auto !important; min-height: 36px; line-height: 1.2 !important; padding: 9px 14px !important;
    display: inline-block; width: auto !important; text-shadow: none !important; box-sizing: border-box; cursor: pointer;
  }
  #columns span.exclusive { background: #bbb none !important; } /* bouton désactivé */

  /* ---------- Fiche produit ---------- */
  /* liens Imprimer / Agrandir : on les isole pour que le titre passe en dessous, sur toute la largeur */
  #usefull_link_block { float: none !important; width: auto !important; overflow: hidden; margin-bottom: 8px !important; }
  #primary_block h1, #pb-left-column h1 { clear: both; }
  #primary_block { width: auto !important; }
  #pb-left-column, #pb-right-column, #primary_block > div { float: none !important; width: auto !important; margin-left: 0 !important; box-sizing: border-box; }
  #image-block, #image-block img, #bigpic { max-width: 100%; height: auto !important; }
  #image-block { width: auto !important; height: auto !important; }
  #views_block { width: auto !important; }
  #more_info_block, #more_info_sheets, #more_info_sheets #idTab1, #customization_block { width: auto !important; }
  ul.idTabs { display: flex; flex-wrap: wrap; }
  ul.idTabs li { float: none !important; }
  #quantity_wanted { font-size: 16px; }
  /* produits associés : défilement horizontal au doigt */
  #productscategory, #productscategory_noscroll, #productscategory_list, #crossselling, #crossselling_list {
    max-width: 100%; height: auto !important; overflow-x: auto; overflow-y: hidden !important; -webkit-overflow-scrolling: touch;
  }

  /* ---------- Textes riches (descriptions) ---------- */
  .rte, .rte table, .cat_desc { max-width: 100%; }
  .rte table { display: block; overflow-x: auto; }

  /* ---------- Panier et commande ---------- */
  #order-detail-content { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  ul.step, #order_step { display: flex; flex-wrap: wrap; height: auto !important; width: auto !important; }
  ul.step li, #order_step li { float: none !important; flex: 1 1 auto; width: auto !important; }
  ul.step li#step_end { width: auto !important; }
  #carrierTable, table.std { max-width: 100%; }
  #carrier_area, #HOOK_PAYMENT { overflow-x: auto; }
  .cart_navigation { display: flex; flex-wrap: wrap; gap: 10px; justify-content: space-between; }
  .cart_navigation .button, .cart_navigation .exclusive, .cart_navigation input { float: none !important; }
  /* le bouton pour avancer (« Suivant ») toujours à droite, le retour à gauche */
  .cart_navigation > * { order: 1; }
  .cart_navigation .exclusive, .cart_navigation input.exclusive, .cart_navigation .standard-checkout { order: 2; margin-left: auto !important; }

  /* ---------- Formulaires (compte, adresses, contact) ---------- */
  form.std, form.std fieldset, #create-account_form, #login_form, #account-creation_form,
  #add_address, #opc_account_form, #new_account_form { width: auto !important; max-width: 100%; box-sizing: border-box; }
  #login_form, #create-account_form, #login_form fieldset, #create-account_form fieldset,
  #create-account_form .form_content, #login_form .form_content { height: auto !important; min-height: 0 !important; }
  form.std input[type="text"], form.std input[type="password"], form.std input[type="email"],
  form.std input[type="tel"], form.std select, form.std textarea,
  #login_form input.account_input, #create-account_form input.account_input {
    max-width: 100%; box-sizing: border-box; font-size: 16px; /* évite le zoom automatique de l'iPhone */
  }
  #login_form input.account_input, #create-account_form input.account_input { width: 100% !important; padding: 10px; }
  /* le champ est dans un <span> flottant qui le rétrécissait (adresse e-mail coupée) */
  form.std p.text > span, form.std p.password > span { float: none !important; display: block !important; width: auto !important; }
  form.std p.text, form.std p.password { height: auto !important; overflow: visible !important; margin-bottom: 12px !important; }
  form.std p.submit, #create-account_form .submit, #login_form .submit { clear: both; margin-top: 10px !important; }
}

/* ============================ Tablette (768–1023 px) ====================== */
@media (min-width: 768px) and (max-width: 1023px) {
  #columns { gap: 12px; }
  #left_column { width: 190px !important; flex: 0 0 190px; margin: 0 !important; }
  #center_column, #index #center_column { width: auto !important; flex: 1 1 0; margin: 0 0 10px !important; }
  #right_column { width: 100% !important; flex: 0 0 100%; margin: 0 !important; display: flex; flex-wrap: wrap; gap: 12px; }
  #right_column > * { flex: 1 1 220px; }
  #TMskitter { zoom: 0.85; } /* diaporama réduit pour tenir dans la colonne */
  ul#in_grid > li { flex: 1 1 calc(33.33% - 10px) !important; max-width: calc(33.33% - 7px); }
}

/* ============================ Téléphone (< 768 px) ======================== */
@media (max-width: 767px) {
  #columns { flex-direction: column; padding: 0 8px; }
  #center_column, #index #center_column { order: 1; width: auto !important; margin: 0 0 10px !important; padding: 10px !important; }
  #left_column { order: 2; width: auto !important; margin: 0 !important; }
  #right_column { order: 3; width: auto !important; margin: 0 !important; }
  /* blocs et bannières des colonnes : côte à côte, centrés */
  #left_column, #right_column { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
  #left_column > *, #right_column > * { flex: 1 1 100%; width: auto !important; margin: 0 !important; box-sizing: border-box; }
  /* blocs (Fabricants, Informations, Panier…) : fond uni pleine largeur */
  #left_column .block, #right_column .block, #left_column .block_content, #right_column .block_content { background: #fff none !important; }
  #left_column .block, #right_column .block { border: 1px solid #e8e8e8; }
  #left_column .block h4, #right_column .block h4 { background: #eeeeee none !important; }
  /* bannières des colonnes : 2 par ligne, centrées, sans puces */
  #left_column_banner ul, #right_column_banner ul {
    display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; list-style: none !important; margin: 0 !important; padding: 0 !important;
  }
  #left_column_banner ul li, #right_column_banner ul li {
    list-style: none !important; margin: 0 !important; flex: 0 1 calc(50% - 5px); max-width: 190px; text-align: center;
  }
  #left_column_banner img, #right_column_banner img { max-width: 100%; height: auto; }
  /* pendant la commande, on retire les colonnes pour ne pas distraire */
  body#order #left_column, body#order #right_column, body#order-opc #left_column, body#order-opc #right_column,
  body#authentication #left_column, body#authentication #right_column, body#address #left_column, body#address #right_column,
  body#order-confirmation #left_column, body#order-confirmation #right_column { display: none !important; }

  #TMskitter, .skitter { display: none !important; } /* diaporama : trop large et lourd sur téléphone */

  h1 { font-size: 20px !important; line-height: 1.25; }

  /* grille produits : 2 par ligne */
  ul#in_grid > li { flex: 1 1 calc(50% - 10px) !important; max-width: calc(50% - 5px); }
  ul#in_grid > li .product_name { font-size: 13px; line-height: 1.3; }
  ul#in_grid > li .exclusive { font-size: 12px; padding-left: 6px; padding-right: 6px; }

  /* panier : on masque photo, référence et disponibilité pour garder prix et total visibles */
  #cart_summary { min-width: 0 !important; width: 100% !important; font-size: 13px; }
  #cart_summary .cart_ref, #cart_summary .cart_availability, #cart_summary .cart_product { display: none !important; }
  #cart_summary td, #cart_summary th { padding: 6px 4px !important; white-space: normal !important; }
  #cart_summary td.price, #cart_summary .cart_unit, #cart_summary .cart_total { white-space: nowrap !important; }
  #cart_summary tfoot td { font-size: 12px; }
  /* totaux : sortis de la grille du tableau (les colspan="6" créaient 3 colonnes fantômes vides à droite) */
  #cart_summary tfoot { display: table-caption; caption-side: bottom; }
  #cart_summary tfoot tr { display: flex; align-items: center; justify-content: flex-end; border-top: 1px solid #e5e5e5; }
  #cart_summary tfoot td { display: block; border: 0 !important; }
  #cart_summary tfoot td:first-child { flex: 1 1 auto; text-align: right; }
  #cart_summary tfoot td.price { min-width: 80px; text-align: right; }

  /* Formulaires : libellé au-dessus du champ, champ pleine largeur */
  form.std p.text, form.std p.password, form.std p.select, form.std p.textarea,
  form.std p.required, form.std p.radio, form.std p.checkbox { padding-left: 0 !important; }
  form.std p label { float: none !important; display: block; width: auto !important; text-align: left !important; margin: 0 0 4px !important; }
  form.std input[type="text"], form.std input[type="password"], form.std input[type="email"],
  form.std input[type="tel"], form.std select, form.std textarea { width: 100% !important; }
  form.std p input, form.std p select, form.std p textarea { margin-left: 0 !important; margin-right: 0 !important; }
  form.std p span.form_info, form.std p .form_info, form.std p.inline-infos, form.std p.inline-infos * {
    padding-left: 0 !important; margin-left: 0 !important; display: block; text-align: left !important; width: auto !important;
  }
  form.std p.radio label { display: inline-block !important; margin: 0 14px 0 4px !important; }
  form.std p.radio > span:first-child { display: block; margin-bottom: 6px; }
  form.std p.radio input, form.std p.checkbox input { width: auto !important; }
  form.std p.select span, form.std p.select label { text-align: left !important; width: auto !important; padding: 0 !important; }
  #create-account_form, #login_form { float: none !important; margin: 0 0 16px 0 !important; }
  ul.address { float: none !important; width: auto !important; margin: 0 0 16px 0 !important; }
  #HOOK_PAYMENT p.payment_module, #HOOK_PAYMENT p.payment_module a { width: auto !important; float: none !important; }
}
