/* ============================================================
   APPLICATION SUIVI CHANTIER — PCR-CI / LOT 5 TCHOLOGO
   Design system : moderne, professionnel, responsive
   ============================================================ */

:root {
  --c-primary:        #1F4E79;
  --c-primary-light:  #2E75B6;
  --c-primary-dark:   #0F2A47;
  --c-accent:         #F2B33A;
  --c-success:        #18A957;
  --c-warning:        #E89B00;
  --c-danger:         #C0392B;
  --c-info:           #00A8CC;
  --c-bg:             #F4F6FA;
  --c-bg-2:           #FFFFFF;
  --c-bg-sidebar:     #0F2A47;
  --c-sidebar-text:   #C9D6E2;
  --c-sidebar-active: #2E75B6;
  --c-border:         #E0E5EC;
  --c-text:           #2C3E50;
  --c-text-light:     #7F8C9B;
  --c-shadow:         0 2px 8px rgba(0,0,0,0.06);
  --c-shadow-lg:      0 8px 24px rgba(0,0,0,0.12);
  --r-sm:             4px;
  --r-md:             8px;
  --r-lg:             12px;
  --r-xl:             16px;
  --t-fast:           0.15s ease;
  --t-med:            0.3s ease;
  --font:             -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  font-size: 14px;
  color: var(--c-text);
  background: var(--c-bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ========== UTILITAIRES ========== */
.hidden { display: none !important; }
.fade-in { animation: fadeIn 0.3s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.text-success { color: var(--c-success); }
.text-warning { color: var(--c-warning); }
.text-danger  { color: var(--c-danger); }
.text-info    { color: var(--c-info); }
.text-muted   { color: var(--c-text-light); }
.text-bold    { font-weight: 600; }
.text-right   { text-align: right; }
.text-center  { text-align: center; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-1 { flex: 1; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }

/* ========== LOGIN ========== */
.auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--c-primary) 0%, var(--c-primary-dark) 100%);
  padding: 24px;
}
.auth-card {
  width: 100%;
  max-width: 440px;
  background: white;
  border-radius: var(--r-xl);
  padding: 40px;
  box-shadow: var(--c-shadow-lg);
}
.auth-card h1 {
  color: var(--c-primary);
  font-size: 24px;
  margin-bottom: 4px;
}
.auth-card .subtitle {
  color: var(--c-text-light);
  margin-bottom: 32px;
  font-size: 13px;
}
.auth-card .form-group { margin-bottom: 18px; }
.auth-card label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--c-text);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.auth-card input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  font-size: 14px;
  transition: all var(--t-fast);
  font-family: var(--font);
}
.auth-card input:focus {
  outline: none;
  border-color: var(--c-primary-light);
  box-shadow: 0 0 0 3px rgba(46,117,182,0.15);
}
.auth-card .auth-btn {
  width: 100%;
  padding: 13px;
  border: none;
  background: var(--c-primary);
  color: white;
  border-radius: var(--r-md);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--t-fast);
  letter-spacing: 0.5px;
  text-transform: uppercase;
}
.auth-card .auth-btn:hover { background: var(--c-primary-light); }
.auth-card .auth-btn:disabled { background: var(--c-text-light); cursor: not-allowed; }
.auth-toggle {
  text-align: center;
  margin-top: 16px;
  font-size: 13px;
}
.auth-toggle a {
  color: var(--c-primary-light);
  text-decoration: none;
  font-weight: 500;
  cursor: pointer;
}
.auth-toggle a:hover { text-decoration: underline; }
.auth-error {
  background: #FEE;
  color: var(--c-danger);
  padding: 10px 14px;
  border-radius: var(--r-md);
  font-size: 13px;
  margin-bottom: 16px;
  border-left: 3px solid var(--c-danger);
}
.auth-info {
  background: #E8F4FD;
  color: var(--c-primary);
  padding: 10px 14px;
  border-radius: var(--r-md);
  font-size: 13px;
  margin-bottom: 16px;
  border-left: 3px solid var(--c-primary-light);
}

/* ========== LAYOUT PRINCIPAL ========== */
.app-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

