:root {
    --bg-primary: #0d1117;
    --bg-secondary: #161b22;
    --bg-tertiary: #21262d;
    --border: #30363d;
    --text-primary: #f0f6fc;
    --text-secondary: #8b949e;
    --text-muted: #6e7681;
    --primary: #1f6feb;
    --primary-hover: #388bfd;
    --success: #3fb950;
    --warning: #d29922;
    --danger: #f85149;
    --info: #58a6ff;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
}

a { color: var(--info); text-decoration: none; }
a:hover { text-decoration: underline; }

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

.sidebar {
    width: 260px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
}

.sidebar-header { padding: 20px; border-bottom: 1px solid var(--border); }
.sidebar-logo { display: flex; align-items: center; gap: 12px; font-size: 1.25rem; font-weight: 600; }
.sidebar-logo svg { width: 28px; height: 28px; color: var(--primary); }

.sidebar-nav { flex: 1; padding: 12px; }
.nav-section { margin-bottom: 24px; }
.nav-section-title { font-size: 0.75rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; padding: 8px 12px; }
.nav-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 6px; color: var(--text-secondary); transition: all 0.15s; }
.nav-item:hover { background: var(--bg-tertiary); color: var(--text-primary); text-decoration: none; }
.nav-item.active { background: var(--primary); color: white; }
.nav-item svg { width: 20px; height: 20px; flex-shrink: 0; }

.sidebar-footer { padding: 16px; border-top: 1px solid var(--border); }
.user-info { display: flex; align-items: center; gap: 12px; }
.user-avatar { width: 36px; height: 36px; background: var(--primary); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 600; }
.user-details { flex: 1; }
.user-name { font-weight: 500; font-size: 0.875rem; }
.user-role { font-size: 0.75rem; color: var(--text-muted); }

.main-content { flex: 1; margin-left: 260px; padding: 24px 32px; }

.page-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 24px; flex-wrap: wrap; gap: 16px; }
.page-title { font-size: 1.75rem; font-weight: 600; margin-bottom: 4px; }
.page-subtitle { color: var(--text-secondary); }
.page-actions { display: flex; gap: 12px; flex-wrap: wrap; }

.btn {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 10px 16px; border-radius: 6px; font-weight: 500; font-size: 0.875rem;
    border: none; cursor: pointer; transition: all 0.15s; text-decoration: none;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); text-decoration: none; }
.btn-secondary { background: var(--bg-tertiary); color: var(--text-primary); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); text-decoration: none; }
.btn-danger { background: var(--danger); color: white; }
.btn-sm { padding: 6px 12px; font-size: 0.8125rem; }

.card { background: var(--bg-secondary); border: 1px solid var(--border); border-radius: 8px; }
.card-header { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.card-title { font-size: 1rem; font-weight: 600; }
.card-body { padding: 20px; }

.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--border); }
.table th { font-weight: 600; color: var(--text-secondary); font-size: 0.8125rem; text-transform: uppercase; background: var(--bg-tertiary); }
.table tbody tr:hover { background: var(--bg-tertiary); }

.badge { display: inline-block; padding: 4px 10px; border-radius: 20px; font-size: 0.75rem; font-weight: 500; }
.badge-success { background: rgba(63, 185, 80, 0.2); color: var(--success); }
.badge-warning { background: rgba(210, 153, 34, 0.2); color: var(--warning); }
.badge-danger { background: rgba(248, 81, 73, 0.2); color: var(--danger); }
.badge-info { background: rgba(88, 166, 255, 0.2); color: var(--info); }
.badge-secondary { background: var(--bg-tertiary); color: var(--text-secondary); }

