:root {
  --primary: #2b7095;
  --secondary: #1a4d69;
  --accent: #2ecc71;
  --danger: #e74c3c;
  --bg-body: #f4f7f9;
  --bg-card: #ffffff;
  --text-main: #2c3e50;
  --text-muted: #7f8c8d;
  --sidebar-width: 260px;
  
  --bg-light: #f8f9fa;
  --border-color: #ccc;
  --border-light: #eee;
  --bg-danger-light: #fff5f5;
  --bg-purple-light: #f9f2fd;
  --bg-warning-light: #fffdf7;
  --input-bg: #ffffff;
}

body.dark-mode {
  color-scheme: dark; /* Force les calendriers natifs en sombre */
  --bg-body: #121212;
  --bg-card: #1e1e1e;
  --text-main: #e0e0e0;
  --text-muted: #aaaaaa;
  
  --bg-light: #2a2a2a;
  --border-color: #444444;
  --border-light: #333333;
  --bg-danger-light: #3a1c1c;
  --bg-purple-light: #2d1b38;
  --bg-warning-light: #332b18;
  --input-bg: #2c2c2c;
}

body.dark-mode input, body.dark-mode select, body.dark-mode textarea { background: var(--input-bg) !important; color: var(--text-main) !important; border-color: var(--border-color) !important; }
body.dark-mode div[style*="background:#f8f9fa"], body.dark-mode div[style*="background: #f8f9fa"] { background: var(--bg-light) !important; }
body.dark-mode div[style*="background:#fff5f5"] { background: var(--bg-danger-light) !important; }
body.dark-mode div[style*="background:#f9f2fd"] { background: var(--bg-purple-light) !important; }
body.dark-mode div[style*="background:#fffdf7"], body.dark-mode div[style*="background: #fffdf7"] { background: var(--bg-warning-light) !important; }
body.dark-mode tr { border-bottom-color: var(--border-light) !important; }

body { margin: 0; font-family: 'Segoe UI', Roboto, sans-serif; background: var(--bg-body); color: var(--text-main); transition: background-color 0.3s ease, color 0.3s ease; }
h1, h2, h3, h4, h5, h6 { text-transform: uppercase !important; color: var(--secondary); letter-spacing: 1px; }
body.dark-mode h1, body.dark-mode h2, body.dark-mode h3, body.dark-mode h4 { color: #5da9d4; }

.btn { padding: 12px 20px; border: none; border-radius: 8px; font-weight: bold; cursor: pointer; transition: all 0.3s ease; text-transform: uppercase; flex-shrink: 0; box-sizing: border-box; }
.btn-primary { background: var(--primary); color: white; width: 100%; }
.btn-primary:hover { background: var(--secondary); }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #c0392b; }

.auth-container { height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, var(--primary), var(--secondary)); }
.auth-card { background: var(--bg-card); padding: 40px; border-radius: 15px; box-shadow: 0 10px 25px rgba(0,0,0,0.3); width: 100%; max-width: 400px; text-align: center; }
.auth-logo { width: 140px; margin-bottom: 20px; }
.input-group { position: relative; margin-bottom: 20px; }
.input-group i { position: absolute; left: 15px; top: 14px; color: var(--text-muted); }
.input-group input { width: 100%; padding: 12px 15px 12px 45px; border: 1px solid var(--border-color); border-radius: 8px; box-sizing: border-box; font-size: 16px; background: var(--input-bg); color: var(--text-main); }

#main-interface { display: flex; min-height: 100vh; overflow-x: hidden; }
.sidebar { width: var(--sidebar-width); background: #2c3e50; color: white; display: flex; flex-direction: column; position: fixed; height: 100vh; z-index: 1000; transition: transform 0.3s ease; }
.sidebar-header { padding: 20px; text-align: center; border-bottom: 1px solid rgba(255,255,255,0.1); }
.sidebar-logo { width: 90%; max-width: 160px; height: auto; display: block; margin: 0 auto; }
.nav-links { list-style: none; padding: 20px 0; margin: 0; flex-grow: 1; overflow-y: auto;}
.nav-links li { padding: 15px 25px; cursor: pointer; transition: 0.3s; display: flex; align-items: center; font-size: 15px; font-weight: 500;}
.nav-links li i { margin-right: 15px; width: 20px; text-align: center; }
.nav-links li:hover, .nav-links li.active { background: var(--primary); border-left: 5px solid var(--accent); }
.sidebar-footer { padding: 20px; }

.content { margin-left: var(--sidebar-width); width: calc(100% - var(--sidebar-width)); flex-grow: 1; padding: 30px; box-sizing: border-box; min-width: 0; }
.top-bar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 30px; background: var(--bg-card); padding: 15px 25px; border-radius: 12px; box-shadow: 0 2px 10px rgba(0,0,0,0.05); }
.header-left { display: flex; align-items: center; }
.header-left h1 { margin: 0; font-size: 22px; }
#btn-mobile-menu { display: none; background: none; border: none; font-size: 24px; margin-right: 15px; cursor: pointer; color: var(--primary);}
.user-selector { background: var(--bg-body); padding: 8px 15px; border-radius: 20px; display: flex; align-items: center; flex-shrink: 0; }
.user-selector select { border: none; background: none; font-weight: bold; outline: none; cursor: pointer; font-size: 15px; color: var(--text-main);}
.card { background: var(--bg-card); border-radius: 12px; padding: 25px; box-shadow: 0 4px 6px rgba(0,0,0,0.05); margin-bottom: 25px; }

