/**
 * ═══════════════════════════════════════════════════════════════
 * RESPONSIVITÉ CONTENU UNIQUEMENT - CGM IMMO ERP
 * ═══════════════════════════════════════════════════════════════
 * Version: 1.0
 * Date: 31 juillet 2026
 * 
 * ⚠️ RÈGLE ABSOLUE: NE JAMAIS TOUCHER À LA SIDEBAR
 * 
 * Ce fichier rend responsive UNIQUEMENT:
 * - Le contenu (right_col)
 * - Les cards/panels
 * - Les tables
 * - Les forms
 * - Les graphiques
 * - Les boutons
 * - Les modals
 * - Etc.
 * 
 * ❌ NE TOUCHE PAS:
 * - .left_col (sidebar)
 * - .top_nav
 * - .side-menu
 * - Navigation Gentelella
 */

/* ═══════════════════════════════════════════════════════════════
   VARIABLES
   ═══════════════════════════════════════════════════════════════ */

:root {
  --mobile: 767px;
  --tablet: 991px;
  --desktop: 1200px;
}

/* ═══════════════════════════════════════════════════════════════
   GLOBAL - CONTENU UNIQUEMENT
   ═══════════════════════════════════════════════════════════════ */

* {
  box-sizing: border-box;
}

img {
  max-width: 100%;
  height: auto;
}

/* ═══════════════════════════════════════════════════════════════
   CONTENT AREA (RIGHT_COL) - MOBILE
   ═══════════════════════════════════════════════════════════════ */

@media (max-width: 767px) {
  /* Padding réduit pour mobile */
  .right_col {
    padding: 10px 15px !important;
  }

  /* Éviter débordement horizontal */
  .right_col > * {
    max-width: 100%;
  }

  /* Page title plus compact */
  .page-title .title_left h3 {
    font-size: 18px !important;
    margin: 10px 0 !important;
  }

  .page-title {
    margin-bottom: 15px !important;
  }
}

/* ═══════════════════════════════════════════════════════════════
   GRIDS BOOTSTRAP - MOBILE
   ═══════════════════════════════════════════════════════════════ */

@media (max-width: 767px) {
  /* Forcer toutes colonnes à 100% sur mobile */
  .row > .col-xs-1, .row > .col-xs-2, .row > .col-xs-3, .row > .col-xs-4,
  .row > .col-xs-5, .row > .col-xs-6, .row > .col-xs-7, .row > .col-xs-8,
  .row > .col-xs-9, .row > .col-xs-10, .row > .col-xs-11, .row > .col-xs-12,
  .row > .col-sm-1, .row > .col-sm-2, .row > .col-sm-3, .row > .col-sm-4,
  .row > .col-sm-5, .row > .col-sm-6, .row > .col-sm-7, .row > .col-sm-8,
  .row > .col-sm-9, .row > .col-sm-10, .row > .col-sm-11, .row > .col-sm-12,
  .row > .col-md-1, .row > .col-md-2, .row > .col-md-3, .row > .col-md-4,
  .row > .col-md-5, .row > .col-md-6, .row > .col-md-7, .row > .col-md-8,
  .row > .col-md-9, .row > .col-md-10, .row > .col-md-11, .row > .col-md-12 {
    width: 100% !important;
    float: none !important;
    padding-left: 10px !important;
    padding-right: 10px !important;
  }

  /* Espacement vertical entre colonnes */
  .row > [class*="col-"] {
    margin-bottom: 15px;
  }

  .row > [class*="col-"]:last-child {
    margin-bottom: 0;
  }
}

/* ═══════════════════════════════════════════════════════════════
   CARDS & PANELS - MOBILE
   ═══════════════════════════════════════════════════════════════ */