/* SIDEBAR */
.sidebar {
  background: var(--c-bg-sidebar);
  color: var(--c-sidebar-text);
  padding: 0;
  overflow-y: auto;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar-header {
  padding: 24px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar-header h2 {
  color: white;
  font-size: 16px;
  margin-bottom: 4px;
}
.sidebar-header .sub {
  font-size: 11px;
  color: var(--c-sidebar-text);
  opacity: 0.7;
}
.sidebar-nav { padding: 12px 0; }
.sidebar-section {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: rgba(255,255,255,0.4);
  padding: 12px 20px 6px;
  margin-top: 8px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 20px;
  color: var(--c-sidebar-text);
  cursor: pointer;
  font-size: 13px;
  transition: all var(--t-fast);
  border-left: 3px solid transparent;
}
.nav-item:hover {
  background: rgba(255,255,255,0.05);
  color: white;
}
.nav-item.active {
  background: rgba(46,117,182,0.2);
  color: white;
  border-left-color: var(--c-primary-light);
}
.nav-icon { font-size: 16px; width: 20px; text-align: center; }

/* MAIN */
.main {
  background: var(--c-bg);
  overflow-x: hidden;
}
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 32px;
  background: white;
  border-bottom: 1px solid var(--c-border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-left h1 { font-size: 18px; color: var(--c-primary); }
.topbar-left .breadcrumb { font-size: 12px; color: var(--c-text-light); margin-top: 2px; }
.topbar-right { display: flex; align-items: center; gap: 16px; }
.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 14px;
  background: var(--c-bg);
  border-radius: 20px;
  font-size: 13px;
}
.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--c-primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 13px;
}
.role-badge {
  display: inline-block;
  padding: 2px 8px;
  background: var(--c-primary-light);
  color: white;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.5px;
}
.btn-logout {
  background: transparent;
  border: 1px solid var(--c-border);
  color: var(--c-text-light);
  padding: 6px 12px;
  border-radius: var(--r-md);
  font-size: 12px;
  cursor: pointer;
  transition: all var(--t-fast);
}
.btn-logout:hover { background: var(--c-danger); color: white; border-color: var(--c-danger); }

/* CONTENT */
.content { padding: 32px; }
.section-title {
  font-size: 20px;
  color: var(--c-primary);
  margin-bottom: 6px;
}
.section-subtitle {
  font-size: 13px;
  color: var(--c-text-light);
  margin-bottom: 24px;
}

/* CARDS */
.card {
  background: white;
  border-radius: var(--r-lg);
  padding: 20px;
  box-shadow: var(--c-shadow);
  margin-bottom: 20px;
}
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--c-border);
}
.card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--c-primary);
}

/* KPI CARDS */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.kpi-card {
  background: white;
  border-radius: var(--r-lg);
  padding: 20px;
  box-shadow: var(--c-shadow);
  position: relative;
  overflow: hidden;
}
.kpi-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 4px;
  height: 100%;
  background: var(--c-primary);
}
.kpi-card.success::before { background: var(--c-success); }
.kpi-card.warning::before { background: var(--c-warning); }
.kpi-card.danger::before  { background: var(--c-danger); }
.kpi-card.info::before    { background: var(--c-info); }

.kpi-label {
  font-size: 11px;
  text-transform: uppercase;
  color: var(--c-text-light);
  letter-spacing: 1px;
  margin-bottom: 8px;
  font-weight: 600;
}
.kpi-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--c-text);
  line-height: 1.2;
}
.kpi-value-sm { font-size: 18px; }
.kpi-sub {
  font-size: 12px;
  color: var(--c-text-light);
  margin-top: 4px;
}

