/* ============================================================
   QUALIXA — Module UI (Vuexy-inspired premium design)
   Sidebar interne + content area (alternative bs4TabCard)
   ============================================================ */

/* ============================================================
   LAYOUT INTERNAL TABS
   ============================================================ */

.qx-module {
  display: flex;
  gap: 1.25rem;
  min-height: calc(100vh - 220px);
}

.qx-sidebar {
  flex: 0 0 250px;
  background: #fff;
  border-radius: 0.625rem;
  box-shadow: 0 0.125rem 0.25rem rgba(47,43,61,0.06);
  padding: 0.875rem;
  height: fit-content;
  position: sticky;
  top: 90px;
}

.qx-sidebar-title {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #8a8d9b;
  font-weight: 700;
  padding: 0.5rem 0.75rem 0.5rem;
  margin: 0;
}

.qx-sidebar-divider {
  height: 1px;
  background: #e6e6e8;
  margin: 0.5rem 0;
}

.qx-sidebar-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.875rem;
  margin: 0.15rem 0;
  border-radius: 0.5rem;
  cursor: pointer;
  color: #6d6b77;
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.2s ease-in-out;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  text-decoration: none;
}

.qx-sidebar-item:hover {
  background: #FDF2F3;
  color: #C8102E;
  text-decoration: none;
}

.qx-sidebar-item.active {
  background: linear-gradient(135deg, #C8102E 0%, #E25B6A 100%);
  color: #fff !important;
  box-shadow: 0 2px 6px rgba(200, 16, 46, 0.4);
}

.qx-sidebar-item .qx-icon {
  font-size: 1rem;
  width: 18px;
  text-align: center;
}

.qx-sidebar-item .qx-badge {
  margin-left: auto;
  background: rgba(255,255,255,0.25);
  color: #fff;
  font-size: 0.65rem;
  padding: 0.1rem 0.4rem;
  border-radius: 50rem;
  font-weight: 700;
}

.qx-sidebar-item:not(.active) .qx-badge {
  background: #FDF2F3;
  color: #C8102E;
}

.qx-content {
  flex: 1;
  background: #fff;
  border-radius: 0.625rem;
  box-shadow: 0 0.125rem 0.25rem rgba(47,43,61,0.06);
  padding: 1.75rem;
  min-height: 600px;
}

.qx-content-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid #e6e6e8;
}

.qx-content-header h4 {
  color: #444050;
  font-weight: 600;
  margin: 0;
  font-size: 1.25rem;
}

.qx-content-header .qx-subtitle {
  color: #8a8d9b;
  font-size: 0.875rem;
  margin-top: 0.25rem;
}

/* ============================================================
   KPI CARDS MODERNES
   ============================================================ */

.qx-kpi-card {
  background: #fff;
  border-radius: 0.625rem;
  padding: 1.25rem;
  box-shadow: 0 0.125rem 0.25rem rgba(47,43,61,0.06);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  border: 1px solid #e6e6e8;
  position: relative;
  overflow: hidden;
}

.qx-kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 0.25rem 1.125rem rgba(47,43,61,0.14);
}

.qx-kpi-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: linear-gradient(90deg, #C8102E, #E25B6A);
}

.qx-kpi-icon {
  width: 48px;
  height: 48px;
  border-radius: 0.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  background: #FDF2F3;
  color: #C8102E;
  margin-bottom: 0.75rem;
}

.qx-kpi-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: #444050;
  line-height: 1.1;
  margin: 0;
}

.qx-kpi-label {
  font-size: 0.8125rem;
  color: #8a8d9b;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 0.25rem;
}

