/* ============================================================
   THIALIE PHARMA MANAGER - Styles principaux
   ============================================================ */

:root {
  --primary:       #1a5276;
  --primary-dark:  #154360;
  --primary-light: #2e86c1;
  --accent:        #148f77;
  --accent-light:  #1abc9c;
  --sidebar-bg:    #0d1b2a;
  --sidebar-text:  #b0c4de;
  --sidebar-hover: #1a5276;
  --sidebar-active:#2e86c1;
  --topbar-bg:     #ffffff;
  --body-bg:       #f0f4f8;
  --card-bg:       #ffffff;
  --text-dark:     #1a202c;
  --text-muted:    #718096;
  --border:        #e2e8f0;
  --danger:        #e74c3c;
  --warning:       #f39c12;
  --success:       #27ae60;
  --info:          #2980b9;
  --sidebar-width: 260px;
  --topbar-height: 64px;
  --transition:    0.2s ease;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
  background: var(--body-bg);
  color: var(--text-dark);
  font-size: 14px;
  line-height: 1.6;
}

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

/* ---- SIDEBAR ---- */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  transition: transform var(--transition);
}

.sidebar-brand {
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
}

.sidebar-brand .brand-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.sidebar-brand .brand-icon {
  width: 40px; height: 40px;
  background: var(--primary-light);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 16px;
  flex-shrink: 0;
}

.sidebar-brand .brand-name {
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: 0.3px;
}

.sidebar-brand .brand-sub {
  color: var(--sidebar-text);
  font-size: 10px;
  font-weight: 400;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.sidebar-nav { padding: 12px 0; flex: 1; }

.nav-section-label {
  padding: 14px 20px 4px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: rgba(176,196,222,0.5);
}

.sidebar-nav .nav-item { margin: 1px 8px; }

.sidebar-nav .nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  color: var(--sidebar-text);
  text-decoration: none;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 450;
  transition: all var(--transition);
  white-space: nowrap;
}

.sidebar-nav .nav-link svg,
.sidebar-nav .nav-link .nav-icon {
  width: 18px; height: 18px;
  flex-shrink: 0;
  opacity: 0.8;
}

.sidebar-nav .nav-link:hover {
  background: rgba(255,255,255,0.07);
  color: #fff;
}

.sidebar-nav .nav-link.active {
  background: var(--primary);
  color: #fff;
}

.sidebar-nav .nav-link.active svg { opacity: 1; }

.sidebar-nav .nav-link .badge-count {
  margin-left: auto;
  background: var(--accent-light);
  color: #fff;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 10px;
  font-weight: 600;
}

/* Sous-menu */
.nav-submenu { display: none; padding-left: 16px; }
.nav-item.open > .nav-submenu { display: block; }
.nav-link.has-sub::after {
  content: '';
  margin-left: auto;
  width: 6px; height: 6px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-45deg);
  transition: transform 0.2s;
}
.nav-item.open > .nav-link.has-sub::after { transform: rotate(45deg); }

/* Sidebar user */
.sidebar-user {
  padding: 14px 20px;
  border-top: 1px solid rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.sidebar-user .user-avatar {
  width: 36px; height: 36px;
  background: var(--primary);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}

.sidebar-user .user-info { flex: 1; min-width: 0; }
.sidebar-user .user-name { color: #fff; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user .user-role { color: var(--sidebar-text); font-size: 11px; }

/* ---- MAIN CONTENT ---- */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ---- TOPBAR ---- */
.topbar {
  height: var(--topbar-height);
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 100;
  gap: 16px;
}

.topbar-title { font-size: 16px; font-weight: 700; color: var(--text-dark); flex: 1; }
.topbar-subtitle { font-size: 12px; color: var(--text-muted); font-weight: 400; margin-left: 8px; }

.topbar-actions { display: flex; align-items: center; gap: 12px; }

.btn-icon {
  width: 36px; height: 36px;
  border: none;
  background: none;
  border-radius: 8px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted);
  transition: all var(--transition);
  position: relative;
}
.btn-icon:hover { background: var(--body-bg); color: var(--text-dark); }
.btn-icon .notif-dot {
  position: absolute; top: 6px; right: 6px;
  width: 8px; height: 8px;
  background: var(--danger);
  border-radius: 50%;
  border: 2px solid #fff;
}

.topbar-user {
  display: flex; align-items: center; gap: 8px;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 8px;
  transition: background var(--transition);
}
.topbar-user:hover { background: var(--body-bg); }
.topbar-user .avatar {
  width: 32px; height: 32px;
  background: var(--primary);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 12px;
}
.topbar-user .user-details .name { font-size: 13px; font-weight: 600; color: var(--text-dark); }
.topbar-user .user-details .role { font-size: 11px; color: var(--text-muted); }

/* ---- PAGE CONTENT ---- */
.page-content { padding: 24px; flex: 1; }

/* ---- CARDS ---- */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  min-width: 0;
}

.card-body { min-width: 0; }

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.card-header .card-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-dark);
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}

.card-body { padding: 20px; }

/* ---- STAT CARDS ---- */
.stat-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  display: flex;
  align-items: flex-start;
  gap: 16px;
  transition: transform var(--transition), box-shadow var(--transition);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 4px 16px rgba(0,0,0,0.1); }

