/* =====================================================================
   Colonel — Gestion de Chantier
   Palette : bleu marine #1e3a5f, orange chantier #f97316, gris béton #64748b
   ===================================================================== */

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

:root {
  --primary:      #1e3a5f;
  --primary-dark: #152c47;
  --primary-light:#2d5a8e;
  --accent:       #f97316;
  --accent-dark:  #ea6c0a;
  --success:      #10b981;
  --warning:      #f59e0b;
  --danger:       #ef4444;
  --info:         #3b82f6;
  --text:         #1e293b;
  --text-muted:   #64748b;
  --border:       #e2e8f0;
  --bg:           #f1f5f9;
  --bg-card:      #ffffff;
  --sidebar-w:    260px;
  --radius:       10px;
  --shadow:       0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md:    0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
  --shadow-lg:    0 10px 15px rgba(0,0,0,.1), 0 4px 6px rgba(0,0,0,.05);
}

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

/* ── Login ─────────────────────────────────────────────────────────── */

.login-page { display: flex; min-height: 100vh; }

.login-sidebar {
  width: 420px;
  background: linear-gradient(160deg, var(--primary) 0%, var(--primary-dark) 60%, #0d1f38 100%);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 40px;
  flex-shrink: 0;
}

.brand { max-width: 320px; }
.brand-icon { font-size: 48px; color: var(--accent); margin-bottom: 16px; display: block; }
.brand h1 { font-size: 32px; font-weight: 800; letter-spacing: -0.5px; margin-bottom: 4px; }
.brand-subtitle { font-size: 14px; color: rgba(255,255,255,.6); text-transform: uppercase; letter-spacing: 2px; margin-bottom: 20px; }
.brand-description { font-size: 14px; color: rgba(255,255,255,.75); line-height: 1.7; margin-bottom: 32px; }

.features { display: flex; flex-direction: column; gap: 14px; }
.feature-item { display: flex; align-items: center; gap: 12px; font-size: 13px; color: rgba(255,255,255,.8); }
.feature-item i { width: 32px; height: 32px; background: rgba(255,255,255,.12); border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 14px; color: var(--accent); flex-shrink: 0; }

.login-main { flex: 1; display: flex; align-items: center; justify-content: center; padding: 32px; background: var(--bg); }

.login-card {
  background: white;
  border-radius: 16px;
  padding: 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
}

.login-card h2 { font-size: 24px; font-weight: 700; color: var(--primary); margin-bottom: 4px; }
.login-subtitle { color: var(--text-muted); font-size: 13px; margin-bottom: 28px; }

.error-msg { display: none; align-items: center; gap: 8px; background: #fef2f2; border: 1px solid #fecaca; border-radius: 8px; padding: 10px 14px; margin-bottom: 20px; color: var(--danger); font-size: 13px; }
.error-msg.visible { display: flex; }

.form-group { margin-bottom: 18px; }
.form-group label { display: block; font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 6px; }

.input-wrapper { position: relative; }
.input-wrapper i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-muted); font-size: 14px; pointer-events: none; }
.input-wrapper input, .input-wrapper select {
  width: 100%;
  padding: 10px 12px 10px 36px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  color: var(--text);
  background: white;
  transition: border-color .2s, box-shadow .2s;
}
.input-wrapper input:focus, .input-wrapper select:focus { outline: none; border-color: var(--primary-light); box-shadow: 0 0 0 3px rgba(45,90,142,.12); }

/* ── Boutons ───────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: 8px;
  border: none;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, transform .1s, box-shadow .15s;
  text-decoration: none;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); color: white; width: 100%; padding: 12px; font-size: 14px; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-accent  { background: var(--accent); color: white; }
.btn-accent:hover { background: var(--accent-dark); }
.btn-success { background: var(--success); color: white; }
.btn-danger  { background: var(--danger); color: white; }
.btn-outline { background: transparent; color: var(--primary); border: 1.5px solid var(--border); }
.btn-outline:hover { border-color: var(--primary); background: rgba(30,58,95,.05); }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-icon { padding: 7px; width: 32px; height: 32px; border-radius: 7px; }

.btn.loading .btn-text { display: none; }
.btn.loading .spinner-small { display: block; }
.btn .spinner-small { display: none; width: 18px; height: 18px; border: 2px solid rgba(255,255,255,.3); border-top-color: white; border-radius: 50%; animation: spin .7s linear infinite; }

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

/* ── Layout dashboard ─────────────────────────────────────────────── */

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

.sidebar {
  width: var(--sidebar-w);
  background: var(--primary);
  color: white;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow-y: auto;
  z-index: 100;
}

