/* ============================================================
   INFIRMIER PRO - Styles principaux
   ============================================================ */

:root {
  --primary:       #0f4c81;
  --primary-light: #1a7fc4;
  --accent:        #0d9488;
  --accent-light:  #14b8a6;
  --danger:        #dc2626;
  --warning:       #f59e0b;
  --success:       #10b981;
  --gray-50:       #f8fafc;
  --gray-100:      #f1f5f9;
  --gray-200:      #e2e8f0;
  --gray-300:      #cbd5e1;
  --gray-500:      #64748b;
  --gray-700:      #374151;
  --gray-900:      #0f172a;
  --sidebar-w:     260px;
  --header-h:      64px;
  --radius:        10px;
  --shadow:        0 1px 4px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.06);
  --shadow-md:     0 4px 20px rgba(0,0,0,.12);
  --font:          'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

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

body {
  font-family: var(--font);
  background: var(--gray-100);
  color: var(--gray-900);
  font-size: 14px;
  line-height: 1.5;
}

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

/* ===================== LAYOUT ===================== */
.app-layout { display: flex; min-height: 100vh; }

/* SIDEBAR */
.sidebar {
  width: var(--sidebar-w);
  background: var(--gray-900);
  position: fixed; top: 0; left: 0; bottom: 0;
  display: flex; flex-direction: column;
  z-index: 100; transition: transform .3s;
  overflow-y: auto;
}

.sidebar-logo {
  padding: 20px 20px 16px;
  display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-logo .logo-icon {
  width: 38px; height: 38px;
  background: linear-gradient(135deg, var(--primary-light), var(--accent));
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.sidebar-logo h2 { color: white; font-size: 16px; font-weight: 700; }
.sidebar-logo span { color: var(--accent-light); font-size: 11px; display: block; }

.sidebar-nav { padding: 16px 12px; flex: 1; }
.nav-section { margin-bottom: 8px; }
.nav-label {
  font-size: 10px; font-weight: 600; letter-spacing: 1px;
  color: var(--gray-500); padding: 8px 8px 4px; text-transform: uppercase;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 8px;
  color: rgba(255,255,255,.65); font-size: 13.5px; font-weight: 500;
  cursor: pointer; transition: all .15s; text-decoration: none; margin-bottom: 2px;
}
.nav-item:hover { background: rgba(255,255,255,.08); color: white; text-decoration: none; }
.nav-item.active { background: var(--primary-light); color: white; }
.nav-item svg { flex-shrink: 0; opacity: .8; }
.nav-item.active svg { opacity: 1; }
.nav-badge {
  margin-left: auto; background: var(--danger); color: white;
  font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 99px;
}

.sidebar-footer {
  padding: 12px; border-top: 1px solid rgba(255,255,255,.08);
}
.user-card {
  display: flex; align-items: center; gap: 10px;
  padding: 10px; border-radius: 8px;
  background: rgba(255,255,255,.06);
}
.user-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary-light), var(--accent));
  display: flex; align-items: center; justify-content: center;
  color: white; font-weight: 700; font-size: 14px; flex-shrink: 0;
}
.user-info .name { color: white; font-size: 13px; font-weight: 600; }
.user-info .role { color: var(--gray-500); font-size: 11px; }
.user-logout {
  margin-left: auto; color: var(--gray-500); cursor: pointer;
  padding: 4px; border-radius: 4px; transition: color .15s;
}
.user-logout:hover { color: var(--danger); }

/* MAIN */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1; display: flex; flex-direction: column; min-width: 0;
}

/* HEADER */
.header {
  height: var(--header-h);
  background: white;
  border-bottom: 1px solid var(--gray-200);
  display: flex; align-items: center; gap: 16px;
  padding: 0 24px; position: sticky; top: 0; z-index: 50;
}
.header-title { font-size: 18px; font-weight: 700; color: var(--gray-900); }
.header-subtitle { font-size: 12px; color: var(--gray-500); margin-top: 1px; }
.header-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.header-date { font-size: 13px; color: var(--gray-500); }

/* PAGE CONTENT */
.page-content { padding: 24px; flex: 1; }

/* ===================== COMPONENTS ===================== */

/* Cards */
.card {
  background: white; border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
}
.card-header {
  padding: 16px 20px; border-bottom: 1px solid var(--gray-100);
  display: flex; align-items: center; gap: 12px;
}
.card-title { font-size: 15px; font-weight: 700; color: var(--gray-900); }
.card-actions { margin-left: auto; display: flex; gap: 8px; }
.card-body { padding: 20px; }

