/* ==========================================================================
   Layout principal
   ========================================================================== */

.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ==========================================================================
   Sidebar
   ========================================================================== */

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 100;
  transition: transform var(--transition-base);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid rgba(255,255,255,0.08);
  min-height: var(--header-height);
}

.sidebar-brand-logo {
  width: 36px;
  height: 36px;
  background: var(--color-accent);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar-brand-logo svg {
  width: 22px;
  height: 22px;
  color: #fff;
}

.sidebar-brand-text {
  display: flex;
  flex-direction: column;
}

.sidebar-brand-name {
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
  color: var(--sidebar-text-active);
  letter-spacing: -0.3px;
}

.sidebar-brand-sub {
  font-size: var(--text-xs);
  color: var(--sidebar-text);
  opacity: 0.7;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.sidebar-nav {
  flex: 1;
  padding: var(--space-4) 0;
}

.sidebar-section {
  margin-bottom: var(--space-2);
}

.sidebar-section-label {
  padding: var(--space-3) var(--space-6) var(--space-1);
  font-size: 10px;
  font-weight: var(--weight-semibold);
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--sidebar-text);
  opacity: 0.45;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-4) var(--space-2) var(--space-5);
  margin: 1px var(--space-3);
  border-radius: var(--radius-md);
  color: var(--sidebar-text);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  transition: background var(--transition-fast), color var(--transition-fast);
  position: relative;
}

.sidebar-link:hover {
  background: var(--sidebar-hover);
  color: var(--sidebar-text-active);
}

.sidebar-link.active {
  background: var(--sidebar-active);
  color: var(--sidebar-text-active);
}

.sidebar-link.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 60%;
  background: var(--sidebar-accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

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

.sidebar-link.active .sidebar-link-icon {
  opacity: 1;
}

.sidebar-footer {
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid rgba(255,255,255,0.08);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}

.sidebar-user-avatar {
  width: 34px;
  height: 34px;
  background: var(--color-accent);
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
  color: #fff;
  flex-shrink: 0;
}

.sidebar-user-info {
  min-width: 0;
}

.sidebar-user-name {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--sidebar-text-active);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-logout {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  color: var(--sidebar-text);
  font-size: var(--text-sm);
  opacity: 0.7;
  transition: all var(--transition-fast);
  width: 100%;
  background: none;
  border: none;
}

.sidebar-logout:hover {
  background: rgba(211,47,47,0.15);
  color: #ff6b6b;
  opacity: 1;
}

/* ==========================================================================
   Contenu principal
   ========================================================================== */

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

.page-wrapper {
  flex: 1;
  padding: var(--space-8);
  max-width: var(--content-max-width);
  width: 100%;
  margin: 0 auto;
}

/* ==========================================================================
   En-tête de page
   ========================================================================== */

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-8);
}

.page-header-left {}

.page-title {
  font-size: var(--text-2xl);
  font-weight: var(--weight-bold);
  color: var(--color-text);
  letter-spacing: -0.4px;
}

.page-subtitle {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-top: var(--space-1);
}

.page-header-actions {
  display: flex;
  gap: var(--space-3);
  align-items: center;
  flex-shrink: 0;
}

/* ==========================================================================
   Flash messages
   ========================================================================== */

.flash-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-bottom: var(--space-6);
}

.flash {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  animation: slideInDown 0.3s ease;
}

@keyframes slideInDown {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.flash-success {
  background: var(--color-success-light);
  color: var(--color-success);
  border: 1px solid rgba(46,125,50,0.2);
}

.flash-error {
  background: var(--color-danger-light);
  color: var(--color-danger);
  border: 1px solid rgba(211,47,47,0.2);
}

.flash-info {
  background: var(--color-info-light);
  color: var(--color-info);
  border: 1px solid rgba(2,119,189,0.2);
}

.flash-warning {
  background: var(--color-warning-light);
  color: var(--color-warning);
  border: 1px solid rgba(245,127,23,0.2);
}

.flash-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* ==========================================================================
   Carte
   ========================================================================== */

.card {
  background: var(--color-bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
}

.card-header {
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
}

.card-title {
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  color: var(--color-text);
}

.card-body {
  padding: var(--space-6);
}

/* ==========================================================================
   Tableaux
   ========================================================================== */

.table-wrapper {
  overflow-x: auto;
}

.table {
  width: 100%;
  font-size: var(--text-sm);
}

.table thead tr {
  border-bottom: 2px solid var(--color-border);
}

.table th {
  padding: var(--space-3) var(--space-4);
  text-align: left;
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  color: var(--color-text-muted);
  letter-spacing: 0.5px;
  text-transform: uppercase;
  white-space: nowrap;
}

.table td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-border);
  color: var(--color-text);
  vertical-align: middle;
}

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

.table tbody tr:hover td {
  background: rgba(0,49,137,0.02);
}

/* ==========================================================================
   Stats dashboard
   ========================================================================== */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-5);
  margin-bottom: var(--space-8);
}

.stat-card {
  background: var(--color-bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
  padding: var(--space-5) var(--space-6);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  transition: box-shadow var(--transition-fast);
}

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

.stat-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.stat-card-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
}

.stat-card-icon.blue   { background: rgba(0,49,137,0.08); color: var(--color-primary); }
.stat-card-icon.orange { background: rgba(244,121,32,0.12); color: var(--color-accent); }
.stat-card-icon.green  { background: rgba(46,125,50,0.08); color: var(--color-success); }
.stat-card-icon.red    { background: rgba(211,47,47,0.08); color: var(--color-danger); }

.stat-card-value {
  font-size: var(--text-3xl);
  font-weight: var(--weight-bold);
  color: var(--color-text);
  letter-spacing: -1px;
  line-height: 1;
}

.stat-card-label {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  font-weight: var(--weight-medium);
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .main-content {
    margin-left: 0;
  }
  .page-wrapper {
    padding: var(--space-4);
  }
}