.sidebar-brand {
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,.1);
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar-brand i { font-size: 22px; color: var(--accent); }
.sidebar-brand span { font-size: 18px; font-weight: 800; }

.sidebar-nav { flex: 1; padding: 12px 8px; }
.nav-section { margin-bottom: 6px; }
.nav-section-label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 1.5px; color: rgba(255,255,255,.4); padding: 8px 12px 4px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background .15s;
  color: rgba(255,255,255,.75);
  font-size: 13px;
  font-weight: 500;
  position: relative;
  margin-bottom: 1px;
  user-select: none;
}
.nav-item:hover { background: rgba(255,255,255,.1); color: white; }
.nav-item.active { background: var(--accent); color: white; }
.nav-item i { width: 18px; text-align: center; font-size: 14px; flex-shrink: 0; }
.nav-badge { background: var(--danger); color: white; font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 10px; margin-left: auto; }

.sidebar-user {
  padding: 14px 16px;
  border-top: 1px solid rgba(255,255,255,.1);
  display: flex;
  align-items: center;
  gap: 10px;
}
.user-avatar { width: 34px; height: 34px; background: var(--accent); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; color: white; flex-shrink: 0; }
.user-name { font-size: 13px; font-weight: 600; color: white; }
.user-role { font-size: 11px; color: rgba(255,255,255,.55); }
.sidebar-user-logout { margin-left: auto; background: none; border: none; color: rgba(255,255,255,.5); cursor: pointer; padding: 4px; font-size: 14px; }
.sidebar-user-logout:hover { color: var(--danger); }

/* ── Main content ──────────────────────────────────────────────────── */

.main-content { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

.topbar {
  background: white;
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-shrink: 0;
  box-shadow: var(--shadow);
}

.topbar-left { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; }
.breadcrumb { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-muted); }
.breadcrumb-sep { color: var(--border); }
.breadcrumb-page { font-weight: 600; color: var(--text); }
#pageTitle { font-size: 16px; font-weight: 700; color: var(--primary); }

.topbar-icon { position: relative; width: 36px; height: 36px; background: var(--bg); border-radius: 8px; display: flex; align-items: center; justify-content: center; cursor: pointer; color: var(--text-muted); border: 1px solid var(--border); transition: background .15s; }
.topbar-icon:hover { background: var(--border); color: var(--text); }
.topbar-icon .badge { position: absolute; top: -4px; right: -4px; background: var(--danger); color: white; font-size: 9px; font-weight: 700; padding: 1px 4px; border-radius: 8px; }

.content-area { flex: 1; overflow-y: auto; padding: 24px; }

/* ── Cards & stats ─────────────────────────────────────────────────── */

.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }

.stat-card {
  background: white;
  border-radius: var(--radius);
  padding: 18px 20px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 14px;
}
.stat-icon { width: 44px; height: 44px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 18px; flex-shrink: 0; }
.stat-icon.blue   { background: rgba(30,58,95,.1);  color: var(--primary); }
.stat-icon.orange { background: rgba(249,115,22,.12); color: var(--accent); }
.stat-icon.green  { background: rgba(16,185,129,.12); color: var(--success); }
.stat-icon.red    { background: rgba(239,68,68,.12);  color: var(--danger); }
.stat-icon.yellow { background: rgba(245,158,11,.12); color: var(--warning); }
.stat-icon.gray   { background: rgba(100,116,139,.1); color: var(--text-muted); }
.stat-value { font-size: 26px; font-weight: 800; color: var(--text); line-height: 1; }
.stat-label { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.card {
  background: white;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.card-title { font-size: 15px; font-weight: 700; color: var(--text); display: flex; align-items: center; gap: 8px; }
.card-body { padding: 20px; }

/* ── Table ─────────────────────────────────────────────────────────── */

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

table { width: 100%; border-collapse: collapse; }
thead th { padding: 10px 14px; text-align: left; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); background: var(--bg); border-bottom: 1px solid var(--border); white-space: nowrap; }
tbody tr { border-bottom: 1px solid var(--border); transition: background .1s; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: rgba(30,58,95,.03); }
tbody td { padding: 11px 14px; font-size: 13px; color: var(--text); }

/* ── Badges / statuts ──────────────────────────────────────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.badge-actif      { background: rgba(16,185,129,.12); color: #047857; }
.badge-pause      { background: rgba(245,158,11,.12); color: #92400e; }
.badge-termine    { background: rgba(100,116,139,.12); color: #475569; }
.badge-annule     { background: rgba(239,68,68,.12); color: #b91c1c; }
.badge-disponible { background: rgba(16,185,129,.12); color: #047857; }
.badge-assigne    { background: rgba(59,130,246,.12); color: #1d4ed8; }
.badge-conge      { background: rgba(245,158,11,.12); color: #92400e; }
.badge-inactif    { background: rgba(100,116,139,.12); color: #475569; }
.badge-pending    { background: rgba(245,158,11,.12); color: #92400e; }
.badge-in_progress{ background: rgba(59,130,246,.12); color: #1d4ed8; }
.badge-completed  { background: rgba(16,185,129,.12); color: #047857; }
.badge-cancelled  { background: rgba(100,116,139,.12); color: #475569; }
.badge-low        { background: rgba(100,116,139,.12); color: #475569; }
.badge-medium     { background: rgba(245,158,11,.12); color: #92400e; }
.badge-high       { background: rgba(249,115,22,.12); color: #c2410c; }
.badge-critical   { background: rgba(239,68,68,.12); color: #b91c1c; }

/* ── Filtres & toolbar ─────────────────────────────────────────────── */

.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.search-input { padding: 8px 12px 8px 34px; border: 1.5px solid var(--border); border-radius: 8px; font-size: 13px; color: var(--text); background: white; width: 220px; transition: border-color .2s; }
.search-input:focus { outline: none; border-color: var(--primary-light); }
.search-wrap { position: relative; }
.search-wrap i { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text-muted); font-size: 13px; }