@media (max-width: 767px) {
  .x_panel {
    margin-bottom: 15px !important;
  }

  .x_title {
    padding: 10px 15px !important;
  }

  .x_title h2 {
    font-size: 16px !important;
    margin: 5px 0 !important;
  }

  .x_content {
    padding: 15px !important;
  }

  /* Boutons dans x_title en colonne */
  .x_title .btn-group,
  .x_title .pull-right {
    display: block !important;
    float: none !important;
    width: 100% !important;
    margin-top: 10px;
  }

  .x_title .btn {
    width: 100% !important;
    margin-bottom: 5px !important;
  }
}

/* ═══════════════════════════════════════════════════════════════
   DASHBOARD KPI CARDS - MOBILE
   ═══════════════════════════════════════════════════════════════ */

@media (max-width: 767px) {
  /* Cards KPI avec background coloré */
  .x_panel[style*="background"] {
    min-height: auto !important;
    margin-bottom: 15px !important;
  }

  .x_panel[style*="background"] .x_content {
    padding: 20px 15px !important;
  }

  .x_panel[style*="background"] h2 {
    font-size: 32px !important;
  }

  .x_panel[style*="background"] p {
    font-size: 14px !important;
  }

  /* Badges inline dans KPI */
  .x_panel span[style*="background"] {
    padding: 4px 8px !important;
    font-size: 11px !important;
    display: inline-block !important;
    margin: 3px 2px !important;
  }

  /* Icônes dans KPI */
  .x_panel i[style*="position:absolute"] {
    font-size: 35px !important;
  }
}

/* ═══════════════════════════════════════════════════════════════
   TABLES - MOBILE
   ═══════════════════════════════════════════════════════════════ */

@media (max-width: 767px) {
  /* Wrapper responsive */
  .table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border: 1px solid #ddd;
    border-radius: 4px;
  }

  /* Table en mode scroll */
  .table {
    min-width: 600px;
    font-size: 12px !important;
  }

  .table th,
  .table td {
    padding: 8px 6px !important;
    white-space: nowrap;
  }

  /* Boutons d'actions en colonne */
  .table .btn-group {
    display: flex;
    flex-direction: column;
  }

  .table .btn-group .btn {
    margin-bottom: 3px;
    width: 100%;
  }

  .table .btn {
    font-size: 11px !important;
    padding: 5px 8px !important;
  }
}

/* ═══════════════════════════════════════════════════════════════
   FORMS - MOBILE
   ═══════════════════════════════════════════════════════════════ */

@media (max-width: 767px) {
  /* Forms horizontal → vertical sur mobile */
  .form-horizontal .form-group {
    margin-left: 0 !important;
    margin-right: 0 !important;
  }

  .form-horizontal .control-label {
    text-align: left !important;
    padding-bottom: 5px;
    width: 100% !important;
    float: none !important;
  }

  .form-horizontal .col-sm-2,
  .form-horizontal .col-sm-3,
  .form-horizontal .col-sm-4,
  .form-horizontal .col-sm-5,
  .form-horizontal .col-sm-6,
  .form-horizontal .col-sm-7,
  .form-horizontal .col-sm-8,
  .form-horizontal .col-sm-9,
  .form-horizontal .col-sm-10 {
    width: 100% !important;
    float: none !important;
  }

  /* Input groups en bloc */
  .input-group {
    display: flex !important;
    width: 100% !important;
  }

  .input-group .form-control {
    flex: 1;
  }

  .input-group-addon {
    min-width: 45px;
  }

  /* Tous les boutons de formulaire en pleine largeur */
  .form-group .btn,
  .form-actions .btn {
    width: 100% !important;
    margin-bottom: 10px !important;
  }

  /* Input fields */
  .form-control {
    font-size: 16px !important; /* Évite le zoom sur iOS */
  }

  /* Select */
  select.form-control {
    font-size: 16px !important;
  }
}

/* ═══════════════════════════════════════════════════════════════
   BUTTONS - MOBILE
   ═══════════════════════════════════════════════════════════════ */