/* Variantes couleurs */
.qx-kpi-success::before { background: linear-gradient(90deg, #28c76f, #5bc97a); }
.qx-kpi-success .qx-kpi-icon { background: #ddf6e8; color: #28c76f; }
.qx-kpi-info::before { background: linear-gradient(90deg, #00bad1, #4dcde0); }
.qx-kpi-info .qx-kpi-icon { background: #d6f4f8; color: #00bad1; }
.qx-kpi-warning::before { background: linear-gradient(90deg, #ff9f43, #ffb46e); }
.qx-kpi-warning .qx-kpi-icon { background: #fff0e1; color: #ff9f43; }

/* ============================================================
   FORM PANEL
   ============================================================ */

.qx-form-panel {
  background: linear-gradient(135deg, #fafafd 0%, #fff 100%);
  border-radius: 0.5rem;
  padding: 1.25rem;
  border: 1px solid #e6e6e8;
  margin-bottom: 1rem;
}

.qx-form-panel h6 {
  color: #C8102E;
  font-weight: 600;
  margin-bottom: 0.75rem;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.qx-form-help {
  color: #8a8d9b;
  font-size: 0.8125rem;
  margin-bottom: 1rem;
}

/* ============================================================
   BUTTONS
   ============================================================ */

.qx-btn-primary {
  background: linear-gradient(135deg, #C8102E, #9E0C24);
  border: none;
  color: #fff;
  font-weight: 600;
  padding: 0.625rem 1rem;
  border-radius: 0.5rem;
  box-shadow: 0 2px 4px rgba(200, 16, 46, 0.25);
  transition: all 0.2s ease;
  width: 100%;
  cursor: pointer;
}

.qx-btn-primary:hover, .qx-btn-primary:focus {
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(200, 16, 46, 0.35);
  color: #fff;
  background: linear-gradient(135deg, #9E0C24, #C8102E);
}

/* ============================================================
   RESULT CARDS
   ============================================================ */

.qx-result-card {
  background: #fff;
  border-radius: 0.5rem;
  padding: 1.25rem;
  box-shadow: 0 0.125rem 0.25rem rgba(47,43,61,0.06);
  border-left: 4px solid #C8102E;
  margin: 1rem 0;
}

.qx-result-success { border-left-color: #28c76f; background: linear-gradient(90deg, #ddf6e8 0%, #fff 35%); }
.qx-result-warning { border-left-color: #ff9f43; background: linear-gradient(90deg, #fff0e1 0%, #fff 35%); }
.qx-result-info    { border-left-color: #00bad1; background: linear-gradient(90deg, #d6f4f8 0%, #fff 35%); }

/* ============================================================
   EMPTY STATE
   ============================================================ */

.qx-empty {
  text-align: center;
  padding: 3rem 1.5rem;
  color: #8a8d9b;
}

.qx-empty .qx-empty-icon {
  font-size: 3.5rem;
  color: #C8102E;
  opacity: 0.4;
  margin-bottom: 1rem;
}

.qx-empty h5 {
  color: #444050;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.qx-empty p {
  color: #8a8d9b;
  margin-bottom: 0;
}

/* ============================================================
   ANIMATIONS
   ============================================================ */

.qx-fade-in {
  animation: qxFadeIn 0.3s ease-out;
}

@keyframes qxFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 992px) {
  .qx-module { flex-direction: column; }
  .qx-sidebar {
    position: relative;
    top: 0;
    flex: 1;
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
  }
  .qx-sidebar-item {
    flex: 1 1 auto;
    min-width: 140px;
  }
  .qx-sidebar-title, .qx-sidebar-divider { display: none; }
}

/* ============================================================
   FIX bs4Dash side-effects (forcer fluidite)
   ============================================================ */

.card.card-tabs > .card-header > ul.nav-tabs {
  border-bottom: none;
}

/* ============================================================
   STYLE NAVLISTPANEL VUEXY (le module utilise navlistPanel natif)
   ============================================================ */

/* Container */
.row.shiny-tab-panel,
.tabbable {
  background: transparent;
}

/* Sidebar = ul.nav-pills.nav-stacked */
ul.nav-pills.nav-stacked {
  background: #fff;
  border-radius: 0.625rem;
  box-shadow: 0 0.125rem 0.25rem rgba(47,43,61,0.06);
  padding: 0.875rem !important;
  list-style: none;
  margin: 0;
}

/* Headers de section (li sans <a>) */
ul.nav-pills.nav-stacked > li:not(:has(> a)),
ul.nav-pills.nav-stacked > li.nav-header,
.well + .nav-pills .nav-header {
  font-size: 0.7rem !important;
  text-transform: uppercase !important;
  letter-spacing: 0.1em !important;
  color: #8a8d9b !important;
  font-weight: 700 !important;
  padding: 0.85rem 0.75rem 0.25rem !important;
  background: transparent !important;
  border: none !important;
}

/* Items navigables */
ul.nav-pills.nav-stacked > li > a {
  display: flex !important;
  align-items: center !important;
  gap: 0.6rem !important;
  padding: 0.65rem 0.875rem !important;
  margin: 0.15rem 0 !important;
  border-radius: 0.5rem !important;
  color: #6d6b77 !important;
  font-size: 0.875rem !important;
  font-weight: 500 !important;
  background: transparent !important;
  border: none !important;
  text-decoration: none !important;
  transition: all 0.2s ease-in-out !important;
}

ul.nav-pills.nav-stacked > li > a:hover {
  background: #FDF2F3 !important;
  color: #C8102E !important;
}

ul.nav-pills.nav-stacked > li.active > a,
ul.nav-pills.nav-stacked > li > a.active {
  background: linear-gradient(135deg, #C8102E 0%, #E25B6A 100%) !important;
  color: #fff !important;
  box-shadow: 0 2px 6px rgba(200, 16, 46, 0.4) !important;
}

/* Icones dans les liens */
ul.nav-pills.nav-stacked > li > a > i.fas,
ul.nav-pills.nav-stacked > li > a > svg {
  width: 18px;
  text-align: center;
  font-size: 0.95rem;
}

/* Content area (col-sm-9 dans navlistPanel) */
.tabbable .tab-content {
  background: #fff;
  border-radius: 0.625rem;
  box-shadow: 0 0.125rem 0.25rem rgba(47,43,61,0.06);
  padding: 1.5rem;
  min-height: 600px;
}

/* Cache l'header du navlistPanel par defaut (nav-tabs above content) */
.tabbable > .tab-content > .tab-pane {
  animation: qxFadeIn 0.25s ease-out;
}

/* ============================================================
   FIX DataTables in hidden tabs : force width + scroll safely
   ============================================================ */

.dataTables_wrapper {
  width: 100% !important;
  overflow-x: auto;
}

table.dataTable {
  width: 100% !important;
}

/* Quand un tab-pane est cache, neutraliser DT pour eviter le crash adjustWidth */
.tab-pane:not(.active) .dataTables_scrollHead,
.tab-pane:not(.active) .dataTables_scrollBody {
  display: none;
}
