/* ==========================================================================
   CoachPlan – CSS principal
   Design: propre, moderne, professionnel
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. VARIABLES CSS
   -------------------------------------------------------------------------- */
:root {
  --primary:              #2563eb;
  --primary-dark:         #1d4ed8;
  --primary-light:        #eff6ff;
  --success:              #16a34a;
  --success-light:        #f0fdf4;
  --warning:              #d97706;
  --warning-light:        #fffbeb;
  --danger:               #dc2626;
  --danger-light:         #fef2f2;
  --purple:               #7c3aed;
  --purple-light:         #f5f3ff;
  --info:                 #0891b2;
  --info-light:           #ecfeff;

  --sidebar-bg:           #1e293b;
  --sidebar-bg-hover:     #334155;
  --sidebar-text:         #cbd5e1;
  --sidebar-text-muted:   #64748b;
  --sidebar-active-bg:    #2563eb;
  --sidebar-active-text:  #ffffff;
  --sidebar-border:       rgba(255,255,255,0.06);

  --body-bg:              #f1f5f9;
  --card-bg:              #ffffff;
  --border-color:         #e2e8f0;
  --text-primary:         #0f172a;
  --text-secondary:       #475569;
  --text-muted:           #94a3b8;

  --sidebar-width:        260px;
  --sidebar-collapsed:    72px;
  --topbar-height:        64px;

  --border-radius:        12px;
  --border-radius-sm:     8px;
  --border-radius-lg:     16px;
  --border-radius-xl:     20px;
  --border-radius-pill:   9999px;

  --shadow:               0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md:            0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.05);
  --shadow-lg:            0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);
  --shadow-xl:            0 20px 25px rgba(0,0,0,0.1), 0 8px 10px rgba(0,0,0,0.04);

  --transition:           all 0.2s ease;
  --transition-slow:      all 0.35s ease;
}

/* --------------------------------------------------------------------------
   2. RESET & BASE
   -------------------------------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 0.9375rem;
  line-height: 1.6;
  color: var(--text-primary);
  background-color: var(--body-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  text-decoration: none;
  color: inherit;
}

img {
  max-width: 100%;
  display: block;
}

/* --------------------------------------------------------------------------
   3. LOGIN PAGE
   -------------------------------------------------------------------------- */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1e293b 0%, #1e3a5f 50%, #2563eb 100%);
  padding: 1.5rem;
  position: relative;
  overflow: hidden;
}

.login-page::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 30% 20%, rgba(37,99,235,0.3) 0%, transparent 60%),
              radial-gradient(ellipse at 70% 80%, rgba(124,58,237,0.2) 0%, transparent 60%);
  pointer-events: none;
}

.login-card {
  background: var(--card-bg);
  border-radius: var(--border-radius-xl);
  box-shadow: var(--shadow-xl);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 420px;
  position: relative;
  z-index: 1;
  animation: fadeInUp 0.5s ease both;
}

.login-logo {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--primary);
  margin-bottom: 1.75rem;
  justify-content: center;
}

.login-logo i {
  font-size: 2rem;
}

.login-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  text-align: center;
  margin-bottom: 0.375rem;
}

.login-subtitle {
  color: var(--text-secondary);
  text-align: center;
  margin-bottom: 2rem;
  font-size: 0.9rem;
}

.btn-login {
  padding: 0.75rem;
  font-size: 1rem;
  font-weight: 600;
  border-radius: var(--border-radius-sm);
  transition: var(--transition);
}

.btn-login:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(37,99,235,0.4);
}

/* --------------------------------------------------------------------------
   4. APP SHELL
   -------------------------------------------------------------------------- */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* --------------------------------------------------------------------------
   5. SIDEBAR
   -------------------------------------------------------------------------- */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background-color: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  z-index: 1040;
  transition: var(--transition-slow);
  overflow: hidden;
}