@media (max-width: 767px) {
  /* Boutons tactiles (minimum 44px) */
  .btn {
    min-height: 44px !important;
    padding: 10px 15px !important;
    font-size: 14px !important;
  }

  .btn-sm {
    min-height: 36px !important;
    padding: 8px 12px !important;
    font-size: 12px !important;
  }

  .btn-xs {
    min-height: 30px !important;
    padding: 5px 10px !important;
    font-size: 11px !important;
  }

  /* Groupes de boutons en colonne */
  .btn-toolbar {
    display: flex;
    flex-direction: column;
  }

  .btn-toolbar .btn-group {
    width: 100%;
    margin-bottom: 5px;
  }

  .btn-toolbar .btn {
    width: 100%;
  }

  /* Boutons côte à côte dans actions */
  .pull-right,
  .text-right {
    float: none !important;
    text-align: center !important;
  }
}

/* ═══════════════════════════════════════════════════════════════
   CHARTS - MOBILE
   ═══════════════════════════════════════════════════════════════ */

@media (max-width: 767px) {
  /* Canvas responsive */
  canvas {
    max-width: 100% !important;
    height: auto !important;
  }

  /* Container de graphique */
  .x_panel canvas {
    min-height: 200px !important;
    max-height: 300px !important;
  }

  /* Légendes */
  .chart-legend {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    font-size: 11px !important;
  }

  .chart-legend li {
    margin: 5px 8px;
  }
}

/* ═══════════════════════════════════════════════════════════════
   MODALS - MOBILE
   ═══════════════════════════════════════════════════════════════ */

@media (max-width: 767px) {
  .modal-dialog {
    width: 95% !important;
    margin: 10px auto !important;
  }

  .modal-header {
    padding: 15px !important;
  }

  .modal-title {
    font-size: 18px !important;
  }

  .modal-body {
    padding: 15px !important;
  }

  .modal-footer {
    padding: 10px 15px !important;
  }

  .modal-footer .btn {
    width: 100% !important;
    margin-bottom: 5px !important;
  }
}

/* ═══════════════════════════════════════════════════════════════
   PAGINATION - MOBILE
   ═══════════════════════════════════════════════════════════════ */

@media (max-width: 767px) {
  .pagination {
    font-size: 12px !important;
  }

  .pagination > li > a,
  .pagination > li > span {
    padding: 6px 10px !important;
  }

  /* Masquer numéros intermédiaires */
  .pagination > li:not(.active):not(.disabled):not(:first-child):not(:last-child):not(:nth-child(2)):not(:nth-last-child(2)) {
    display: none;
  }

  .pagination > li.active {
    display: inline-block !important;
  }
}

/* ═══════════════════════════════════════════════════════════════
   ALERTS - MOBILE
   ═══════════════════════════════════════════════════════════════ */

@media (max-width: 767px) {
  .alert {
    padding: 12px 15px !important;
    font-size: 13px !important;
  }

  .alert .close {
    font-size: 20px !important;
    padding: 0 !important;
  }
}

/* ═══════════════════════════════════════════════════════════════
   BREADCRUMB - MOBILE
   ═══════════════════════════════════════════════════════════════ */

@media (max-width: 767px) {
  .breadcrumb {
    overflow-x: auto;
    white-space: nowrap;
    flex-wrap: nowrap;
    font-size: 12px !important;
    padding: 8px 12px !important;
  }

  .breadcrumb > li {
    display: inline-block;
  }
}

/* ═══════════════════════════════════════════════════════════════
   TABS - MOBILE
   ═══════════════════════════════════════════════════════════════ */

@media (max-width: 767px) {
  .nav-tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap;
    white-space: nowrap;
  }

  .nav-tabs > li {
    float: none;
    display: inline-block;
  }

  .nav-tabs > li > a {
    font-size: 13px !important;
    padding: 10px 15px !important;
  }
}

/* ═══════════════════════════════════════════════════════════════
   BADGES & LABELS - MOBILE
   ═══════════════════════════════════════════════════════════════ */

