/**
 * CSS Responsive Global pour Mobile et Tablette
 * Appliqué à toutes les pages de l'ERP
 * Date: 2026-01-11
 */

/* ========================================
   CONFIGURATION DE BASE MOBILE
   ======================================== */

/* Empêcher le zoom sur focus des inputs (iOS) */
@media (max-width: 767px) {
  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="number"],
  input[type="tel"],
  input[type="date"],
  select,
  textarea {
    font-size: 16px !important;
  }
}

/* ========================================
   HEADER & NAVIGATION MOBILE
   ======================================== */

@media (max-width: 1024px) {
  /* Header mobile */
  .kt-header {
    padding: 0 10px;
    height: auto !important;
    min-height: 60px;
  }

  .kt-header__topbar {
    padding: 5px 0;
  }

  /* Menu hamburger plus grand pour tactile */
  .kt-header-mobile__toolbar-toggler,
  .kt-aside-close {
    min-width: 44px !important;
    min-height: 44px !important;
    padding: 10px !important;
  }

  /* Logo plus petit sur mobile */
  .kt-header__brand-logo img {
    max-height: 40px !important;
  }
}

/* ========================================
   SIDEBAR / ASIDE MOBILE
   ======================================== */

@media (max-width: 1024px) {
  /* Sidebar en overlay sur mobile */
  .kt-aside {
    position: fixed !important;
    z-index: 1000;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
  }

  .kt-aside--on {
    transform: translateX(0) !important;
  }

  /* Menu items plus grands pour tactile */
  .kt-menu__link {
    min-height: 48px !important;
    padding: 12px 20px !important;
    font-size: 15px !important;
  }

  .kt-menu__link-icon {
    font-size: 20px !important;
  }
}

/* ========================================
   CONTENU PRINCIPAL MOBILE
   ======================================== */

@media (max-width: 767px) {
  /* Wrapper principal */
  .kt-content {
    padding: 10px 10px 20px 10px !important;
  }

  .kt-container {
    padding: 0 !important;
  }

  /* Subheader mobile */
  .kt-subheader {
    padding: 10px 15px !important;
    min-height: auto !important;
  }

  .kt-subheader__main {
    flex-direction: column;
    align-items: flex-start !important;
  }

  .kt-subheader__title {
    font-size: 1.3rem !important;
    margin-bottom: 5px;
  }

  .kt-subheader__breadcrumbs {
    margin-top: 5px;
  }
}

/* ========================================
   PORTLETS / CARDS MOBILE
   ======================================== */

@media (max-width: 767px) {
  /* Portlets responsive */
  .kt-portlet {
    margin-bottom: 15px !important;
    border-radius: 8px;
  }

  .kt-portlet__head {
    padding: 15px !important;
    min-height: auto !important;
  }

  .kt-portlet__head-title {
    font-size: 1.1rem !important;
  }

  .kt-portlet__body {
    padding: 15px !important;
  }

  /* Cards widgets */
  .kt-widget {
    padding: 15px !important;
  }
}

/* ========================================
   TABLEAUX RESPONSIVE
   ======================================== */