.sidebar.collapsed {
  width: var(--sidebar-collapsed);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1.25rem 1.25rem;
  color: #ffffff;
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  border-bottom: 1px solid var(--sidebar-border);
  min-height: var(--topbar-height);
  white-space: nowrap;
  overflow: hidden;
}

.sidebar-brand i {
  font-size: 1.5rem;
  color: #60a5fa;
  flex-shrink: 0;
}

.sidebar-brand-text {
  transition: var(--transition-slow);
}

.sidebar.collapsed .sidebar-brand-text {
  opacity: 0;
  width: 0;
  overflow: hidden;
}

/* Nav */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0.75rem 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.1) transparent;
}

.sidebar-nav::-webkit-scrollbar {
  width: 4px;
}

.sidebar-nav::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.1);
  border-radius: 4px;
}

.sidebar-nav .nav {
  gap: 2px;
  padding: 0 0.625rem;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem 0.875rem;
  border-radius: var(--border-radius-sm);
  color: var(--sidebar-text);
  font-size: 0.875rem;
  font-weight: 500;
  white-space: nowrap;
  transition: var(--transition);
  cursor: pointer;
  width: 100%;
}

.sidebar-link i {
  font-size: 1.125rem;
  flex-shrink: 0;
  width: 1.25rem;
  text-align: center;
}

.sidebar-link span:not(.sidebar-badge) {
  transition: var(--transition-slow);
}

.sidebar.collapsed .sidebar-link span:not(.sidebar-badge) {
  opacity: 0;
  width: 0;
  overflow: hidden;
}

.sidebar.collapsed .sidebar-badge {
  display: none !important;
}

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

.sidebar-link.active {
  background-color: var(--sidebar-active-bg);
  color: var(--sidebar-active-text);
  box-shadow: 0 2px 8px rgba(37,99,235,0.4);
}

.sidebar-badge {
  font-size: 0.7rem;
  padding: 0.1em 0.45em;
  line-height: 1.4;
}

/* Footer */
.sidebar-footer {
  border-top: 1px solid var(--sidebar-border);
  padding: 0.75rem 0.625rem;
  overflow: hidden;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.5rem 0.875rem;
  margin-bottom: 0.25rem;
  border-radius: var(--border-radius-sm);
  overflow: hidden;
}

.sidebar-user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--purple));
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.875rem;
  flex-shrink: 0;
}

.sidebar-user-details {
  overflow: hidden;
  transition: var(--transition-slow);
}

.sidebar.collapsed .sidebar-user-details {
  opacity: 0;
  width: 0;
}

.sidebar-user-name {
  font-size: 0.8125rem;
  font-weight: 600;
  color: #e2e8f0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-email {
  font-size: 0.7rem;
  color: var(--sidebar-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-gear {
  margin-left: auto;
  font-size: 0.85rem;
  color: var(--sidebar-text-muted);
  flex-shrink: 0;
  opacity: 0;
  transition: opacity var(--transition);
}

.sidebar-user:hover .sidebar-user-gear {
  opacity: 1;
}

.sidebar.collapsed .sidebar-user-gear {
  display: none;
}

.sidebar-logout {
  color: #f87171;
}

.sidebar-logout:hover {
  background-color: rgba(220,38,38,0.15);
  color: #fca5a5;
}

/* --------------------------------------------------------------------------
   6. TOPBAR
   -------------------------------------------------------------------------- */
.topbar {
  position: fixed;
  top: 0;
  left: var(--sidebar-width);
  right: 0;
  height: var(--topbar-height);
  background: var(--card-bg);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  gap: 0.75rem;
  z-index: 1030;
  box-shadow: var(--shadow);
  transition: left var(--transition-slow);
}

.app-shell.sidebar-collapsed .topbar {
  left: var(--sidebar-collapsed);
}

.topbar-breadcrumb .breadcrumb-item {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.topbar-breadcrumb .breadcrumb-item.active {
  font-weight: 600;
  color: var(--text-primary);
}

.topbar-user-menu {
  position: relative;
}

.topbar-user-chip {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.375rem 0.75rem 0.375rem 0.375rem;
  background: var(--body-bg);
  border-radius: var(--border-radius-pill);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-primary);
  cursor: pointer;
  user-select: none;
  transition: background var(--transition);
}

.topbar-user-chip:hover {
  background: var(--hover-bg);
}

.topbar-chevron {
  font-size: 0.6rem;
  opacity: 0.6;
  transition: transform var(--transition);
}

.topbar-user-menu.open .topbar-chevron {
  transform: rotate(180deg);
}

.topbar-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 180px;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  box-shadow: 0 8px 24px rgba(0,0,0,0.15);
  z-index: 1050;
  overflow: hidden;
}

.topbar-user-menu.open .topbar-dropdown {
  display: block;
}

.topbar-dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.625rem 1rem;
  color: var(--text-primary);
  text-decoration: none;
  font-size: 0.875rem;
  transition: background var(--transition);
}