/* Stats */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px,1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: white; border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 16px;
}
.stat-icon {
  width: 48px; height: 48px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.stat-icon.blue { background: #dbeafe; color: var(--primary-light); }
.stat-icon.green { background: #d1fae5; color: var(--success); }
.stat-icon.amber { background: #fef3c7; color: var(--warning); }
.stat-icon.red { background: #fee2e2; color: var(--danger); }
.stat-icon.teal { background: #ccfbf1; color: var(--accent); }
.stat-value { font-size: 28px; font-weight: 800; color: var(--gray-900); line-height: 1; }
.stat-label { font-size: 12px; color: var(--gray-500); margin-top: 3px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: 8px;
  font-size: 13.5px; font-weight: 600; cursor: pointer;
  border: none; transition: all .15s; white-space: nowrap;
}
.btn-primary { background: var(--primary-light); color: white; }
.btn-primary:hover { background: var(--primary); }
.btn-accent { background: var(--accent); color: white; }
.btn-accent:hover { background: #0b7a71; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #b91c1c; }
.btn-ghost { background: var(--gray-100); color: var(--gray-700); }
.btn-ghost:hover { background: var(--gray-200); }
.btn-outline { background: transparent; color: var(--primary-light); border: 1.5px solid var(--primary-light); }
.btn-outline:hover { background: #dbeafe; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }
.btn-icon { padding: 8px; }

/* Forms */
.form-grid { display: grid; gap: 16px; }
.form-grid-2 { grid-template-columns: 1fr 1fr; }
.form-grid-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group label { font-size: 12.5px; font-weight: 600; color: var(--gray-700); }
.form-group input,
.form-group select,
.form-group textarea {
  padding: 9px 12px; border: 1.5px solid var(--gray-200);
  border-radius: 8px; font-size: 14px; outline: none;
  transition: border-color .15s; font-family: inherit;
  background: white; color: var(--gray-900);
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(26,127,196,.12);
}
.form-group textarea { resize: vertical; min-height: 80px; }
.form-hint { font-size: 11.5px; color: var(--gray-500); }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead { background: var(--gray-50); }
th {
  padding: 10px 14px; text-align: left;
  font-size: 11.5px; font-weight: 700; color: var(--gray-500);
  text-transform: uppercase; letter-spacing: .5px;
  border-bottom: 1px solid var(--gray-200);
}
td {
  padding: 12px 14px; border-bottom: 1px solid var(--gray-100);
  font-size: 13.5px; color: var(--gray-700);
}
tbody tr:hover { background: var(--gray-50); }
tbody tr:last-child td { border-bottom: none; }

/* Badges */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 8px; border-radius: 99px;
  font-size: 11px; font-weight: 600;
}
.badge-blue { background: #dbeafe; color: #1d4ed8; }
.badge-green { background: #d1fae5; color: #065f46; }
.badge-amber { background: #fef3c7; color: #92400e; }
.badge-red { background: #fee2e2; color: #991b1b; }
.badge-gray { background: var(--gray-100); color: var(--gray-700); }
.badge-teal { background: #ccfbf1; color: #0f766e; }
.badge-purple { background: #ede9fe; color: #6d28d9; }

/* Tabs */
.tabs { display: flex; border-bottom: 1px solid var(--gray-200); margin-bottom: 20px; }
.tab {
  padding: 10px 20px; font-size: 13.5px; font-weight: 600;
  color: var(--gray-500); cursor: pointer; border-bottom: 2px solid transparent;
  transition: all .15s; margin-bottom: -1px;
}
.tab.active { color: var(--primary-light); border-bottom-color: var(--primary-light); }
.tab:hover:not(.active) { color: var(--gray-900); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* 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: 20px; opacity: 0; pointer-events: none; transition: opacity .2s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: white; border-radius: 16px;
  box-shadow: var(--shadow-md); width: 100%;
  max-height: 90vh; overflow-y: auto;
  transform: translateY(20px); transition: transform .2s;
}
.modal-overlay.open .modal { transform: translateY(0); }
.modal-sm { max-width: 440px; }
.modal-md { max-width: 640px; }
.modal-lg { max-width: 900px; }
.modal-header {
  padding: 20px 24px; border-bottom: 1px solid var(--gray-100);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-title { font-size: 17px; font-weight: 700; }
.modal-close { background: none; border: none; cursor: pointer; color: var(--gray-500); padding: 4px; border-radius: 4px; }
.modal-close:hover { color: var(--danger); background: var(--gray-100); }
.modal-body { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--gray-100); display: flex; justify-content: flex-end; gap: 10px; }

/* Alert */
.alert { padding: 12px 16px; border-radius: 8px; font-size: 13.5px; margin-bottom: 16px; }
.alert-success { background: #d1fae5; color: #065f46; border-left: 3px solid var(--success); }
.alert-danger { background: #fee2e2; color: #991b1b; border-left: 3px solid var(--danger); }
.alert-warning { background: #fef3c7; color: #92400e; border-left: 3px solid var(--warning); }
.alert-info { background: #dbeafe; color: #1e40af; border-left: 3px solid var(--primary-light); }

/* Search bar */
.search-bar {
  display: flex; align-items: center; gap: 8px;
  background: var(--gray-100); border: 1.5px solid var(--gray-200);
  border-radius: 8px; padding: 0 12px;
}
.search-bar input {
  border: none; background: transparent; padding: 9px 0;
  font-size: 14px; outline: none; width: 100%;
}
.search-bar svg { color: var(--gray-500); flex-shrink: 0; }

/* Notification bell */
.notif-bell { position: relative; }
.notif-dot {
  position: absolute; top: 2px; right: 2px;
  width: 8px; height: 8px; background: var(--danger);
  border-radius: 50%; border: 2px solid white;
}

/* ===================== RESPONSIVE ===================== */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .form-grid-2, .form-grid-3 { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .page-content { padding: 16px; }
}

/* ===================== UTILITIES ===================== */
.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.text-sm { font-size: 12px; }
.text-muted { color: var(--gray-500); }
.text-center { text-align: center; }
.font-bold { font-weight: 700; }
.w-full { width: 100%; }
.hidden { display: none !important; }

/* Loading */
.spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--gray-200);
  border-top-color: var(--primary-light);
  border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Toast */
#toast-container {
  position: fixed; bottom: 24px; right: 24px;
  z-index: 9999; display: flex; flex-direction: column; gap: 8px;
}
.toast {
  background: var(--gray-900); color: white;
  padding: 12px 18px; border-radius: 10px;
  font-size: 13.5px; max-width: 320px;
  box-shadow: var(--shadow-md); animation: toastIn .25s ease;
  display: flex; align-items: center; gap: 10px;
}
.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--danger); }
@keyframes toastIn { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }

/* Calendar */
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.cal-day {
  min-height: 90px; padding: 6px; border-radius: 8px;
  background: white; border: 1px solid var(--gray-100);
  cursor: pointer; transition: background .15s;
}
.cal-day:hover { background: #f0f9ff; }
.cal-day.today { border-color: var(--primary-light); background: #eff6ff; }
.cal-day.other-month { opacity: .4; }
.cal-day-num {
  font-size: 12px; font-weight: 700; color: var(--gray-700); margin-bottom: 4px;
}
.cal-day.today .cal-day-num {
  color: var(--primary-light);
}
.cal-event {
  font-size: 10.5px; padding: 2px 5px; border-radius: 4px;
  margin-bottom: 2px; truncate: ellipsis; white-space: nowrap;
  overflow: hidden;
}
.cal-nav {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.cal-nav h3 { font-size: 17px; font-weight: 700; text-transform: capitalize; }

/* Chat */
.chat-layout { display: flex; height: calc(100vh - var(--header-h) - 48px); gap: 0; }
.chat-list { width: 280px; flex-shrink: 0; border-right: 1px solid var(--gray-200); overflow-y: auto; }
.chat-messages { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.messages-area { flex: 1; overflow-y: auto; padding: 20px; }
.chat-input-area {
  padding: 16px; border-top: 1px solid var(--gray-200);
  display: flex; gap: 10px; align-items: flex-end;
}
.msg-bubble {
  max-width: 65%; padding: 10px 14px; border-radius: 12px;
  font-size: 13.5px; margin-bottom: 8px;
}
.msg-bubble.sent {
  background: var(--primary-light); color: white;
  margin-left: auto; border-bottom-right-radius: 2px;
}
.msg-bubble.received {
  background: var(--gray-100); color: var(--gray-900);
  border-bottom-left-radius: 2px;
}
.msg-time { font-size: 10px; opacity: .6; margin-top: 4px; }

/* GPS Tournée */
#map { height: 400px; border-radius: var(--radius); }