@media (max-width: 767px) {
  .label {
    font-size: 11px !important;
    padding: 4px 8px !important;
  }

  .badge {
    font-size: 10px !important;
    padding: 3px 6px !important;
  }
}

/* ═══════════════════════════════════════════════════════════════
   STATS COUNTERS - MOBILE
   ═══════════════════════════════════════════════════════════════ */

@media (max-width: 767px) {
  .tile_stats_count {
    margin-bottom: 15px !important;
    border-right: none !important;
    border-bottom: 1px solid #ddd !important;
    padding-bottom: 15px;
  }

  .tile_stats_count:last-child {
    border-bottom: none !important;
  }

  .tile_stats_count .count {
    font-size: 32px !important;
  }

  .tile_stats_count span {
    font-size: 13px !important;
  }
}

/* ═══════════════════════════════════════════════════════════════
   DATATABLES - MOBILE
   ═══════════════════════════════════════════════════════════════ */

@media (max-width: 767px) {
  .dataTables_wrapper {
    overflow-x: auto;
  }

  .dataTables_wrapper .dataTables_length,
  .dataTables_wrapper .dataTables_filter {
    width: 100% !important;
    margin-bottom: 10px;
  }

  .dataTables_wrapper .dataTables_length label,
  .dataTables_wrapper .dataTables_filter label {
    width: 100%;
  }

  .dataTables_wrapper .dataTables_length select,
  .dataTables_wrapper .dataTables_filter input {
    width: 100% !important;
    margin-left: 0 !important;
  }

  .dataTables_wrapper .dataTables_info,
  .dataTables_wrapper .dataTables_paginate {
    float: none !important;
    text-align: center !important;
    margin-top: 10px;
  }
}

/* ═══════════════════════════════════════════════════════════════
   LOGIN PAGE - MOBILE
   ═══════════════════════════════════════════════════════════════ */

@media (max-width: 767px) {
  body.login {
    padding: 20px 10px;
  }

  .login_wrapper {
    width: 100% !important;
    padding: 0 !important;
  }

  .login_form {
    padding: 20px !important;
  }

  .login_content {
    padding: 0 15px !important;
    width: 100% !important;
  }

  .login_content h1 {
    font-size: 24px !important;
    margin-bottom: 15px;
  }

  .login_content form input {
    margin-bottom: 15px;
    height: 44px !important;
    font-size: 16px !important;
  }

  .login_content form .btn {
    width: 100% !important;
    height: 44px !important;
    margin-bottom: 15px;
  }

  .login_content .reset_pass {
    display: block;
    text-align: center;
    margin-top: 10px;
  }
}

/* ═══════════════════════════════════════════════════════════════
   FOOTER - MOBILE
   ═══════════════════════════════════════════════════════════════ */

@media (max-width: 767px) {
  footer {
    padding: 15px 10px !important;
    text-align: center !important;
  }

  footer .pull-right {
    float: none !important;
    display: block;
    margin-bottom: 5px;
  }
}

/* ═══════════════════════════════════════════════════════════════
   PRINT - TOUS APPAREILS
   ═══════════════════════════════════════════════════════════════ */

@media print {
  .x_panel {
    border: 1px solid #ddd;
    page-break-inside: avoid;
  }

  .table {
    font-size: 10px;
    page-break-inside: avoid;
  }

  .btn {
    display: none !important;
  }
}

/* ═══════════════════════════════════════════════════════════════
   UTILITIES - MOBILE
   ═══════════════════════════════════════════════════════════════ */

@media (max-width: 767px) {
  .hidden-mobile {
    display: none !important;
  }

  .visible-mobile {
    display: block !important;
  }

  .text-center-mobile {
    text-align: center !important;
  }
}

@media (min-width: 768px) {
  .hidden-desktop {
    display: none !important;
  }
}

/* ═══════════════════════════════════════════════════════════════
   FIN - SIDEBAR ET NAVIGATION NON TOUCHÉES
   ═══════════════════════════════════════════════════════════════ */