select.filter-select { padding: 8px 28px 8px 10px; border: 1.5px solid var(--border); border-radius: 8px; font-size: 13px; color: var(--text); background: white; cursor: pointer; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%2364748b'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; }
select.filter-select:focus { outline: none; border-color: var(--primary-light); }

/* ── Modal ─────────────────────────────────────────────────────────── */

.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal { background: white; border-radius: 14px; width: 100%; max-width: 560px; max-height: 90vh; display: flex; flex-direction: column; box-shadow: var(--shadow-lg); }
.modal-lg { max-width: 720px; }
.modal-header { padding: 18px 22px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-header h3 { font-size: 16px; font-weight: 700; color: var(--primary); }
.modal-close { background: none; border: none; font-size: 18px; color: var(--text-muted); cursor: pointer; padding: 4px; }
.modal-close:hover { color: var(--text); }
.modal-body { padding: 22px; overflow-y: auto; flex: 1; }
.modal-footer { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

/* ── Form inside modal ─────────────────────────────────────────────── */

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 5px; }
.form-control { width: 100%; padding: 9px 12px; border: 1.5px solid var(--border); border-radius: 8px; font-size: 13px; color: var(--text); background: white; transition: border-color .2s; }
.form-control:focus { outline: none; border-color: var(--primary-light); box-shadow: 0 0 0 3px rgba(45,90,142,.1); }
textarea.form-control { resize: vertical; min-height: 80px; }

/* ── Progress bar ──────────────────────────────────────────────────── */

.progress-bar { background: var(--border); border-radius: 4px; height: 6px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 4px; background: linear-gradient(90deg, var(--primary-light), var(--accent)); transition: width .3s; }

/* ── Empty state ───────────────────────────────────────────────────── */

.empty-state { text-align: center; padding: 48px 24px; color: var(--text-muted); }
.empty-state i { font-size: 40px; margin-bottom: 12px; opacity: .4; display: block; }
.empty-state p { font-size: 14px; }

/* ── Charts ─────────────────────────────────────────────────────────── */

.chart-container { position: relative; height: 300px; width: 100%; }
.chart-container-sm { position: relative; height: 200px; width: 100%; }
.chart-wrapper { display: flex; align-items: center; justify-content: center; height: 100%; padding: 10px; }
.chart-wrapper canvas { max-height: 260px; max-width: 100%; }

/* Sparkline */
.spark-line { display: inline-flex; align-items: center; height: 8px; width: 90px; }
.spark-line canvas { height: 100%; width: 100%; }

/* ── Data cards with sparklines ─────────────────────────────────────── */

.data-card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; margin-bottom: 24px; }
.data-card { background: white; border-radius: var(--radius); padding: 18px 20px; border: 1px solid var(--border); box-shadow: var(--shadow); display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.data-card-value { font-size: 24px; font-weight: 700; color: var(--text); }
.data-card-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.data-card-chart { flex-shrink: 0; }

/* ─── Sidebar overlay (mobile) ──────────────────────────────────────── */
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 99; }

/* ── Responsive ────────────────────────────────────────────────────── */

@media (max-width: 900px) {
  .login-sidebar { display: none; }
  .sidebar {
    position: fixed;
    left: -280px;
    top: 0;
    bottom: 0;
    transition: left .25s;
    z-index: 100;
  }
  .sidebar.active { left: 0; }
  .sidebar-overlay { display: block; }
  .sidebar-overlay.active { display: block; }
  .form-row { grid-template-columns: 1fr; }
}