/* BARS / PROGRESS */
.progress {
  height: 8px;
  background: var(--c-border);
  border-radius: 4px;
  overflow: hidden;
  margin-top: 8px;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--c-primary-light), var(--c-primary));
  transition: width var(--t-med);
}
.progress-fill.success { background: linear-gradient(90deg, var(--c-success), #0F8043); }
.progress-fill.warning { background: linear-gradient(90deg, var(--c-warning), #B07300); }
.progress-fill.danger  { background: linear-gradient(90deg, var(--c-danger), #8B2A1F); }

/* TABLES */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--r-md);
  border: 1px solid var(--c-border);
}
table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  background: white;
}
table.data-table thead th {
  background: var(--c-primary);
  color: white;
  padding: 10px 12px;
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
}
table.data-table tbody td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--c-border);
}
table.data-table tbody tr:hover { background: #FAFBFD; }
table.data-table tbody tr:last-child td { border-bottom: none; }
table.data-table tfoot td {
  background: #EEF3F8;
  font-weight: 600;
  padding: 10px 12px;
  border-top: 2px solid var(--c-primary);
}
.td-num { text-align: right; font-variant-numeric: tabular-nums; }
.td-status { white-space: nowrap; }

/* STATUS PILLS */
.pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.pill-success { background: #E1F4EA; color: var(--c-success); }
.pill-warning { background: #FFF4E0; color: var(--c-warning); }
.pill-danger  { background: #FCE6E2; color: var(--c-danger); }
.pill-info    { background: #E0F4F8; color: var(--c-info); }
.pill-muted   { background: #E9EDF1; color: var(--c-text-light); }
.pill-primary { background: #E1EDF7; color: var(--c-primary); }

/* BUTTONS */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: none;
  border-radius: var(--r-md);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--t-fast);
  font-family: var(--font);
}
.btn-primary { background: var(--c-primary); color: white; }
.btn-primary:hover { background: var(--c-primary-light); }
.btn-success { background: var(--c-success); color: white; }
.btn-success:hover { filter: brightness(1.08); }
.btn-danger  { background: var(--c-danger); color: white; }
.btn-danger:hover { filter: brightness(1.08); }
.btn-warning { background: var(--c-warning); color: white; }
.btn-secondary { background: white; color: var(--c-primary); border: 1px solid var(--c-primary); }
.btn-secondary:hover { background: var(--c-primary); color: white; }
.btn-ghost { background: transparent; color: var(--c-text-light); padding: 6px 10px; }
.btn-ghost:hover { background: var(--c-bg); color: var(--c-text); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-xs { padding: 3px 8px; font-size: 11px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* FORMS */
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 14px;
}
.form-row.full { grid-template-columns: 1fr; }
.form-row.three { grid-template-columns: 1fr 1fr 1fr; }
.form-field {
  display: flex;
  flex-direction: column;
}
.form-field label {
  font-size: 11px;
  font-weight: 600;
  color: var(--c-text);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.form-field input, .form-field select, .form-field textarea {
  padding: 8px 10px;
  border: 1px solid var(--c-border);
  border-radius: var(--r-sm);
  font-size: 13px;
  font-family: var(--font);
  background: white;
}
.form-field input:focus, .form-field select:focus, .form-field textarea:focus {
  outline: none;
  border-color: var(--c-primary-light);
  box-shadow: 0 0 0 2px rgba(46,117,182,0.15);
}
.form-field textarea { resize: vertical; min-height: 80px; }

/* MODALS */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 42, 71, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 24px;
  backdrop-filter: blur(2px);
}
.modal {
  background: white;
  border-radius: var(--r-xl);
  max-width: 720px;
  width: 100%;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--c-shadow-lg);
}
.modal.wide  { max-width: 960px; }
.modal-header {
  padding: 18px 24px;
  background: var(--c-primary);
  color: white;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.modal-header h3 { font-size: 16px; font-weight: 600; }
.modal-close {
  background: rgba(255,255,255,0.15);
  border: none;
  color: white;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 16px;
}
.modal-close:hover { background: rgba(255,255,255,0.25); }
.modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}
.modal-footer {
  padding: 14px 24px;
  border-top: 1px solid var(--c-border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  background: #FAFBFD;
}

/* TOAST */
.toast-container {
  position: fixed;
  top: 80px;
  right: 24px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  background: white;
  padding: 12px 18px;
  border-radius: var(--r-md);
  box-shadow: var(--c-shadow-lg);
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 280px;
  border-left: 4px solid var(--c-primary);
  animation: toastIn 0.3s ease;
}
.toast.success { border-left-color: var(--c-success); }
.toast.warning { border-left-color: var(--c-warning); }
.toast.danger  { border-left-color: var(--c-danger); }
@keyframes toastIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }

/* LOADER */
.loader {
  display: inline-block;
  width: 18px; height: 18px;
  border: 2px solid var(--c-border);
  border-top-color: var(--c-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.loader-lg { width: 40px; height: 40px; border-width: 3px; }
@keyframes spin { to { transform: rotate(360deg); } }

.center-loader {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px;
  color: var(--c-text-light);
}

/* FILTERS BAR */
.filter-bar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  background: white;
  padding: 12px 16px;
  border-radius: var(--r-md);
  margin-bottom: 16px;
  box-shadow: var(--c-shadow);
}
.filter-bar input, .filter-bar select {
  padding: 6px 10px;
  border: 1px solid var(--c-border);
  border-radius: var(--r-sm);
  font-size: 13px;
}
.filter-bar .filter-label {
  font-size: 11px;
  color: var(--c-text-light);
  font-weight: 600;
  text-transform: uppercase;
}

/* GRID 2-3 COL */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
@media (max-width: 900px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

/* CHARTS CONTAINER */
.chart-box { position: relative; height: 280px; }

/* PHOTO GALLERY */
.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}
.photo-tile {
  position: relative;
  aspect-ratio: 4/3;
  border-radius: var(--r-md);
  overflow: hidden;
  background: var(--c-border);
  cursor: pointer;
  box-shadow: var(--c-shadow);
  transition: transform var(--t-fast);
}
.photo-tile:hover { transform: scale(1.02); }
.photo-tile img { width: 100%; height: 100%; object-fit: cover; }
.photo-tile .caption {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  padding: 8px 10px;
  background: linear-gradient(transparent, rgba(0,0,0,0.7));
  color: white;
  font-size: 11px;
}

/* ALERTS SECTION */
.alert-list { display: flex; flex-direction: column; gap: 10px; }
.alert-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: white;
  border-left: 3px solid var(--c-warning);
  border-radius: var(--r-md);
  box-shadow: var(--c-shadow);
}
.alert-item.danger { border-left-color: var(--c-danger); }
.alert-item.info  { border-left-color: var(--c-info); }
.alert-icon { font-size: 18px; }
.alert-content { flex: 1; }
.alert-content .title { font-weight: 600; font-size: 13px; }
.alert-content .desc  { font-size: 12px; color: var(--c-text-light); }

/* PRINT-FRIENDLY REPORTS */
@media print {
  .sidebar, .topbar, .btn { display: none !important; }
  .content { padding: 0; }
  .card { box-shadow: none; border: 1px solid #ccc; }
}

/* RESPONSIVE */
@media (max-width: 768px) {
  .app-layout { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    left: -280px;
    transition: left var(--t-med);
    z-index: 50;
  }
  .sidebar.open { left: 0; }
  .topbar { padding: 12px 16px; }
  .content { padding: 16px; }
  .form-row { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
}
.menu-toggle {
  display: none;
  background: transparent;
  border: none;
  font-size: 20px;
  cursor: pointer;
}
@media (max-width: 768px) {
  .menu-toggle { display: inline-block; }
}

/* DASHBOARD HERO */
.hero {
  background: linear-gradient(135deg, var(--c-primary) 0%, var(--c-primary-light) 100%);
  color: white;
  padding: 24px 28px;
  border-radius: var(--r-xl);
  margin-bottom: 24px;
  box-shadow: var(--c-shadow-lg);
}
.hero h2 { font-size: 22px; margin-bottom: 8px; }
.hero p  { opacity: 0.85; font-size: 13px; }
.hero-stats { display: flex; gap: 32px; margin-top: 16px; flex-wrap: wrap; }
.hero-stat .label { font-size: 11px; opacity: 0.7; text-transform: uppercase; letter-spacing: 1px; }
.hero-stat .value { font-size: 22px; font-weight: 700; margin-top: 2px; }