.topbar-dropdown-item:hover {
  background: var(--hover-bg);
  color: var(--text-primary);
}

.topbar-dropdown-item--danger {
  color: #f87171;
  border-top: 1px solid var(--border-color);
}

.topbar-dropdown-item--danger:hover {
  background: rgba(220,38,38,0.1);
  color: #fca5a5;
}

.topbar-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--purple));
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.75rem;
}

.topbar-badge {
  font-size: 0.6rem;
  min-width: 16px;
  height: 16px;
  line-height: 1;
  padding: 0 4px;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
}

/* --------------------------------------------------------------------------
   7. MAIN CONTENT
   -------------------------------------------------------------------------- */
.main-content {
  flex: 1;
  min-width: 0;
  margin-left: var(--sidebar-width);
  margin-top: var(--topbar-height);
  padding: 2rem 1.75rem;
  min-height: calc(100vh - var(--topbar-height));
  background-color: var(--body-bg);
  transition: margin-left var(--transition-slow);
}

.app-shell.sidebar-collapsed .main-content {
  margin-left: var(--sidebar-collapsed);
}

/* --------------------------------------------------------------------------
   8. PAGE SECTIONS & HEADER
   -------------------------------------------------------------------------- */
.page-section {
  animation: fadeInUp 0.3s ease both;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.75rem;
  flex-wrap: wrap;
}

.page-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 0.25rem;
  line-height: 1.2;
}

.page-subtitle {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin: 0;
}

/* --------------------------------------------------------------------------
   9. BUTTONS
   -------------------------------------------------------------------------- */
.btn {
  border-radius: var(--border-radius-sm);
  font-weight: 500;
  transition: var(--transition);
}

.btn-primary {
  background-color: var(--primary);
  border-color: var(--primary);
}

.btn-primary:hover,
.btn-primary:focus {
  background-color: var(--primary-dark);
  border-color: var(--primary-dark);
  box-shadow: 0 4px 12px rgba(37,99,235,0.35);
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--border-radius-sm);
  border: 1px solid var(--border-color);
  background: var(--card-bg);
  color: var(--text-secondary);
  font-size: 1rem;
  cursor: pointer;
}

.btn-icon:hover {
  background: var(--body-bg);
  color: var(--text-primary);
  border-color: var(--primary);
  color: var(--primary);
}

.btn-icon-label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.btn-ghost {
  background: transparent;
  border-color: var(--border-color);
  color: var(--text-secondary);
}

.btn-ghost:hover {
  background: var(--body-bg);
  color: var(--text-primary);
}

/* --------------------------------------------------------------------------
   10. CARDS
   -------------------------------------------------------------------------- */
.card-custom {
  background: var(--card-bg);
  border-radius: var(--border-radius);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: var(--transition);
}

.card-custom:hover {
  box-shadow: var(--shadow-md);
}

.card-header-custom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
  gap: 0.75rem;
  flex-wrap: wrap;
}