.loader-overlay { position: fixed; top:0; left:0; width:100%; height:100%; background: rgba(0,0,0, 0.8); z-index: 9999; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.spinner { width: 60px; height: 60px; border: 5px solid rgba(255,255,255,0.3); border-top: 5px solid var(--accent); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

#toast-container { position: fixed; bottom: 20px; right: 20px; z-index: 10000; }
.toast { padding: 15px 25px; border-radius: 8px; color: white; margin-top: 10px; font-weight: bold; box-shadow: 0 5px 15px rgba(0,0,0,0.2); animation: slideIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275); }
.toast.success { background: var(--accent); border-left: 5px solid #27ae60; }
.toast.error { background: var(--danger); border-left: 5px solid #c0392b; }
.toast.info { background: var(--primary); border-left: 5px solid var(--secondary); }
@keyframes slideIn { from { transform: translateX(120%); } to { transform: translateX(0); } }

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .content { margin-left: 0; padding: 15px; width: 100%; } 
  #btn-mobile-menu { display: block; }
  .top-bar { flex-direction: column; align-items: flex-start; gap: 15px; }
  .top-actions { justify-content: center !important; width: 100%; }
  .user-selector { width: 100%; justify-content: center; }
}

.news-ticker-container { background: #2c3e50; color: white; padding: 0; overflow: hidden; white-space: nowrap; display: flex; align-items: center; border-radius: 8px; margin-bottom: 25px; box-shadow: 0 4px 6px rgba(0,0,0,0.1); position: relative; }
.news-ticker-container i.fa-bullhorn { color: #f39c12; font-size: 18px; background: #2c3e50; padding: 12px 15px; position: relative; z-index: 10; box-shadow: 15px 0 15px -5px #2c3e50; }
.news-content { display: inline-block; padding-left: 100%; padding-top: 12px; padding-bottom: 12px; animation: scroll-ticker 25s linear infinite; }
.news-content:hover { animation-play-state: paused; }
@keyframes scroll-ticker { 0% { transform: translate(0, 0); } 100% { transform: translate(-100%, 0); } }

.tag-gov { background: #e74c3c; color: white; padding: 2px 8px; border-radius: 4px; font-weight: bold; font-size: 12px; margin-right: 5px; text-transform: uppercase; }
.tag-pub { background: #3498db; color: white; padding: 2px 8px; border-radius: 4px; font-weight: bold; font-size: 12px; margin-right: 5px; text-transform: uppercase; }
.news-item { margin-right: 50px; font-size: 15px; }

.bg-warning-light { background: #fffdf7; border: 1px solid #f39c12; }
.table-custom { width: 100%; border-collapse: collapse; background: white; text-align: left; }
.table-custom tr { border-bottom: 1px solid #ddd; }
.table-header { background: #eee; }

.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0, 0, 0, 0.7); backdrop-filter: blur(3px); z-index: 10000; display: flex; align-items: center; justify-content: center; opacity: 0; animation: fadeIn 0.3s forwards; }
.modal-box { background: var(--bg-card); color: var(--text-main); width: 90%; max-width: 400px; padding: 25px; border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,0.5); text-align: center; transform: translateY(-20px); animation: slideDown 0.3s forwards; }
.modal-box h3 { margin-top: 0; color: var(--primary); font-size: 20px; }
.modal-box p { font-size: 15px; color: var(--text-muted); margin-bottom: 20px; }
.modal-input { width: 100%; padding: 12px; border: 1px solid var(--border-color); border-radius: 8px; background: var(--input-bg); color: var(--text-main); margin-bottom: 20px; box-sizing: border-box; text-align: center; font-size: 16px; }
.modal-actions { display: flex; gap: 10px; justify-content: center; }
.modal-actions button { flex: 1; }
@keyframes fadeIn { to { opacity: 1; } }
@keyframes slideDown { to { transform: translateY(0); } }