@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

:root {
  --bg-body: #f0f2f5;
  --bg-white: #ffffff;
  --bg-sidebar: #1e293b;
  --bg-sidebar-hover: rgba(255,255,255,0.08);
  --bg-sidebar-active: rgba(59,130,246,0.18);
  --border: #e2e8f0;
  --border-light: #f1f5f9;
  --text-dark: #0f172a;
  --text-body: #334155;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --text-white: #ffffff;
  --accent: #2563eb;
  --accent-light: #dbeafe;
  --accent-hover: #1d4ed8;
  --emerald: #059669;
  --emerald-light: #d1fae5;
  --amber: #d97706;
  --amber-light: #fef3c7;
  --red: #dc2626;
  --red-light: #fee2e2;
  --purple: #7c3aed;
  --purple-light: #ede9fe;
  --cyan: #0891b2;
  --cyan-light: #cffafe;
  --gradient-brand: linear-gradient(135deg, #2563eb 0%, #7c3aed 100%);
  --gradient-success: linear-gradient(135deg, #059669 0%, #0891b2 100%);
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 10px 30px rgba(0,0,0,0.1);
  --shadow-card: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-xs: 6px;
  --transition: all 0.25s ease;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-body);
  color: var(--text-body);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ===== SIDEBAR ===== */
.sidebar {
  position: fixed;
  left: 0; top: 0;
  width: 260px;
  height: 100vh;
  background: var(--bg-sidebar);
  display: flex;
  flex-direction: column;
  z-index: 100;
  box-shadow: 2px 0 8px rgba(0,0,0,0.1);
}

.sidebar-brand {
  padding: 22px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar-brand .logo-icon {
  width: 40px; height: 40px;
  background: var(--gradient-brand);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: #fff;
}

.sidebar-brand h1 { font-size: 15px; font-weight: 700; color: #fff; }
.sidebar-brand span { font-size: 11px; color: var(--text-muted); display: block; margin-top: 1px; }

.sidebar-nav { flex: 1; padding: 14px 10px; overflow-y: auto; }

.nav-section { margin-bottom: 18px; }
.nav-section-title {
  font-size: 10px; text-transform: uppercase; letter-spacing: 1.5px;
  color: rgba(255,255,255,0.35); padding: 0 12px; margin-bottom: 6px; font-weight: 600;
}

.nav-link {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 12px; border-radius: var(--radius-sm);
  color: rgba(255,255,255,0.65); text-decoration: none;
  font-size: 13px; font-weight: 500; transition: var(--transition);
  position: relative;
}
.nav-link:hover { background: var(--bg-sidebar-hover); color: #fff; }
.nav-link.active { background: var(--bg-sidebar-active); color: #60a5fa; }
.nav-link.active::before {
  content:''; position:absolute; left:0; top:50%; transform:translateY(-50%);
  width:3px; height:18px; background:#3b82f6; border-radius:0 3px 3px 0;
}
.nav-link i { width:18px; text-align:center; font-size:14px; }

.sidebar-user {
  padding: 14px 18px;
  border-top: 1px solid rgba(255,255,255,0.08);
  display: flex; align-items: center; gap: 10px;
}
.user-avatar {
  width: 34px; height: 34px; border-radius: 8px;
  background: var(--gradient-brand);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; color: #fff;
}
.user-info .name { font-size: 12px; font-weight: 600; color: #fff; }
.user-info .role { font-size: 10px; color: var(--text-muted); }

/* ===== MAIN ===== */
.main-content {
  margin-left: 260px;
  padding: 24px 28px;
  min-height: 100vh;
}

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px;
}
.topbar-left h2 { font-size: 22px; font-weight: 700; color: var(--text-dark); letter-spacing: -0.3px; }
.topbar-left p { font-size: 13px; color: var(--text-secondary); margin-top: 2px; }
.topbar-right { display: flex; align-items: center; gap: 10px; }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 18px; border: none; border-radius: var(--radius-sm);
  font-family: 'Inter', sans-serif; font-size: 13px; font-weight: 600;
  cursor: pointer; transition: var(--transition); text-decoration: none;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn-secondary { background: var(--bg-white); color: var(--text-body); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--bg-body); }
.btn-success { background: var(--emerald); color: #fff; }
.btn-success:hover { background: #047857; transform: translateY(-1px); }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-icon { padding: 8px; width: 36px; height: 36px; justify-content: center; }

/* ===== CARDS ===== */
.card {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  transition: var(--transition);
}
.card:hover { box-shadow: var(--shadow-md); }

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

/* ===== STAT CARDS ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px; margin-bottom: 22px;
}

.stat-card {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-card);
  transition: var(--transition);
  position: relative; overflow: hidden;
}
.stat-card::before {
  content:''; position:absolute; top:0; left:0;
  width:100%; height:3px;
}
.stat-card.blue::before { background: var(--accent); }
.stat-card.green::before { background: var(--emerald); }
.stat-card.amber::before { background: var(--amber); }
.stat-card.purple::before { background: var(--purple); }
.stat-card.cyan::before { background: var(--cyan); }

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

.stat-icon {
  width: 42px; height: 42px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 17px; margin-bottom: 12px;
}
.stat-card.blue .stat-icon { background: var(--accent-light); color: var(--accent); }
.stat-card.green .stat-icon { background: var(--emerald-light); color: var(--emerald); }
.stat-card.amber .stat-icon { background: var(--amber-light); color: var(--amber); }
.stat-card.purple .stat-icon { background: var(--purple-light); color: var(--purple); }
.stat-card.cyan .stat-icon { background: var(--cyan-light); color: var(--cyan); }

.stat-value { font-size: 26px; font-weight: 800; color: var(--text-dark); letter-spacing: -0.5px; }
.stat-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-top: 2px; }
.stat-change { font-size: 11px; margin-top: 6px; font-weight: 600; }
.stat-change.up { color: var(--emerald); }
.stat-change.down { color: var(--red); }

/* ===== GRID ===== */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-bottom: 22px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 18px; margin-bottom: 22px; }

/* ===== TABLE ===== */
.table-wrapper { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; }
thead th {
  padding: 10px 14px; text-align: left; font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.8px;
  color: var(--text-muted); border-bottom: 2px solid var(--border);
  background: #f8fafc; white-space: nowrap;
}
tbody td {
  padding: 10px 14px; font-size: 13px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-body);
}
tbody tr { transition: var(--transition); }
tbody tr:hover { background: #f8fafc; }

/* ===== PROGRESS BAR ===== */
.progress-bar {
  height: 8px; background: #e2e8f0; border-radius: 4px; overflow: hidden;
}
.progress-bar .fill {
  height: 100%; border-radius: 4px; transition: width 0.8s ease;
}
.fill.blue { background: var(--accent); }
.fill.green { background: var(--emerald); }
.fill.amber { background: var(--amber); }
.fill.red { background: var(--red); }
.fill.purple { background: var(--purple); }
.fill.cyan { background: var(--cyan); }

.progress-lg { height: 12px; border-radius: 6px; }
.progress-lg .fill { border-radius: 6px; }

/* ===== BADGES ===== */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 600;
}
.badge-blue { background: var(--accent-light); color: var(--accent); }
.badge-green { background: var(--emerald-light); color: var(--emerald); }
.badge-amber { background: var(--amber-light); color: var(--amber); }
.badge-red { background: var(--red-light); color: var(--red); }
.badge-purple { background: var(--purple-light); color: var(--purple); }

/* ===== FORM ===== */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block; font-size: 12px; font-weight: 600;
  color: var(--text-secondary); margin-bottom: 5px;
}
.form-control {
  width: 100%; padding: 9px 12px;
  background: var(--bg-white);
  border: 1px solid var(--border); border-radius: var(--radius-xs);
  color: var(--text-dark); font-family: 'Inter', sans-serif; font-size: 13px;
  transition: var(--transition);
}
.form-control:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
}
.form-control::placeholder { color: var(--text-muted); }

select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2364748b' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; padding-right: 30px;
}
textarea.form-control { resize: vertical; min-height: 70px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(15,23,42,0.5);
  backdrop-filter: blur(4px); z-index: 1000;
  display: none; align-items: center; justify-content: center;
}
.modal-overlay.show { display: flex; }
.modal {
  background: var(--bg-white); border-radius: var(--radius);
  width: 90%; max-width: 600px; max-height: 85vh; overflow-y: auto;
  box-shadow: var(--shadow-lg); animation: modalIn 0.25s ease;
}
.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(--text-dark); }
.modal-close { background:none; border:none; color:var(--text-muted); font-size:18px; cursor:pointer; }
.modal-body { padding: 22px; }
.modal-footer { padding:14px 22px; border-top:1px solid var(--border); display:flex; justify-content:flex-end; gap:8px; }

/* ===== TOAST ===== */
.toast-container { position:fixed; top:16px; right:16px; z-index:2000; display:flex; flex-direction:column; gap:6px; }
.toast {
  background: var(--bg-white); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px 16px;
  display:flex; align-items:center; gap:8px;
  min-width:280px; box-shadow: var(--shadow-lg);
  animation: slideIn 0.3s ease;
}
.toast.success { border-left: 3px solid var(--emerald); }
.toast.error { border-left: 3px solid var(--red); }
.toast.info { border-left: 3px solid var(--accent); }
.toast-msg { font-size: 13px; flex: 1; color: var(--text-body); }

/* ===== LOGIN ===== */
.login-page {
  min-height: 100vh; display: flex;
  background: linear-gradient(135deg, #f0f4ff 0%, #e8f0fe 50%, #f0f2f5 100%);
}
.login-left {
  flex: 1; display: flex; align-items: center; justify-content: center;
  background: var(--bg-sidebar);
  color: #fff; padding: 40px;
}
.login-left-inner { max-width: 400px; }
.login-left h2 { font-size: 28px; font-weight: 800; margin-bottom: 12px; }
.login-left p { font-size: 14px; color: rgba(255,255,255,0.7); line-height: 1.7; }
.login-left .features { margin-top: 28px; }
.login-left .features li {
  display: flex; align-items: center; gap: 10px;
  font-size: 13px; color: rgba(255,255,255,0.8);
  margin-bottom: 12px;
}
.login-left .features li i { color: #60a5fa; width: 20px; }

.login-right {
  flex: 1; display: flex; align-items: center; justify-content: center; padding: 40px;
}
.login-card {
  width: 100%; max-width: 400px; padding: 36px;
  background: var(--bg-white); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
}
.login-card .logo-block { text-align: center; margin-bottom: 28px; }
.login-card .logo-block .icon {
  width: 56px; height: 56px; background: var(--gradient-brand);
  border-radius: 14px; display: inline-flex; align-items: center; justify-content: center;
  font-size: 24px; color: #fff; margin-bottom: 14px;
}
.login-card .logo-block h2 { font-size: 20px; font-weight: 700; color: var(--text-dark); }
.login-card .logo-block p { font-size: 13px; color: var(--text-secondary); margin-top: 4px; }

/* ===== CHART ===== */
.chart-container { width: 100%; height: 260px; position: relative; }

/* ===== DOMAIN COLORS ===== */
.domain-gc-station { border-left: 3px solid var(--accent); }
.domain-gc-reservoir { border-left: 3px solid var(--purple); }
.domain-terrassement { border-left: 3px solid var(--amber); }
.domain-conduite { border-left: 3px solid var(--emerald); }
.domain-equipements { border-left: 3px solid var(--cyan); }
.domain-installation { border-left: 3px solid var(--red); }

/* ===== ANIMATIONS ===== */
@keyframes modalIn { from { transform:scale(0.95);opacity:0; } to { transform:scale(1);opacity:1; } }
@keyframes slideIn { from { transform:translateX(80px);opacity:0; } to { transform:translateX(0);opacity:1; } }
@keyframes fadeUp { from { transform:translateY(12px);opacity:0; } to { transform:translateY(0);opacity:1; } }
.fade-up { animation: fadeUp 0.4s ease both; }

/* ===== RESPONSIVE ===== */
@media (max-width: 1024px) {
  .sidebar { transform:translateX(-100%); }
  .sidebar.open { transform:translateX(0); }
  .main-content { margin-left:0; padding: 16px; }
  .grid-2,.grid-3,.form-row,.form-row-3 { grid-template-columns:1fr; }
  .login-page { flex-direction: column; }
  .login-left { display:none; }
  .topbar { padding-left: 52px; flex-direction: column; align-items: flex-start; gap: 10px; }
  .topbar-right { width: 100%; justify-content: flex-start; }
}

/* Hamburger Button for Mobile Navigation */
.mobile-toggle {
  display: none;
  position: fixed;
  top: 18px;
  left: 16px;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: var(--bg-sidebar);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.1);
  align-items: center;
  justify-content: center;
  font-size: 16px;
  cursor: pointer;
  z-index: 1001;
  box-shadow: var(--shadow-md);
  transition: var(--transition);
}
.mobile-toggle:hover {
  background: var(--accent);
}
@media (max-width: 1024px) {
  .mobile-toggle {
    display: flex;
  }
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width:5px; }
::-webkit-scrollbar-track { background:transparent; }
::-webkit-scrollbar-thumb { background:#cbd5e1; border-radius:3px; }

/* ===== UTILS ===== */
.text-accent { color: var(--accent); }
.text-green { color: var(--emerald); }
.text-amber { color: var(--amber); }
.text-red { color: var(--red); }
.text-purple { color: var(--purple); }
.text-cyan { color: var(--cyan); }
.text-muted { color: var(--text-muted); }
.text-dark { color: var(--text-dark); }
.text-center { text-align:center; }
.text-right { text-align:right; }
.fw-700 { font-weight:700; }
.fw-800 { font-weight:800; }
.mt-1 { margin-top:8px; }
.mt-2 { margin-top:16px; }
.mb-2 { margin-bottom:16px; }
.mb-3 { margin-bottom:22px; }
.flex { display:flex; }
.items-center { align-items:center; }
.justify-between { justify-content:space-between; }
.gap-sm { gap:8px; }
.hidden { display:none !important; }
