/* ============================================
   GROUPE LA PERRIERE - Gestion Immobilière
   Styles principaux
   ============================================ */

:root {
  --primary: #1a3a5c;
  --primary-light: #2563a8;
  --primary-dark: #0f2340;
  --secondary: #c8a84b;
  --secondary-light: #e8c96a;
  --accent: #e74c3c;
  --success: #27ae60;
  --warning: #f39c12;
  --danger: #e74c3c;
  --info: #2980b9;
  --bg: #f0f4f8;
  --bg-card: #ffffff;
  --text: #1e2b3a;
  --text-muted: #6b7a8d;
  --border: #d1dce8;
  --sidebar-width: 260px;
  --header-height: 64px;
  --radius: 10px;
  --shadow: 0 2px 12px rgba(26,58,92,0.10);
  --shadow-lg: 0 8px 32px rgba(26,58,92,0.16);
}

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

body {
  font-family: 'Inter', 'Segoe UI', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ── HEADER ── */
header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-height);
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 1000;
  box-shadow: 0 2px 16px rgba(0,0,0,0.18);
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  text-decoration: none;
}

.header-logo {
  width: 40px; height: 40px;
  background: var(--secondary);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; color: var(--primary);
  font-weight: 800;
}

.header-title {
  color: #fff;
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1.2;
}

.header-subtitle {
  color: var(--secondary-light);
  font-size: 0.72rem;
  font-weight: 400;
  letter-spacing: 0.04em;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-alert-badge {
  background: var(--danger);
  color: #fff;
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: background 0.2s;
}
.header-alert-badge:hover { background: #c0392b; }

.burger-btn {
  display: none;
  background: none;
  border: none;
  color: #fff;
  font-size: 1.4rem;
  cursor: pointer;
  padding: 4px 8px;
}

/* ── LAYOUT ── */
.app-layout {
  display: flex;
  margin-top: var(--header-height);
  min-height: calc(100vh - var(--header-height));
}

/* ── SIDEBAR ── */
.sidebar {
  position: fixed;
  top: var(--header-height);
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--primary-dark);
  overflow-y: auto;
  z-index: 900;
  transition: transform 0.3s;
}

.sidebar-section {
  padding: 16px 0 4px;
}

.sidebar-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #5e7fa0;
  padding: 0 20px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 20px;
  color: #a8c0d8;
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  transition: background 0.15s, color 0.15s;
  border-left: 3px solid transparent;
}

.nav-item:hover {
  background: rgba(255,255,255,0.07);
  color: #fff;
}

.nav-item.active {
  background: rgba(200,168,75,0.15);
  color: var(--secondary-light);
  border-left-color: var(--secondary);
}

.nav-item i {
  width: 20px;
  text-align: center;
  font-size: 0.95rem;
}

.nav-badge {
  margin-left: auto;
  background: var(--danger);
  color: #fff;
  border-radius: 10px;
  padding: 1px 7px;
  font-size: 0.72rem;
  font-weight: 700;
}

/* ── MAIN CONTENT ── */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  padding: 28px;
  min-width: 0;
}

/* ── PAGE VIEWS ── */
.page-view {
  display: none;
}
.page-view.active {
  display: block;
}