.stat-card .stat-icon {
  width: 48px; height: 48px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.stat-card .stat-icon.blue   { background: #dbeafe; color: #2563eb; }
.stat-card .stat-icon.green  { background: #dcfce7; color: #16a34a; }
.stat-card .stat-icon.orange { background: #fff7ed; color: #ea580c; }
.stat-card .stat-icon.purple { background: #f3e8ff; color: #9333ea; }
.stat-card .stat-icon.teal   { background: #ccfbf1; color: #0d9488; }
.stat-card .stat-icon.red    { background: #fee2e2; color: #dc2626; }
.stat-card .stat-icon.indigo { background: #e0e7ff; color: #4f46e5; }
.stat-card .stat-icon.yellow { background: #fef9c3; color: #ca8a04; }

.stat-card .stat-body { flex: 1; min-width: 0; }
.stat-card .stat-value { font-size: 22px; font-weight: 800; color: var(--text-dark); line-height: 1.2; }
.stat-card .stat-label { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.stat-card .stat-change { font-size: 11px; margin-top: 6px; display: flex; align-items: center; gap: 4px; }
.stat-card .stat-change.up   { color: var(--success); }
.stat-card .stat-change.down { color: var(--danger); }

/* ---- TABLES ---- */
.table-responsive { border-radius: 8px; overflow-x: auto; overflow-y: hidden; }
.table { margin-bottom: 0; font-size: 13.5px; }
.table thead th {
  background: #f8fafc;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 12px 16px;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
.table tbody td { padding: 12px 16px; vertical-align: middle; border-bottom: 1px solid #f1f5f9; }
.table tbody tr:hover { background: #f8fafc; }
.table tbody tr:last-child td { border-bottom: none; }

/* ---- BADGES ---- */
.badge { font-size: 11px; padding: 4px 8px; border-radius: 6px; font-weight: 600; }

/* ---- BUTTONS ---- */
.btn { border-radius: 8px; font-weight: 500; font-size: 13px; padding: 8px 16px; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-success { background: var(--success); border-color: var(--success); }
.btn-outline-primary { color: var(--primary); border-color: var(--primary); }
.btn-outline-primary:hover { background: var(--primary); color: #fff; }

/* ---- FORMS ---- */
.form-label { font-weight: 600; font-size: 13px; color: var(--text-dark); margin-bottom: 5px; }
.form-control, .form-select {
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 13.5px;
  padding: 9px 13px;
  transition: border var(--transition), box-shadow var(--transition);
}
.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26,82,118,0.1);
  outline: none;
}
.input-group .form-control { border-radius: 8px !important; }
.input-group-text { background: #f8fafc; border: 1.5px solid var(--border); border-radius: 8px !important; }

/* ---- BREADCRUMB ---- */
.breadcrumb { font-size: 13px; margin: 0; }
.breadcrumb-item + .breadcrumb-item::before { content: '/'; color: var(--text-muted); }
.breadcrumb-item a { color: var(--primary); text-decoration: none; }
.breadcrumb-item.active { color: var(--text-muted); }

/* ---- FILTERS BAR ---- */
.filters-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
  padding: 16px 20px;
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
}

/* ---- CHART CONTAINER ---- */
.chart-container { position: relative; }

/* ---- PROGRESS ---- */
.progress { height: 8px; border-radius: 4px; background: #e2e8f0; }
.progress-bar { border-radius: 4px; }

/* ---- AVATAR STACK ---- */
.avatar-sm {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--primary-light);
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-size: 12px; font-weight: 700;
}

/* ---- EMPTY STATE ---- */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}
.empty-state svg { width: 64px; height: 64px; opacity: 0.3; margin-bottom: 16px; }
.empty-state h6 { font-size: 15px; margin-bottom: 6px; }

/* ---- ALERTS ---- */
.alert { border-radius: 10px; border: none; font-size: 13.5px; }
.alert-success { background: #f0fdf4; color: #166534; }
.alert-danger  { background: #fef2f2; color: #991b1b; }
.alert-warning { background: #fffbeb; color: #92400e; }
.alert-info    { background: #eff6ff; color: #1e40af; }

/* ---- LOGIN PAGE ---- */
.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, var(--sidebar-bg) 0%, var(--primary) 60%, var(--primary-light) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  background: #fff;
  border-radius: 20px;
  padding: 48px 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

.login-logo {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo .logo-box {
  width: 64px; height: 64px;
  background: var(--primary);
  border-radius: 16px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 24px; font-weight: 900; color: #fff;
  margin-bottom: 12px;
}

.login-logo h1 { font-size: 18px; font-weight: 800; color: var(--text-dark); }
.login-logo p  { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; }

/* ---- MODALS ---- */
.modal-content { border: none; border-radius: 16px; }
.modal-header { background: var(--primary); color: #fff; border-radius: 16px 16px 0 0; border-bottom: none; }
.modal-header .btn-close { filter: invert(1); }
.modal-footer { border-top: 1px solid var(--border); }

/* ---- DROPDOWN ---- */
.dropdown-menu { border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,0.1); font-size: 13.5px; }
.dropdown-item { padding: 8px 16px; border-radius: 6px; transition: background var(--transition); }
.dropdown-item:hover { background: var(--body-bg); }
.dropdown-divider { margin: 4px 0; }

/* ---- MOBILE ---- */
.topbar .sidebar-toggle { display: none; }

@media (max-width: 991px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .topbar .sidebar-toggle { display: flex; }
  .sidebar-overlay {
    display: none;
    position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 999;
  }
  .sidebar-overlay.show { display: block; }
}

@media (max-width: 576px) {
  .page-content { padding: 16px; }
  .stat-card { padding: 14px; }
  .stat-card .stat-value { font-size: 18px; }
  .login-card { padding: 32px 24px; }
}

/* ---- SCROLLBAR ---- */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ---- UTILITIES ---- */
.fw-700 { font-weight: 700; }
.text-primary-brand { color: var(--primary) !important; }
.bg-primary-brand { background: var(--primary) !important; }
.border-radius-12 { border-radius: 12px; }
.gap-2 { gap: 8px; }
.cursor-pointer { cursor: pointer; }
.hover-shadow:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.1); }