@media (max-width: 767px) {
  /* Tables scrollables horizontalement */
  .table-responsive {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Optimisation des tables */
  table {
    font-size: 14px;
  }

  table th,
  table td {
    padding: 10px 8px !important;
    white-space: nowrap;
  }

  /* Cacher certaines colonnes sur mobile (optionnel) */
  .hide-mobile {
    display: none !important;
  }

  /* Pagination mobile */
  .pagination {
    flex-wrap: wrap;
    justify-content: center;
  }

  .page-link {
    min-width: 40px;
    min-height: 40px;
    padding: 8px 12px;
  }
}

/* ========================================
   FORMULAIRES MOBILE
   ======================================== */

@media (max-width: 767px) {
  /* Form groups */
  .form-group {
    margin-bottom: 15px;
  }

  /* Labels */
  label {
    font-size: 14px;
    margin-bottom: 8px;
  }

  /* Form controls */
  .form-control {
    height: 48px !important;
    font-size: 16px !important;
    padding: 12px 15px !important;
    border-radius: 6px;
  }

  textarea.form-control {
    height: auto !important;
    min-height: 100px;
  }

  /* Select2 mobile */
  .select2-container .select2-selection--single {
    height: 48px !important;
    padding: 10px 15px;
  }

  .select2-container--default .select2-selection--single .select2-selection__rendered {
    line-height: 48px !important;
  }

  .select2-container--default .select2-selection--single .select2-selection__arrow {
    height: 48px !important;
  }

  /* Checkboxes et radios plus grands */
  input[type="checkbox"],
  input[type="radio"] {
    width: 20px;
    height: 20px;
    margin-right: 8px;
  }

  /* Input groups */
  .input-group {
    flex-wrap: nowrap;
  }

  .input-group-append,
  .input-group-prepend {
    min-width: 44px;
  }
}

/* ========================================
   BOUTONS MOBILE
   ======================================== */

@media (max-width: 767px) {
  /* Boutons tactiles */
  .btn {
    min-height: 44px !important;
    padding: 12px 20px !important;
    font-size: 15px !important;
    border-radius: 6px;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
  }

  .btn-sm {
    min-height: 38px !important;
    padding: 8px 15px !important;
    font-size: 14px !important;
  }

  .btn-lg {
    min-height: 52px !important;
    padding: 15px 25px !important;
    font-size: 16px !important;
  }

  /* Boutons icon only */
  .btn-icon {
    min-width: 44px !important;
    min-height: 44px !important;
    padding: 10px !important;
  }

  /* Groupes de boutons en colonne sur mobile */
  .btn-group-mobile-vertical {
    flex-direction: column !important;
  }

  .btn-group-mobile-vertical .btn {
    width: 100%;
    margin-bottom: 10px;
  }

  /* Boutons d'action en bas sticky */
  .kt-portlet__foot {
    position: sticky;
    bottom: 0;
    background: white;
    padding: 15px !important;
    border-top: 1px solid #ebedf2;
    z-index: 10;
  }
}

/* ========================================
   MODALS MOBILE
   ======================================== */

@media (max-width: 767px) {
  /* Modal plein écran sur mobile */
  .modal-dialog {
    margin: 0 !important;
    max-width: 100% !important;
  }

  .modal-content {
    border-radius: 0;
    min-height: 100vh;
  }

  .modal-header {
    padding: 15px !important;
  }

  .modal-body {
    padding: 15px !important;
  }

  .modal-footer {
    padding: 15px !important;
    flex-direction: column-reverse;
  }

  .modal-footer .btn {
    width: 100%;
    margin: 5px 0;
  }

  /* Close button plus grand */
  .close {
    min-width: 44px;
    min-height: 44px;
    padding: 10px;
    font-size: 30px;
  }
}

/* ========================================
   DROPDOWNS MOBILE
   ======================================== */

@media (max-width: 767px) {
  .dropdown-menu {
    font-size: 15px;
  }

  .dropdown-item {
    padding: 12px 20px !important;
    min-height: 44px;
  }

  /* Dropdown pleine largeur sur mobile */
  .dropdown-menu-mobile-full {
    width: 100% !important;
    left: 0 !important;
    right: 0 !important;
  }
}

/* ========================================
   HOME PAGE - WIDGETS & STATS
   ======================================== */

@media (max-width: 767px) {
  /* Stats widgets en pile sur mobile */
  .row.kt-row--stats .col-xl-3,
  .row.kt-row--stats .col-lg-3,
  .row.kt-row--stats .col-md-6 {
    flex: 0 0 100%;
    max-width: 100%;
    margin-bottom: 15px;
  }

  /* Widget stats compact */
  .kt-widget24 {
    padding: 20px 15px !important;
  }

  .kt-widget24__title {
    font-size: 14px !important;
  }

  .kt-widget24__desc {
    font-size: 24px !important;
  }

  /* Charts responsive */
  canvas {
    max-width: 100% !important;
    height: auto !important;
  }
}

/* ========================================
   SETTINGS PAGE
   ======================================== */

@media (max-width: 767px) {
  /* Tabs verticaux deviennent horizontaux */
  .kt-nav-tabs--vertical {
    flex-direction: row !important;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .kt-nav-tabs--vertical .nav-item {
    white-space: nowrap;
  }

  .kt-nav-tabs--vertical .nav-link {
    padding: 12px 20px;
    min-height: 44px;
  }

  /* Upload area responsive */
  .dropzone {
    padding: 20px 10px !important;
  }

  /* Color picker responsive */
  .color-picker-container {
    width: 100%;
  }
}

/* ========================================
   UTILITAIRES RESPONSIVE
   ======================================== */

@media (max-width: 767px) {
  /* Masquer sur mobile */
  .d-mobile-none {
    display: none !important;
  }

  /* Afficher seulement sur mobile */
  .d-mobile-block {
    display: block !important;
  }

  /* Texte plus petit sur mobile */
  .text-mobile-sm {
    font-size: 14px !important;
  }

  /* Espacement réduit sur mobile */
  .p-mobile-sm {
    padding: 10px !important;
  }

  .m-mobile-sm {
    margin: 10px !important;
  }

  /* Full width sur mobile */
  .w-mobile-100 {
    width: 100% !important;
  }
}

/* ========================================
   TABLETTES (768px - 1024px)
   ======================================== */

@media (min-width: 768px) and (max-width: 1024px) {
  /* Content padding tablette */
  .kt-content {
    padding: 20px !important;
  }

  /* Portlets tablette */
  .kt-portlet__body {
    padding: 20px !important;
  }

  /* Colonnes tablette */
  .col-tablet-6 {
    flex: 0 0 50%;
    max-width: 50%;
  }

  .col-tablet-12 {
    flex: 0 0 100%;
    max-width: 100%;
  }

  /* Boutons tablette */
  .btn {
    min-height: 44px;
    touch-action: manipulation;
  }

  /* Tables tablette */
  table {
    font-size: 14px;
  }
}

/* ========================================
   FIXES SPÉCIFIQUES iOS
   ======================================== */

/* Empêcher le bounce scroll sur iOS */
body {
  overscroll-behavior-y: contain;
}

/* Fix pour les input sticky sur iOS */
@supports (-webkit-overflow-scrolling: touch) {
  input,
  textarea,
  select {
    -webkit-appearance: none;
    border-radius: 0;
  }
}

/* ========================================
   PRINT (impression)
   ======================================== */

@media print {
  /* Cacher les éléments non imprimables */
  .kt-header,
  .kt-aside,
  .kt-subheader,
  .btn,
  .kt-portlet__foot,
  .no-print {
    display: none !important;
  }

  .kt-content {
    padding: 0 !important;
  }

  .kt-portlet {
    box-shadow: none !important;
    border: 1px solid #ddd;
  }
}

/* ========================================
   ACCESSIBILITÉ
   ======================================== */

/* Zone de focus visible pour navigation clavier */
a:focus,
button:focus,
input:focus,
select:focus,
textarea:focus {
  outline: 2px solid #5867dd;
  outline-offset: 2px;
}

/* Taille minimale des zones tactiles (44x44px recommandé) */
@media (max-width: 1024px) {
  a,
  button,
  .btn,
  .dropdown-item,
  .nav-link {
    min-width: 44px;
    min-height: 44px;
  }
}