/* ── PAGE HEADER ── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}

.page-header-left h1 {
  font-size: 1.55rem;
  font-weight: 700;
  color: var(--primary);
}

.page-header-left p {
  color: var(--text-muted);
  font-size: 0.88rem;
  margin-top: 2px;
}

/* ── BUTTONS ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: var(--radius);
  border: none;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}

.btn-primary {
  background: var(--primary-light);
  color: #fff;
}
.btn-primary:hover { background: var(--primary); }

.btn-secondary {
  background: var(--secondary);
  color: var(--primary-dark);
}
.btn-secondary:hover { background: var(--secondary-light); }

.btn-success {
  background: var(--success);
  color: #fff;
}
.btn-success:hover { background: #219150; }

.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-danger:hover { background: #c0392b; }

.btn-ghost {
  background: transparent;
  border: 1.5px solid var(--border);
  color: var(--text-muted);
}
.btn-ghost:hover { border-color: var(--primary-light); color: var(--primary-light); }

.btn-sm { padding: 5px 12px; font-size: 0.8rem; }
.btn-icon { padding: 7px 10px; }

/* ── CARDS ── */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.card-header {
  padding: 18px 24px 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.card-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-body { padding: 20px 24px; }

/* ── KPI CARDS ── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.kpi-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 16px;
  transition: transform 0.2s, box-shadow 0.2s;
}
.kpi-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }

.kpi-icon {
  width: 52px; height: 52px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}
.kpi-icon.blue { background: #e8f0fc; color: var(--primary-light); }
.kpi-icon.gold { background: #fdf4dc; color: #b8860b; }
.kpi-icon.green { background: #e8f8ef; color: var(--success); }
.kpi-icon.red { background: #fdecea; color: var(--danger); }
.kpi-icon.purple { background: #f0ebff; color: #7c3aed; }
.kpi-icon.orange { background: #fff3e0; color: #e65100; }

.kpi-info { flex: 1; }
.kpi-value { font-size: 1.7rem; font-weight: 800; color: var(--primary); line-height: 1; }
.kpi-label { font-size: 0.8rem; color: var(--text-muted); margin-top: 4px; }

/* ── TABLES ── */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

thead th {
  background: #f4f8fb;
  color: var(--primary);
  font-weight: 700;
  padding: 11px 16px;
  text-align: left;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid #eef2f7;
  transition: background 0.12s;
}

tbody tr:hover { background: #f8fbff; }
tbody tr:last-child { border-bottom: none; }

tbody td {
  padding: 11px 16px;
  vertical-align: middle;
  color: var(--text);
}

/* ── BADGES / STATUTS ── */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}
.badge-success { background: #e8f8ef; color: #1a7a40; }
.badge-warning { background: #fff8e1; color: #b8860b; }
.badge-danger  { background: #fdecea; color: #c0392b; }
.badge-info    { background: #e3f0fb; color: #1565c0; }
.badge-neutral { background: #f0f4f8; color: #6b7a8d; }
.badge-purple  { background: #f0ebff; color: #5b21b6; }

/* ── FILTERS BAR ── */
.filters-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.search-box {
  display: flex;
  align-items: center;
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 0 12px;
  gap: 8px;
  flex: 1;
  min-width: 200px;
  max-width: 340px;
}
.search-box i { color: var(--text-muted); }
.search-box input {
  border: none;
  outline: none;
  background: transparent;
  padding: 9px 0;
  font-size: 0.875rem;
  color: var(--text);
  width: 100%;
}

.filter-select {
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 9px 14px;
  font-size: 0.875rem;
  color: var(--text);
  outline: none;
  cursor: pointer;
}
.filter-select:focus { border-color: var(--primary-light); }

/* ── FORMS & MODALS ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,35,64,0.55);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}
.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: var(--bg-card);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 680px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  transform: translateY(24px);
  transition: transform 0.25s;
}
.modal-overlay.open .modal { transform: translateY(0); }
.modal.modal-lg { max-width: 860px; }

.modal-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-header h2 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--primary);
}
.modal-close {
  background: none;
  border: none;
  font-size: 1.3rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  transition: background 0.15s;
}
.modal-close:hover { background: var(--bg); color: var(--text); }

.modal-body {
  padding: 24px;
  overflow-y: auto;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ── FORM ELEMENTS ── */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.form-grid .full-width { grid-column: 1 / -1; }

.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.form-group label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
}

.form-group input,
.form-group select,
.form-group textarea {
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 0.875rem;
  color: var(--text);
  background: var(--bg-card);
  outline: none;
  transition: border-color 0.2s;
  font-family: inherit;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--primary-light);
}
.form-group textarea { resize: vertical; min-height: 80px; }

/* ── EMPTY STATE ── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state i { font-size: 3rem; margin-bottom: 16px; opacity: 0.4; }
.empty-state p { font-size: 1rem; font-weight: 500; }
.empty-state small { font-size: 0.82rem; }

/* ── ALERT ITEMS ── */
.alert-item {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 14px 18px;
  border-radius: 10px;
  border-left: 4px solid;
  background: var(--bg-card);
  margin-bottom: 10px;
  box-shadow: var(--shadow);
}
.alert-item.urgent { border-color: var(--danger); background: #fff8f8; }
.alert-item.warning { border-color: var(--warning); background: #fffcf0; }
.alert-item.info { border-color: var(--info); background: #f0f8ff; }
.alert-item.success { border-color: var(--success); background: #f0fff6; }

.alert-icon { font-size: 1.3rem; margin-top: 2px; }
.alert-item.urgent .alert-icon { color: var(--danger); }
.alert-item.warning .alert-icon { color: var(--warning); }
.alert-item.info .alert-icon { color: var(--info); }
.alert-item.success .alert-icon { color: var(--success); }

.alert-content { flex: 1; }
.alert-title { font-weight: 700; font-size: 0.9rem; color: var(--primary); }
.alert-meta { font-size: 0.8rem; color: var(--text-muted); margin-top: 2px; }
.alert-actions { display: flex; gap: 8px; align-items: center; }

/* ── TOAST NOTIFICATIONS ── */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  background: var(--primary-dark);
  color: #fff;
  padding: 14px 20px;
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  font-size: 0.875rem;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 280px;
  max-width: 400px;
  animation: toastIn 0.3s ease;
}
.toast.success { background: var(--success); }
.toast.error   { background: var(--danger); }
.toast.warning { background: var(--warning); color: #1a1a1a; }
@keyframes toastIn {
  from { opacity: 0; transform: translateX(40px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ── TABS ── */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 2px solid var(--border);
  margin-bottom: 20px;
}
.tab-btn {
  padding: 9px 18px;
  background: none;
  border: none;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color 0.2s;
}
.tab-btn.active { color: var(--primary-light); border-bottom-color: var(--primary-light); }
.tab-btn:hover { color: var(--primary); }

/* ── RESPONSIVE ── */
@media (max-width: 768px) {
  :root { --sidebar-width: 0px; }
  
  .sidebar {
    transform: translateX(-260px);
    width: 260px;
  }
  .sidebar.open {
    transform: translateX(0);
    width: 260px;
  }

  .main-content {
    margin-left: 0;
    padding: 16px;
  }

  .burger-btn { display: block; }

  .kpi-grid {
    grid-template-columns: 1fr 1fr;
  }

  .form-grid { grid-template-columns: 1fr; }
  .form-grid .full-width { grid-column: 1; }

  .page-header { flex-direction: column; align-items: flex-start; }
  
  table { font-size: 0.8rem; }
  thead th, tbody td { padding: 8px 10px; }
  
  .modal { max-width: 100%; }
}

@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .header-title { font-size: 0.95rem; }
  .header-subtitle { display: none; }
}

/* ── LOADER ── */
.loader {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}
.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--primary-light);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── CHARTS CONTAINER ── */
.charts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
}
.chart-container {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}
.chart-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

@media (max-width: 768px) {
  .charts-grid { grid-template-columns: 1fr; }
}

/* ── DETAIL VIEW ── */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.detail-item { display: flex; flex-direction: column; gap: 2px; }
.detail-label { font-size: 0.75rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.detail-value { font-size: 0.9rem; color: var(--text); font-weight: 500; }

/* ── PROGRESS BAR ── */
.progress-bar-wrap {
  background: var(--bg);
  border-radius: 10px;
  height: 8px;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  border-radius: 10px;
  background: var(--primary-light);
  transition: width 0.5s;
}

/* ── SIDEBAR OVERLAY (mobile) ── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 850;
}
.sidebar-overlay.open { display: block; }