.card-title-custom {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.card-subtitle-custom {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* --------------------------------------------------------------------------
   11. STAT CARDS
   -------------------------------------------------------------------------- */
.stat-card {
  background: var(--card-bg);
  border-radius: var(--border-radius);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  border-radius: 4px 0 0 4px;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.stat-card--blue::before  { background: var(--primary); }
.stat-card--green::before { background: var(--success); }
.stat-card--purple::before{ background: var(--purple); }
.stat-card--orange::before{ background: var(--warning); }

.stat-card__icon {
  width: 52px;
  height: 52px;
  border-radius: var(--border-radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.375rem;
  flex-shrink: 0;
}

.stat-card--blue  .stat-card__icon { background: var(--primary-light); color: var(--primary); }
.stat-card--green .stat-card__icon { background: var(--success-light); color: var(--success); }
.stat-card--purple.stat-card__icon, .stat-card--purple .stat-card__icon { background: var(--purple-light); color: var(--purple); }
.stat-card--orange .stat-card__icon { background: var(--warning-light); color: var(--warning); }

.stat-card__body {
  min-width: 0;
}

.stat-card__value {
  font-size: 1.625rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.1;
  white-space: nowrap;
}

.stat-card__label {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
}

/* --------------------------------------------------------------------------
   12. TABLES
   -------------------------------------------------------------------------- */
.table-custom {
  font-size: 0.875rem;
  color: var(--text-primary);
  border-collapse: separate;
  border-spacing: 0;
}

.table-custom thead th {
  background: var(--body-bg);
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

.table-custom tbody td {
  padding: 0.8rem 1rem;
  border-bottom: 1px solid var(--border-color);
  vertical-align: middle;
}

.table-custom tbody tr:last-child td {
  border-bottom: none;
}

.table-custom.table-hover tbody tr:hover {
  background-color: rgba(37,99,235,0.03);
}

/* Action buttons in tables */
.table-custom .btn-icon {
  width: 30px;
  height: 30px;
  font-size: 0.875rem;
}

.action-buttons {
  display: flex;
  gap: 4px;
  justify-content: center;
  flex-wrap: nowrap;
}

/* --------------------------------------------------------------------------
   13. BADGES / STATUS
   -------------------------------------------------------------------------- */
.badge {
  font-weight: 500;
  border-radius: var(--border-radius-pill);
  font-size: 0.72rem;
  padding: 0.3em 0.7em;
}

.badge-planifiee {
  background: var(--primary-light);
  color: var(--primary);
}

.badge-realisee {
  background: var(--success-light);
  color: var(--success);
}

.badge-annulee {
  background: #f1f5f9;
  color: var(--text-secondary);
}

.badge-manquee {
  background: var(--danger-light);
  color: var(--danger);
}

.badge-actif {
  background: var(--success-light);
  color: var(--success);
}

.badge-inactif {
  background: #f1f5f9;
  color: var(--text-secondary);
}

.badge-en-cours {
  background: var(--primary-light);
  color: var(--primary);
}

.badge-en-retard {
  background: var(--warning-light);
  color: var(--warning);
}

.badge-termine {
  background: #f1f5f9;
  color: var(--text-secondary);
}

/* --------------------------------------------------------------------------
   14. PROGRESS BARS
   -------------------------------------------------------------------------- */
.progress {
  height: 8px;
  border-radius: var(--border-radius-pill);
  background-color: var(--border-color);
  overflow: hidden;
}

.progress-bar {
  border-radius: var(--border-radius-pill);
  transition: width 0.5s ease;
}

.progress-bar.bg-success,
[data-progress-status="ok"] .progress-bar {
  background-color: var(--success) !important;
}

.progress-bar.bg-warning,
[data-progress-status="warning"] .progress-bar {
  background-color: var(--warning) !important;
}

.progress-bar.bg-danger,
[data-progress-status="danger"] .progress-bar {
  background-color: var(--danger) !important;
}

.progress-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 3px;
  display: block;
}

/* --------------------------------------------------------------------------
   15. FORFAIT CARDS
   -------------------------------------------------------------------------- */
.forfaits-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.25rem;
}

.forfait-card {
  background: var(--card-bg);
  border-radius: var(--border-radius);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: var(--transition);
  cursor: default;
}

.forfait-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
}

.forfait-card__header {
  height: 6px;
  /* background color injected inline via CSS var --forfait-color */
  background-color: var(--forfait-color, var(--primary));
}

.forfait-card__body {
  padding: 1.25rem;
}

.forfait-card__name {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.25rem;
}

.forfait-card__desc {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  margin-bottom: 1rem;
  min-height: 2.4em;
}

.forfait-card__meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.forfait-card__meta-item {
  font-size: 0.8rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.forfait-card__meta-item i {
  color: var(--text-muted);
  font-size: 0.875rem;
}

.forfait-card__price {
  font-size: 1.375rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 0.75rem;
}

.forfait-card__actions {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem 1.25rem;
  border-top: 1px solid var(--border-color);
}

/* --------------------------------------------------------------------------
   16. PLANNING / CALENDAR
   -------------------------------------------------------------------------- */
.calendar-nav {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.calendar-month-label {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  min-width: 160px;
  text-align: center;
  text-transform: capitalize;
}

.calendar-day-headers {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  border-bottom: 1px solid var(--border-color);
}

.calendar-day-headers > div {
  padding: 0.5rem 0.75rem;
  text-align: center;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  background: var(--body-bg);
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
}

.calendar-grid.week-mode {
  display: block;
  width: 100%;
}

/* ── Week view ─────────────────────────────────────────────── */
.week-view {
  display: flex;
  width: 100%;
  flex-direction: column;
}

.week-header-row {
  display: flex;
  border-bottom: 2px solid var(--border-color);
  background: var(--card-bg);
  position: sticky;
  top: 0;
  z-index: 2;
}

.week-time-gutter {
  width: 48px;
  flex-shrink: 0;
}

.week-header-day {
  flex: 1;
  text-align: center;
  padding: 0.35rem 0.25rem;
  font-size: 0.8rem;
  border-left: 1px solid var(--border-color);
  line-height: 1.3;
}

.week-header-day.today {
  color: var(--primary);
}

.week-header-day.today strong {
  background: var(--primary);
  color: #fff;
  border-radius: 50%;
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.week-body {
  overflow-y: scroll;
  height: 480px;
}

/* Inner flex row — sits INSIDE the scrollable .week-body */
.week-inner {
  display: flex;
  position: relative;
}

.week-time-col {
  width: 48px;
  flex-shrink: 0;
  position: relative;
}

.week-time-label {
  position: absolute;
  right: 6px;
  font-size: 0.68rem;
  color: var(--text-muted);
  transform: translateY(-50%);
  white-space: nowrap;
}

.week-days-wrapper {
  flex: 1;
  display: flex;
  min-width: 0;
  overflow: hidden;
}

.week-day-col {
  flex: 1;
  position: relative;
  border-left: 1px solid var(--border-color);
  min-width: 0;
}

.week-day-col.today {
  background: rgba(37, 99, 235, 0.03);
}

.week-hour-line {
  position: absolute;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--border-color);
  pointer-events: none;
}

.week-half-line {
  position: absolute;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--border-color);
  opacity: 0.35;
  pointer-events: none;
}

.week-event {
  position: absolute;
  left: 2px;
  right: 2px;
  border-radius: 4px;
  padding: 3px 5px;
  font-size: 0.67rem;
  cursor: pointer;
  overflow: hidden;
  z-index: 1;
  color: #fff;
  line-height: 1.25;
  text-shadow: 0 1px 2px rgba(0,0,0,0.3);
  transition: opacity 0.12s, box-shadow 0.12s;
  border-left: 3px solid rgba(255,255,255,0.45);
}

.week-event:hover {
  opacity: 0.88;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
  z-index: 2;
}

/* Status variants — left-border color */
.week-event.s-realisee   { border-left-color: #16a34a; opacity: 0.75; }
.week-event.s-manquee    { border-left-color: #dc2626; opacity: 0.6; }
.week-event.s-annulee_client,
.week-event.s-annulee_coach { border-left-color: #6b7280; opacity: 0.5; }

/* Pill inner layout */
.we-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.we-time {
  font-weight: 700;
  font-size: 0.7rem;
}

.we-si {
  font-size: 0.7rem;
  font-weight: 700;
}

.we-name {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.we-sub {
  font-size: 0.62rem;
  opacity: 0.88;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.week-event.s-realisee .we-name { text-decoration: line-through; }

.week-now-line {
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--primary, #2563eb);
  z-index: 3;
  pointer-events: none;
}

.week-now-line::before {
  content: '';
  position: absolute;
  left: -4px;
  top: -4px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--primary, #2563eb);
}

.calendar-cell {
  min-height: 120px;
  border-right: 1px solid var(--border-color);
  border-bottom: 1px solid var(--border-color);
  padding: 0.5rem;
  position: relative;
  transition: background var(--transition);
}

.calendar-cell:nth-child(7n) {
  border-right: none;
}

.calendar-cell:hover {
  background: var(--body-bg);
}

.calendar-cell.today {
  background: var(--primary-light);
}

.calendar-cell.other-month {
  background: #fafafa;
}

.calendar-cell.other-month .calendar-day-num {
  color: var(--text-muted);
}

.calendar-day-num {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-secondary);
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  margin-bottom: 0.35rem;
}

.calendar-cell.today .calendar-day-num {
  background: var(--primary);
  color: white;
}

.calendar-sessions {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.session-pill {
  font-size: 0.7rem;
  font-weight: 500;
  padding: 2px 6px;
  border-radius: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  transition: var(--transition);
  line-height: 1.4;
}

.session-pill:hover {
  filter: brightness(0.9);
}

.session-pill.planifiee {
  background: var(--primary-light);
  color: var(--primary);
}

.session-pill.realisee {
  background: var(--success-light);
  color: var(--success);
}

.session-pill.annulee {
  background: #f1f5f9;
  color: var(--text-secondary);
  text-decoration: line-through;
}

.session-pill.manquee {
  background: var(--danger-light);
  color: var(--danger);
}

/* --------------------------------------------------------------------------
   17. ALERTES
   -------------------------------------------------------------------------- */
.alertes-toolbar {
  display: flex;
  align-items: center;
}

.alertes-toolbar .btn-group .btn.active {
  z-index: 1;
}

#alertes-table .alert-checkbox {
  cursor: pointer;
  width: 16px;
  height: 16px;
}
.urgence-haute {
  border-left: 3px solid var(--danger);
  background: rgba(220,38,38,0.03);
}

.urgence-moyenne {
  border-left: 3px solid var(--warning);
  background: rgba(217,119,6,0.03);
}

.urgence-faible {
  border-left: 3px solid #ca8a04;
  background: rgba(202,138,4,0.03);
}

.badge-urgence-haute   { background: var(--danger-light);  color: var(--danger);  }
.badge-urgence-moyenne { background: var(--warning-light); color: var(--warning); }
.badge-urgence-faible  { background: #fefce8; color: #854d0e; }

/* --------------------------------------------------------------------------
   18. CLIENT DETAIL PANEL
   -------------------------------------------------------------------------- */
.client-detail-panel {
  animation: fadeInUp 0.25s ease both;
}

.detail-info-group {
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
}

.detail-info-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.detail-info-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.detail-info-value {
  font-size: 0.9rem;
  color: var(--text-primary);
  font-weight: 500;
}

.detail-forfaits-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.detail-forfait-item {
  background: var(--body-bg);
  border-radius: var(--border-radius-sm);
  border: 1px solid var(--border-color);
  padding: 0.875rem;
}

/* --------------------------------------------------------------------------
   19. TOASTS
   -------------------------------------------------------------------------- */
.toast-container {
  pointer-events: none;
}

.toast-custom {
  pointer-events: auto;
  background: var(--card-bg);
  border-radius: var(--border-radius-sm);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-lg);
  padding: 0.875rem 1rem;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  min-width: 300px;
  max-width: 400px;
  animation: slideInRight 0.3s ease both;
}

.toast-custom.hiding {
  animation: slideOutRight 0.3s ease both;
}

.toast-custom__icon {
  font-size: 1.125rem;
  flex-shrink: 0;
  margin-top: 1px;
}

.toast-custom.toast-success .toast-custom__icon { color: var(--success); }
.toast-custom.toast-danger  .toast-custom__icon { color: var(--danger); }
.toast-custom.toast-warning .toast-custom__icon { color: var(--warning); }
.toast-custom.toast-info    .toast-custom__icon { color: var(--info); }

.toast-custom__body {
  flex: 1;
  min-width: 0;
}

.toast-custom__title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.toast-custom__message {
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

.toast-custom__close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0;
  font-size: 0.875rem;
  line-height: 1;
  transition: var(--transition);
  flex-shrink: 0;
}

.toast-custom__close:hover {
  color: var(--text-primary);
}

/* --------------------------------------------------------------------------
   20. MODALS
   -------------------------------------------------------------------------- */
.modal-custom {
  border-radius: var(--border-radius-lg);
  border: none;
  box-shadow: var(--shadow-xl);
  overflow: hidden;
}

.modal-custom .modal-header {
  border-bottom: 1px solid var(--border-color);
  padding: 1.125rem 1.5rem;
  background: var(--card-bg);
}

.modal-custom .modal-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.modal-custom .modal-body {
  padding: 1.5rem;
  background: var(--card-bg);
}

.modal-custom .modal-footer {
  border-top: 1px solid var(--border-color);
  padding: 0.875rem 1.5rem;
  background: var(--body-bg);
  gap: 0.5rem;
}

.modal-backdrop.show {
  opacity: 0.5;
  backdrop-filter: blur(2px);
}

/* --------------------------------------------------------------------------
   21. FORMS
   -------------------------------------------------------------------------- */
.form-control,
.form-select {
  border-color: var(--border-color);
  border-radius: var(--border-radius-sm);
  color: var(--text-primary);
  font-size: 0.875rem;
  transition: var(--transition);
  padding: 0.5rem 0.75rem;
}

.form-control:focus,
.form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
}

.form-control::placeholder {
  color: var(--text-muted);
}

.form-control[readonly] {
  background: var(--body-bg);
  cursor: default;
}

.form-label {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 0.375rem;
}

.form-text {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.input-group-text {
  background: var(--body-bg);
  border-color: var(--border-color);
  color: var(--text-secondary);
  font-size: 0.875rem;
}

.form-check-input:checked {
  background-color: var(--primary);
  border-color: var(--primary);
}

.form-control-color {
  padding: 0.25rem;
  height: 38px;
  cursor: pointer;
}

.form-control-plaintext {
  color: var(--text-primary);
  font-size: 0.875rem;
  padding: 0.5rem 0;
}

/* --------------------------------------------------------------------------
   22. LOADING OVERLAY
   -------------------------------------------------------------------------- */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(4px);
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.loading-spinner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.loading-text {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-secondary);
}

/* --------------------------------------------------------------------------
   23. ANIMATIONS
   -------------------------------------------------------------------------- */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(100%);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes slideOutRight {
  from {
    opacity: 1;
    transform: translateX(0);
  }
  to {
    opacity: 0;
    transform: translateX(110%);
  }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* --------------------------------------------------------------------------
   24. RESPONSIVE – 768px (tablet/mobile)
   -------------------------------------------------------------------------- */
@media (max-width: 992px) {
  .main-content {
    padding: 1.25rem 1rem;
  }

  .forfaits-grid {
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  }

  .calendar-cell {
    min-height: 90px;
    padding: 0.35rem;
  }
}

@media (max-width: 768px) {
  /* Sidebar becomes overlay on mobile */
  .sidebar {
    transform: translateX(-100%);
    width: var(--sidebar-width);
    box-shadow: var(--shadow-xl);
  }

  .sidebar.mobile-open {
    transform: translateX(0);
  }

  /* Topbar stretches full width */
  .topbar {
    left: 0;
    padding: 0 1rem;
  }

  .main-content {
    margin-left: 0;
    padding: 1rem;
  }

  .app-shell.sidebar-collapsed .topbar {
    left: 0;
  }

  .app-shell.sidebar-collapsed .main-content {
    margin-left: 0;
  }

  /* Tables: horizontal scroll */
  .table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }

  .page-header .btn {
    width: 100%;
    justify-content: center;
  }

  .calendar-grid {
    overflow-x: auto;
  }

  .calendar-day-headers,
  .calendar-grid {
    min-width: 560px;
  }

  .calendar-cell {
    min-height: 80px;
  }

  .forfaits-grid {
    grid-template-columns: 1fr;
  }

  .stat-card__value {
    font-size: 1.375rem;
  }

  .modal-dialog {
    margin: 0.75rem;
  }

  .modal-custom .modal-body {
    padding: 1rem;
  }

  .modal-custom .modal-footer {
    padding: 0.75rem 1rem;
  }

  .topbar-user-chip span {
    display: none;
  }
}

@media (max-width: 480px) {
  .stat-card {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }

  .stat-card::before {
    width: 100%;
    height: 4px;
    top: 0;
    bottom: auto;
    border-radius: 4px 4px 0 0;
  }

  .calendar-month-label {
    min-width: 120px;
    font-size: 0.875rem;
  }
}

/* Mobile sidebar overlay backdrop */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1039;
  animation: fadeIn 0.2s ease;
}

.sidebar-backdrop.visible {
  display: block;
}

/* --------------------------------------------------------------------------
   25. SUIVI — progress compound display
   -------------------------------------------------------------------------- */
.progress-compound {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 140px;
}

.progress-compound .progress {
  height: 6px;
}

/* --------------------------------------------------------------------------
   26. YEAR SELECT in Comptabilité
   -------------------------------------------------------------------------- */
#year-select {
  min-width: 90px;
  font-weight: 600;
}

/* --------------------------------------------------------------------------
   27. EMPTY STATE
   -------------------------------------------------------------------------- */
.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--text-muted);
}

.empty-state i {
  font-size: 2.5rem;
  margin-bottom: 1rem;
  display: block;
  opacity: 0.4;
}

.empty-state p {
  font-size: 0.9rem;
  margin: 0;
}

/* --------------------------------------------------------------------------
   28. MISC UTILITIES
   -------------------------------------------------------------------------- */
.text-truncate-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.rotate-180 {
  transform: rotate(180deg);
}

.fw-semibold {
  font-weight: 600;
}

/* Subtle divider */
.divider {
  height: 1px;
  background: var(--border-color);
  margin: 1.25rem 0;
}

/* Alert color overrides */
.alert-success { border-left: 4px solid var(--success); }
.alert-warning { border-left: 4px solid var(--warning); }
.alert-danger  { border-left: 4px solid var(--danger); }
.alert-info    { border-left: 4px solid var(--info); }

/* Breadcrumb separator */
.breadcrumb-item + .breadcrumb-item::before {
  content: '›';
  font-weight: 700;
  color: var(--text-muted);
}

/* Scrollbar global (Webkit) */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* --------------------------------------------------------------------------
   29. PRINT
   -------------------------------------------------------------------------- */
@media print {
  .sidebar,
  .topbar,
  .btn,
  .modal,
  #toast-container {
    display: none !important;
  }

  .main-content {
    margin: 0;
    padding: 0;
  }

  .card-custom {
    box-shadow: none;
    border: 1px solid #ddd;
  }
}
