/* Custom Stylesheet - ERP Bibliothèque & Services */
:root {
  --primary-color: #2563eb;
  --primary-hover: #1d4ed8;
  --sidebar-bg: #1e293b;
  --sidebar-hover: #334155;
  --sidebar-active: #2563eb;
  --topbar-height: 60px;
  --sidebar-width: 260px;
  --bg-light: #f8fafc;
  --card-border: #e2e8f0;
}

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background-color: var(--bg-light);
  color: #1e293b;
  min-height: 100vh;
}

/* Layout Wrapper */
.app-wrapper {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.app-sidebar {
  width: var(--sidebar-width);
  background-color: var(--sidebar-bg);
  color: #f1f5f9;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 1040;
  display: flex;
  flex-direction: column;
  transition: transform 0.3s ease;
  overflow-y: auto;
}

.sidebar-header {
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  padding: 0 1.25rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: 0.5px;
}

.sidebar-menu {
  list-style: none;
  padding: 0.75rem 0.5rem;
  margin: 0;
  flex: 1;
}

.sidebar-menu .menu-header {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #94a3b8;
  padding: 0.75rem 0.75rem 0.25rem;
  font-weight: 600;
}

.sidebar-menu .nav-link {
  display: flex;
  align-items: center;
  padding: 0.65rem 0.85rem;
  color: #cbd5e1;
  border-radius: 0.5rem;
  margin-bottom: 0.2rem;
  font-weight: 500;
  font-size: 0.92rem;
  transition: all 0.2s ease;
  text-decoration: none;
}

.sidebar-menu .nav-link i {
  width: 1.5rem;
  font-size: 1rem;
  margin-right: 0.5rem;
  text-align: center;
}

.sidebar-menu .nav-link:hover {
  background-color: var(--sidebar-hover);
  color: #ffffff;
}

.sidebar-menu .nav-link.active {
  background-color: var(--sidebar-active);
  color: #ffffff;
  font-weight: 600;
  box-shadow: 0 4px 6px -1px rgba(37, 99, 235, 0.3);
}

.sidebar-menu .nav-link .badge {
  margin-left: auto;
  font-size: 0.72rem;
}

/* Main Content */
.app-main {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  transition: margin-left 0.3s ease;
}

/* Navbar */
.app-navbar {
  height: var(--topbar-height);
  background-color: #ffffff;
  border-bottom: 1px solid var(--card-border);
  position: sticky;
  top: 0;
  z-index: 1030;
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  justify-content: space-between;
}

/* Page Body */
.app-content {
  padding: 1.5rem;
  flex: 1;
}

/* Cards */
.card {
  border: 1px solid var(--card-border);
  border-radius: 0.75rem;
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.05);
  background-color: #ffffff;
  margin-bottom: 1.5rem;
}

.card-header {
  background-color: #ffffff;
  border-bottom: 1px solid var(--card-border);
  padding: 1rem 1.25rem;
  font-weight: 600;
  border-top-left-radius: 0.75rem !important;
  border-top-right-radius: 0.75rem !important;
}

/* Stat Cards */
.stat-card {
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  border-left: 4px solid var(--primary-color);
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.08);
}

.stat-card.stat-success { border-left-color: #10b981; }
.stat-card.stat-danger { border-left-color: #ef4444; }
.stat-card.stat-warning { border-left-color: #f59e0b; }
.stat-card.stat-info { border-left-color: #06b6d4; }
.stat-card.stat-purple { border-left-color: #8b5cf6; }

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
}

/* Table styling */
.table th {
  font-weight: 600;
  color: #475569;
  background-color: #f8fafc;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom-width: 1px;
}

.table td {
  vertical-align: middle;
  font-size: 0.92rem;
}

/* Badges */
.badge {
  padding: 0.4em 0.65em;
  font-weight: 500;
  border-radius: 6px;
}

/* Toast Container */
.toast-container {
  z-index: 1090;
}

/* Mobile Responsiveness */
@media (max-width: 991.98px) {
  .app-sidebar {
    transform: translateX(-100%);
  }
  .app-sidebar.show {
    transform: translateX(0);
  }
  .app-main {
    margin-left: 0;
  }
}

/* Autocomplétion & Recherche Mots-Clés (Devis, Factures, BL) */
.table-responsive-visible,
.table-responsive:has(.search-container),
.table-responsive:has(.search-dropdown-menu) {
  overflow: visible !important;
}

.document-line.search-active {
  position: relative;
  z-index: 1060;
}

.search-container {
  position: relative;
}

.search-dropdown-menu {
  position: absolute !important;
  top: 100% !important;
  left: 0 !important;
  z-index: 2050 !important;
  min-width: 100%;
  width: max-content;
  max-width: 580px;
  background-color: #ffffff !important;
  border: 1px solid #cbd5e1 !important;
  border-radius: 0.5rem !important;
  box-shadow: 0 15px 35px -5px rgba(0, 0, 0, 0.25), 0 5px 15px rgba(0, 0, 0, 0.08) !important;
  max-height: 280px;
  overflow-y: auto;
  margin-top: 3px;
}

.search-item {
  transition: background-color 0.15s ease;
  border-left: 3px solid transparent !important;
}

.search-item:hover,
.search-item:focus {
  background-color: #eff6ff !important;
  border-left-color: var(--primary-color) !important;
}

/* --- TomSelect Améliorations Ergonomiques & Thème --- */
.ts-wrapper.form-select {
  padding: 0 !important;
  border: none !important;
  box-shadow: none !important;
}

.ts-control {
  border-radius: 0.375rem !important;
  min-height: 38px;
  padding: 0.375rem 0.75rem !important;
  font-size: 0.92rem !important;
  border-color: #dee2e6 !important;
  background-color: #ffffff !important;
}

.ts-wrapper.focus .ts-control {
  border-color: #86b7fe !important;
  box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.2) !important;
}

.ts-dropdown {
  border-radius: 0.5rem !important;
  border: 1px solid #cbd5e1 !important;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.15) !important;
  z-index: 1060 !important;
  font-size: 0.92rem !important;
}

.ts-dropdown .option {
  padding: 8px 12px !important;
  border-bottom: 1px solid #f1f5f9;
}

.ts-dropdown .option:last-child {
  border-bottom: none;
}

.ts-dropdown .active {
  background-color: #0d6efd !important;
  color: #ffffff !important;
}

.ts-dropdown .no-results {
  color: #64748b;
  font-size: 0.85rem;
}