.form-group { margin-bottom: 20px; }
.form-label { display: block; font-weight: 500; margin-bottom: 8px; color: var(--text-secondary); font-size: 0.875rem; }
.form-control {
    width: 100%; padding: 10px 14px; background: var(--bg-tertiary); border: 1px solid var(--border);
    border-radius: 6px; color: var(--text-primary); font-size: 0.9375rem;
}
.form-control:focus { outline: none; border-color: var(--primary); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

.filters-bar { display: flex; gap: 12px; margin-bottom: 24px; flex-wrap: wrap; }
.search-input { position: relative; flex: 1; min-width: 200px; }
.search-input svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--text-muted); }
.search-input .form-control { padding-left: 40px; }
.filter-select { width: auto; min-width: 160px; }

.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { display: flex; align-items: center; gap: 16px; padding: 20px; background: var(--bg-secondary); border: 1px solid var(--border); border-radius: 8px; }
.stat-icon { width: 48px; height: 48px; border-radius: 12px; display: flex; align-items: center; justify-content: center; }
.stat-icon svg { width: 24px; height: 24px; }
.stat-icon.blue { background: rgba(31, 111, 235, 0.2); color: var(--primary); }
.stat-icon.green { background: rgba(63, 185, 80, 0.2); color: var(--success); }
.stat-icon.yellow { background: rgba(210, 153, 34, 0.2); color: var(--warning); }
.stat-icon.red { background: rgba(248, 81, 73, 0.2); color: var(--danger); }
.stat-value { font-size: 1.75rem; font-weight: 600; }
.stat-label { color: var(--text-secondary); font-size: 0.875rem; }

.detail-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 24px; }
.detail-section { margin-bottom: 24px; }
.detail-section:last-child { margin-bottom: 0; }
.detail-section-title { font-size: 0.75rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; margin-bottom: 12px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.detail-row { display: flex; justify-content: space-between; padding: 8px 0; }
.detail-label { color: var(--text-secondary); }
.detail-value { font-weight: 500; }

.timeline { position: relative; padding-left: 24px; }
.timeline::before { content: ''; position: absolute; left: 6px; top: 8px; bottom: 8px; width: 2px; background: var(--border); }
.timeline-item { position: relative; padding-bottom: 20px; }
.timeline-item::before { content: ''; position: absolute; left: -18px; top: 6px; width: 10px; height: 10px; border-radius: 50%; background: var(--border); }
.timeline-item.entrée::before, .timeline-item.entry::before { background: var(--success); }
.timeline-item.affectation::before { background: var(--info); }
.timeline-item.retour::before { background: var(--warning); }
.timeline-date { font-size: 0.75rem; color: var(--text-muted); margin-bottom: 4px; }
.timeline-type { font-weight: 600; margin-bottom: 4px; }
.timeline-details { font-size: 0.875rem; color: var(--text-secondary); }

.empty-state { text-align: center; padding: 60px 20px; }
.empty-state h3 { color: var(--text-muted); margin-bottom: 16px; }

.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg-primary); }
.login-card { background: var(--bg-secondary); border: 1px solid var(--border); border-radius: 12px; padding: 40px; width: 100%; max-width: 400px; }
.login-logo { text-align: center; margin-bottom: 32px; }
.login-logo svg { width: 48px; height: 48px; color: var(--primary); margin-bottom: 16px; }
.login-logo h1 { font-size: 1.5rem; margin-bottom: 4px; }
.login-logo p { color: var(--text-secondary); }

.alert { padding: 12px 16px; border-radius: 6px; margin-bottom: 16px; }
.alert-success { background: rgba(63, 185, 80, 0.15); border: 1px solid var(--success); color: var(--success); }
.alert-danger { background: rgba(248, 81, 73, 0.15); border: 1px solid var(--danger); color: var(--danger); }
.alert-warning { background: rgba(210, 153, 34, 0.15); border: 1px solid var(--warning); color: var(--warning); }
.alert-info { background: rgba(88, 166, 255, 0.15); border: 1px solid var(--info); color: var(--info); }

@media (max-width: 1024px) {
    .sidebar { width: 220px; }
    .main-content { margin-left: 220px; }
    .detail-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    .sidebar { display: none; }
    .main-content { margin-left: 0; }
    .form-row { grid-template-columns: 1fr; }
}
