/* ============================================
   Logiciel Gestion Immobilière - Admin Moderne
   Design 2026 - Responsive
   ============================================ */

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

:root {
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --primary-light: #e0e7ff;
  --accent: #f59e0b;
  --accent-light: #fef3c7;
  --success: #10b981;
  --success-light: #d1fae5;
  --warning: #f59e0b;
  --danger: #ef4444;
  --danger-light: #fee2e2;
  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --bg-sidebar: #0f172a;
  --bg-sidebar-hover: #1e293b;
  --text: #0f172a;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --border: #e2e8f0;
  --sidebar-width: 280px;
  --header-height: 72px;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -4px rgba(0,0,0,0.05);
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
  background: var(--bg-main);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: color 0.2s;
}

a:hover {
  color: var(--primary-hover);
}

/* ========== PAGE CONNEXION ========== */
body.login-page-body {
  background-color: #0f172a;
  min-height: 100vh;
}

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #334155 100%);
  background-color: #0f172a;
  padding: 1.5rem;
  position: relative;
  overflow: hidden;
  isolation: isolate;
}

.login-page::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 70% 20%, rgba(99, 102, 241, 0.12) 0%, transparent 55%);
  pointer-events: none;
  z-index: 0;
}

.login-card {
  background-color: #ffffff;
  background: #ffffff;
  padding: 2.5rem;
  border-radius: var(--radius-lg);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.35);
  width: 100%;
  max-width: 420px;
  position: relative;
  z-index: 2;
  border: 1px solid rgba(226, 232, 240, 0.98);
  opacity: 1;
}

.login-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 3rem;
  margin-bottom: 1.25rem;
}

.login-brand-logo {
  display: block;
  max-height: 3.25rem;
  max-width: min(16rem, 100%);
  width: auto;
  height: auto;
  object-fit: contain;
  object-position: center;
}

.login-brand-text {
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--text, #0f172a);
  text-align: center;
  line-height: 1.3;
}

.login-brand-hidden {
  display: none !important;
}

.login-title {
  color: var(--text, #0f172a);
  font-size: 1.35rem;
  margin-bottom: 0.5rem;
  font-weight: 700;
  text-align: center;
}

.login-card .subtitle {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-bottom: 2rem;
}

/* Connexion : carte toujours opaque (aucun effet « verre » / données visibles en arrière-plan) */
body.login-page-body .login-card {
  background: #ffffff !important;
  opacity: 1 !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

body.login-page-body .login-page {
  background-color: #0f172a !important;
}

body.login-page-body .login-card input {
  background-color: #ffffff !important;
  color: #0f172a !important;
}

.login-card .form-group {
  margin-bottom: 1.25rem;
}

.login-card label {
  display: block;
  font-weight: 500;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
  color: var(--text);
}

.login-card input {
  width: 100%;
  padding: 0.875rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.login-card input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.15);
}

.login-card .btn {
  width: 100%;
  padding: 0.9rem;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-hover) 100%);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.login-card .btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(99,102,241,0.4);
}

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

/* Sidebar - Dark moderne */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  color: white;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform 0.3s;
}

.sidebar-header {
  padding: 1.5rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-header a.sidebar-brand {
  text-decoration: none;
}

.sidebar-header a {
  color: white;
  font-weight: 700;
  font-size: 1.15rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.sidebar-brand-inner {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}

.sidebar-logo-img {
  flex-shrink: 0;
  display: block;
  max-height: 2.25rem;
  max-width: min(11rem, 100%);
  width: auto;
  height: auto;
  object-fit: contain;
  object-position: left center;
}

/* Marque : un emplacement par thème (logo ou texte si pas d’URL pour ce thème) */
.sidebar-brand-slot-classique,
.sidebar-brand-slot-clair {
  display: inline-flex;
  align-items: center;
  min-width: 0;
}

html:not([data-theme="clair"]) .sidebar-brand-slot-clair {
  display: none !important;
}

html[data-theme="clair"] .sidebar-brand-slot-classique {
  display: none !important;
}

.sidebar-brand-text {
  min-width: 0;
  line-height: 1.25;
}

.sidebar-header a:hover {
  color: var(--primary-light);
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 0.75rem;
}

.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
}

.theme-label {
  display: block;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(255,255,255,0.45);
  margin-bottom: 0.5rem;
  font-weight: 600;
}

.theme-select {
  width: 100%;
  padding: 0.6rem 0.75rem;
  margin: 0;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255,255,255,0.2);
  background: rgba(255,255,255,0.1);
  color: white;
  font-size: 0.9rem;
  font-family: inherit;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' fill='white'%3E%3Cpath d='M6 8L4 4h4L6 8z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2rem;
}

.theme-select:hover,
.theme-select:focus {
  background-color: rgba(255,255,255,0.15);
  border-color: rgba(255,255,255,0.3);
  outline: none;
}

.theme-select option {
  background: #1e293b;
  color: #f8fafc;
}

.nav-section {
  margin-bottom: 0.5rem;
}

.nav-section-title {
  padding: 0.5rem 1rem;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(255,255,255,0.45);
  font-weight: 600;
}

.nav-section-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0.5rem 1rem;
  cursor: pointer;
}

.nav-section-toggle .nav-section-title {
  color: rgba(255,255,255,0.8);
  font-size: 0.9rem;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 500;
  text-decoration: none;
  flex: 1;
}

.nav-section-toggle .nav-section-title:hover {
  color: white;
}

.nav-section-toggle .nav-section-title.active {
  color: white;
  font-weight: 600;
}

.nav-section-toggle .nav-arrow {
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  flex-shrink: 0;
  user-select: none;
}
.nav-section-toggle .nav-section-title {
  flex: 1;
}

.nav-arrow {
  font-size: 0.65rem;
  transition: transform 0.2s ease;
  opacity: 0.8;
  display: inline-block;
}

.nav-section.has-sublinks.collapsed .nav-arrow {
  transform: rotate(0deg);
}

.nav-section.has-sublinks.expanded .nav-arrow {
  transform: rotate(90deg);
}

.nav-section.has-sublinks.collapsed .nav-link.nav-sublinks {
  display: none;
}

.nav-section.has-sublinks .nav-section-toggle .nav-section-title {
  padding: 0;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem 1rem;
  color: rgba(255,255,255,0.8);
  border-radius: var(--radius-sm);
  transition: all 0.2s;
  margin-bottom: 2px;
}

.nav-link:hover {
  background: var(--bg-sidebar-hover);
  color: white;
}

.nav-link.active {
  background: rgba(99,102,241,0.2);
  color: white;
  font-weight: 600;
}

.nav-link svg {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  opacity: 0.9;
}

.nav-link.nav-sublinks {
  padding: 0.5rem 1rem 0.5rem 2.5rem;
  font-size: 0.9rem;
}

/* Main content */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  min-width: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
}

.header {
  min-height: var(--header-height);
  height: auto;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: 0.5rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: nowrap;
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(8px);
}

.header h1 {
  flex: 1;
  min-width: 0;
  font-size: clamp(1rem, 3.8vw, 1.35rem);
  font-weight: 700;
  color: var(--text);
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.header-welcome {
  font-size: 0.9rem;
  color: var(--text-secondary, #64748b);
  margin-right: 0.25rem;
  white-space: nowrap;
  max-width: min(42vw, 22rem);
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-welcome-name {
  font-weight: 700;
  color: var(--text, #0f172a);
}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
  text-decoration: none;
}
.btn-icon:hover {
  color: var(--primary);
  border-color: var(--primary);
}
.btn-icon svg {
  width: 18px;
  height: 18px;
}

.page-content {
  flex: 1;
  padding: 1.5rem;
}

/* ========== BOUTONS ========== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
  border: none;
  text-decoration: none;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-secondary {
  background: var(--bg-main);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--border);
}

.btn-sm {
  padding: 0.375rem 0.75rem;
  font-size: 0.8rem;
}

/* ========== CARDS & STATS ========== */
.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.page-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--bg-card);
  padding: 1.5rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  transition: all 0.2s;
}

.stat-card:hover {
  box-shadow: var(--shadow);
}

a.stat-card-link:hover {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary-light);
}

.stat-card .stat-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1rem;
  font-size: 1.25rem;
}

.stat-card .stat-icon.primary { background: var(--primary-light); color: var(--primary); }
.stat-card .stat-icon.success { background: var(--success-light); color: var(--success); }
.stat-card .stat-icon.warning { background: var(--accent-light); color: var(--warning); }
.stat-card .stat-icon.danger { background: var(--danger-light); color: var(--danger); }
.stat-card .stat-icon.neutral { background: #f1f5f9; color: var(--text-secondary); }

.stat-card .value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text);
}

.stat-card .label {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
}

.stat-card .trend {
  font-size: 0.8rem;
  margin-top: 0.5rem;
  font-weight: 500;
}

.stat-card .trend.up { color: var(--success); }
.stat-card .trend.down { color: var(--danger); }

/* ========== CARDS CONTENU ========== */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  overflow: hidden;
  transition: all 0.2s;
}

.card:hover {
  box-shadow: var(--shadow);
}

.card-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}

/* Boutons d’action dans l’en-tête (fiches immeuble, etc.) : espacement entre les boutons */
.card-header-actions,
.card-header > div:has(> .btn) {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.card-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
}

.card-body {
  padding: 1.5rem;
}

.info-list { display: grid; grid-template-columns: auto 1fr; gap: 0.5rem 1.5rem; }
.info-list dt { color: var(--text-secondary); font-weight: 500; }
.info-list dd { margin: 0; word-break: break-word; }
.link-list { list-style: none; padding: 0; margin: 0; }
.link-list li { margin-bottom: 0.5rem; }
.link-list a { color: var(--primary); }

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
}

.card-grid .card h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--text);
}

.card-grid .card p {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 1rem;
}

.card-grid a.card-link {
  text-decoration: none;
  color: inherit;
}

.card-grid a.card-link:hover {
  border-color: var(--primary);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.15);
}

.card-grid a.card-link .card-body {
  padding: 1.5rem;
}

.card-grid .card a,
.card-grid a.card-link span.btn {
  font-size: 0.9rem;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

/* ========== RECHERCHE & FILTRES ========== */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.5rem;
  align-items: center;
}

.search-box {
  flex: 1;
  min-width: 200px;
  position: relative;
}

.search-box input {
  width: 100%;
  padding: 0.625rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
}

.search-box input:focus {
  outline: none;
  border-color: var(--primary);
}


.filter-checkbox {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  color: var(--text-secondary);
  cursor: pointer;
  white-space: nowrap;
}

.filter-checkbox input {
  cursor: pointer;
}

.filter-select {
  padding: 0.625rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  background: white;
}

/* ========== TABLES ========== */
.table-container,
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
}

.table-container::-webkit-scrollbar,
.table-wrap::-webkit-scrollbar {
  height: 5px;
}

.table-container::-webkit-scrollbar-thumb,
.table-wrap::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
  background: var(--bg-main);
}

.pagination-info {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.pagination-btns {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.pagination-page {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.data-table th,
.data-table td {
  padding: 1rem 1.25rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.data-table th {
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.data-table tbody tr {
  transition: background 0.15s;
}

.data-table tbody tr:hover {
  background: var(--bg-main);
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.data-table tfoot td {
  border-top: 2px solid var(--border);
  background: var(--bg-secondary, #f8fafc);
}

/* Tableaux liste responsive : Fiche + menu ⋮, colonnes .col-m-hide masquées sur mobile */
.card-table-responsive {
  overflow: visible;
}

.table-actions-row {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-end;
  gap: 0.4rem;
  flex-wrap: nowrap;
}

.table-actions-more {
  position: relative;
}

.data-table-mobile-list .table-actions-more[open] {
  z-index: 50;
}

/* Même gabarit que .btn.btn-sm (ne pas réécrire padding : était plus petit que « Fiche ») */
.table-actions-more > summary.table-actions-kb.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
}

.table-actions-kb {
  list-style: none;
  cursor: pointer;
  font-weight: 700;
  min-width: 2.35rem;
  text-align: center;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.table-actions-kb::-webkit-details-marker {
  display: none;
}

.table-actions-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  z-index: 40;
  min-width: 11rem;
  padding: 0.35rem 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
}

.table-actions-menu > * + * {
  border-top: 1px solid var(--border);
}

.table-actions-menu-link {
  display: block;
  padding: 0.55rem 1rem;
  font-size: 0.9rem;
  color: var(--primary);
  font-weight: 500;
  text-decoration: none;
}

.table-actions-menu-link:hover {
  background: var(--bg-main);
}

.table-actions-menu-btn {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.55rem 1rem;
  font-size: 0.9rem;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--text);
  font-family: inherit;
}

.table-actions-menu-btn:hover {
  background: var(--bg-main);
}

.data-table-mobile-list .cell-m-actions {
  vertical-align: middle;
  white-space: nowrap;
}

.table-mobile-muted {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* Contenu dupliqué pour le résumé mobile (masqué sur grand écran si les colonnes sont visibles) */
.show-mobile-only {
  display: none !important;
}

/* Mobile : ligne type « carte » — libellé à gauche, actions à droite */
@media (max-width: 768px) {
  .table-container:has(.data-table-mobile-list) {
    overflow-x: visible;
    padding-left: 0.75rem;
    padding-right: 0.75rem;
    box-sizing: border-box;
  }

  .card-table-responsive:has(.data-table-mobile-list) {
    overflow: visible;
  }

  .table-container:has(.data-table-mobile-list) .data-table-mobile-list {
    min-width: 0 !important;
    width: 100%;
    display: block;
  }

  .data-table-mobile-list thead {
    display: none;
  }

  .data-table-mobile-list tbody {
    display: block;
  }

  .data-table-mobile-list tbody tr {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.65rem 0;
    min-height: 2.75rem;
    border-bottom: 1px solid var(--border);
  }

  .data-table-mobile-list tbody tr:hover {
    background: var(--bg-main);
  }

  .data-table-mobile-list tbody td {
    border-bottom: none;
    padding: 0.15rem 0;
    vertical-align: middle;
  }

  .data-table-mobile-list tbody tr:last-child {
    border-bottom: 1px solid var(--border);
  }

  .data-table-mobile-list .col-m-hide {
    display: none !important;
  }

  .data-table-mobile-list .cell-m-primary {
    display: block !important;
    flex: 1;
    min-width: 0;
    font-size: 0.88rem;
    line-height: 1.4;
    padding-right: 0.35rem;
    align-self: center;
  }

  .data-table-mobile-list .cell-m-primary a {
    word-break: break-word;
    hyphens: auto;
  }

  .data-table-mobile-list .cell-m-actions {
    display: flex !important;
    flex-direction: row;
    align-items: center;
    justify-content: flex-end;
    flex-shrink: 0;
    align-self: center;
  }

  .data-table-mobile-list .cell-m-tail {
    flex-shrink: 0;
    align-self: center;
    font-size: 0.85rem;
  }

  .data-table-mobile-list .table-actions-row .btn-sm {
    padding: 0.35rem 0.55rem;
    font-size: 0.75rem;
  }

  .data-table-mobile-list tbody tr:has(td[colspan]) {
    display: block;
    border-bottom: none;
    padding: 0;
  }

  .data-table-mobile-list tbody tr:has(td[colspan]) td {
    display: block !important;
    width: 100% !important;
    text-align: center;
    padding: 1rem 0.5rem !important;
    font-size: 0.9rem;
  }

  .data-table-mobile-list .show-mobile-only {
    display: block !important;
  }
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.625rem;
  font-size: 0.75rem;
  font-weight: 500;
  border-radius: 9999px;
}

.badge-success { background: var(--success-light); color: var(--success); }
.badge-warning { background: var(--accent-light); color: #b45309; }
.badge-danger { background: var(--danger-light); color: var(--danger); }
.badge-info { background: var(--primary-light); color: var(--primary); }
.badge-neutral { background: var(--bg-main); color: var(--text-secondary); }

/* ========== FORMULAIRES ========== */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.25rem;
}

.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  font-weight: 500;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
  color: var(--text);
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 0.625rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
}

.form-group input[type="checkbox"] {
  width: auto;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
.form-hint {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}
.settings-presets {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.settings-page {
  max-width: 640px;
}
.settings-page .settings-section {
  margin-bottom: 1.5rem;
}

.lot-search-combobox {
  position: relative;
}
.lot-search-combobox input[type="text"] {
  width: 100%;
}
.lot-search-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 2px;
  max-height: 220px;
  overflow-y: auto;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  z-index: 100;
  display: none;
}
.lot-search-dropdown.visible {
  display: block;
}
.lot-search-dropdown .lot-item {
  padding: 0.6rem 1rem;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}
.lot-search-dropdown .lot-item:last-child { border-bottom: none; }
.lot-search-dropdown .lot-item:hover,
.lot-search-dropdown .lot-item.selected {
  background: var(--primary-light);
}
.lot-search-dropdown .lot-item .lot-ref { font-weight: 600; }
.lot-search-dropdown .lot-item .lot-meta { font-size: 0.8rem; color: var(--text-muted); }
.lot-search-dropdown .lot-empty {
  padding: 1rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

tr.ticket-non-lu {
  background: var(--primary-light);
}

/* ========== ACTIVITÉ / TIMELINE ========== */
.activity-card-body {
  padding: 0 !important;
}

.activity-list {
  list-style: none;
  padding: 0 1.5rem 1.5rem;
}

.activity-item {
  border-bottom: 1px solid var(--border);
}

.activity-link {
  display: flex;
  gap: 1rem;
  padding: 1.25rem 0;
  align-items: flex-start;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  transition: background 0.15s;
}

.activity-link:hover {
  background: var(--bg-hover, rgba(0,0,0,0.03));
}

.activity-item:last-child {
  border-bottom: none;
}

.activity-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--primary);
  flex-shrink: 0;
  margin-top: 0.4rem;
}

.activity-content {
  flex: 1;
  min-width: 0;
}

.activity-title {
  font-weight: 600;
  color: var(--text);
  font-size: 0.95rem;
}

.activity-meta {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.35rem;
  line-height: 1.4;
}

/* ========== CHAT / MESSAGES ========== */
.chat-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 0;
  min-height: 500px;
}

.chat-list {
  border-right: 1px solid var(--border);
  overflow-y: auto;
}

.chat-item {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s;
}

.chat-item:hover,
.chat-item.active {
  background: var(--bg-main);
}

.chat-list-header {
  padding: 1rem 1.25rem;
  font-weight: 600;
  font-size: 0.9rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-main);
}

.chat-list-filters {
  padding: 0.75rem 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-main);
}

.chat-list-filters .search-input {
  flex: 1;
  min-width: 140px;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
}

.chat-list-filters .filter-date {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
}

.chat-date {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

.incident-description,
.incident-notes {
  white-space: pre-wrap;
  padding: 0.75rem;
  background: var(--bg-main);
  border-radius: var(--radius-sm);
  margin-top: 0.5rem;
}

.chat-list-body {
  max-height: 400px;
  overflow-y: auto;
}

.chat-empty {
  padding: 2rem 1.25rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.chat-panel-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 300px;
  color: var(--text-muted);
}

.chat-panel-empty p {
  font-size: 1rem;
}

.signature-preview {
  font-size: 0.85rem;
  color: var(--text-muted);
  padding: 0.75rem;
  background: var(--bg-main);
  border-radius: var(--radius-sm);
  margin-top: 0.5rem;
  white-space: pre-wrap;
  display: none;
}

.form-group-checkbox {
  display: flex;
  align-items: center;
}

.form-group-checkbox label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  font-weight: 400;
}

.form-group-checkbox input[type="checkbox"] {
  width: auto;
}

/* Option TVA (fiche lot — modal modifier) */
.lot-tva-field .lot-tva-heading {
  display: block;
  font-weight: 500;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
  color: var(--text);
}
.lot-tva-field .lot-tva-checkbox-label {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  font-weight: 400;
  cursor: pointer;
  margin: 0;
  line-height: 1.4;
}
.lot-tva-field .lot-tva-checkbox-label input[type="checkbox"] {
  width: 1.05rem;
  height: 1.05rem;
  flex-shrink: 0;
  margin-top: 0.12rem;
  accent-color: var(--primary);
}
.lot-tva-field .lot-tva-checkbox-label span {
  flex: 1;
  min-width: 0;
}

.chat-thread-header {
  padding: 1rem 1.25rem;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  background: var(--bg-main);
}

.signature-item {
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 0.75rem;
}

.signature-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.signature-item-preview {
  font-size: 0.85rem;
  color: var(--text-muted);
  max-height: 80px;
  overflow: hidden;
}

.signature-editor {
  min-height: 150px;
  background: #fff;
}

.ql-editor {
  min-height: 120px;
}

.chat-preview {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.chat-panel {
  display: flex;
  flex-direction: column;
}

.chat-messages {
  flex: 1;
  padding: 1.5rem;
  overflow-y: auto;
}

.message {
  max-width: 80%;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
}

.message.sent {
  background: var(--primary);
  color: white;
  margin-left: auto;
}

.message.received {
  background: var(--bg-main);
  color: var(--text);
}

.chat-input {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 0.5rem;
}

.chat-input input {
  flex: 1;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

/* ========== IA / FAQ ========== */
.ia-chat {
  max-width: 700px;
  margin: 0 auto;
}

.ia-input-area {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

.ia-input-area input {
  flex: 1;
  padding: 1rem 1.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem;
}

.ia-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
}

.ia-suggestion {
  padding: 0.5rem 1rem;
  background: var(--bg-main);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s;
}

.ia-suggestion:hover {
  background: var(--primary-light);
  border-color: var(--primary);
}

/* ========== BREADCRUMB ========== */
.breadcrumb {
  display: flex;
  gap: 0.5rem;
  font-size: 0.875rem;
  margin-bottom: 1rem;
  color: var(--text-muted);
}

.breadcrumb a {
  color: var(--text-muted);
}

.breadcrumb a:hover {
  color: var(--primary);
}

.breadcrumb span:last-child {
  color: var(--text);
  font-weight: 500;
}

/* ========== MOBILE ========== */
.menu-toggle {
  display: none;
  flex-shrink: 0;
  background: none;
  border: none;
  padding: 0.5rem;
  margin: -0.25rem;
  min-width: 44px;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text);
  border-radius: var(--radius-sm);
}

.menu-toggle:active {
  background: var(--bg-main);
}

.menu-toggle svg {
  width: 24px;
  height: 24px;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 99;
}

.sidebar-overlay.active {
  display: block;
}

/* ========== RESPONSIVE ========== */
@media (max-width: 992px) {
  .sidebar {
    transform: translateX(-100%);
    box-shadow: none;
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: 8px 0 32px rgba(0, 0, 0, 0.35);
  }

  .nav-link {
    padding: 0.7rem 1rem;
    min-height: 44px;
  }

  .main-content {
    margin-left: 0;
  }

  .menu-toggle {
    display: inline-flex;
  }

  .chat-layout {
    grid-template-columns: 1fr;
    min-height: min(70vh, 560px);
  }

  .chat-list {
    border-right: none;
    border-bottom: 1px solid var(--border);
    max-height: 40vh;
  }

  .chat-panel {
    min-height: 280px;
  }
}

@media (max-width: 768px) {
  .page-content {
    padding: 1rem;
  }

  .header {
    padding: 0.5rem 0.75rem;
  }

  .header-actions {
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: flex-end;
    align-items: center;
  }

  .header-welcome {
    font-size: 0.8rem;
    max-width: min(40vw, 14rem);
  }

  .page-header {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }

  .page-header .btn {
    width: 100%;
    justify-content: center;
  }

  .page-title {
    font-size: 1.25rem;
  }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
  }

  .stat-card {
    padding: 1rem;
  }

  .stat-card .value {
    font-size: 1.35rem;
  }

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

  .card-header,
  .card-body {
    padding: 1rem 1.1rem;
  }

  .card-header {
    flex-direction: column;
    align-items: stretch;
  }

  .card-header .btn {
    width: 100%;
    justify-content: center;
  }

  .card-header-actions,
  .card-header > div:has(> .btn) {
    flex-direction: column;
    align-items: stretch;
    gap: 0.65rem;
  }

  .form-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .data-table th,
  .data-table td {
    padding: 0.65rem 0.75rem;
    font-size: 0.8125rem;
  }

  .data-table th {
    font-size: 0.7rem;
  }

  .table-container .data-table,
  .table-wrap .data-table {
    min-width: 520px;
  }

  .toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }

  .toolbar .search-box {
    min-width: 0;
    width: 100%;
  }

  .toolbar .filter-select,
  .toolbar .btn {
    width: 100%;
    justify-content: center;
  }

  .toolbar .filter-checkbox {
    white-space: normal;
  }

  .pagination-bar {
    flex-direction: column;
    align-items: stretch;
    text-align: center;
  }

  .pagination-btns {
    justify-content: center;
    flex-wrap: wrap;
  }

  .dashboard-immeuble-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
  }

  .dashboard-immeuble-bar .filter-select {
    min-width: 0;
    width: 100%;
  }

  .info-list {
    grid-template-columns: 1fr;
    gap: 0.25rem 0;
  }

  .info-list dt {
    font-size: 0.85rem;
    margin-top: 0.75rem;
  }

  .info-list dt:first-of-type {
    margin-top: 0;
  }

  .info-list dd {
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
  }

  .settings-page {
    max-width: none;
  }

  .breadcrumb {
    font-size: 0.8rem;
    flex-wrap: wrap;
  }

  .modal {
    max-width: calc(100vw - 1rem);
    margin: 0 auto;
  }

  .modal-header,
  .modal-body,
  .modal-footer {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  .modal-footer {
    flex-direction: column-reverse;
    align-items: stretch;
  }

  .modal-footer .btn {
    width: 100%;
    justify-content: center;
  }

  .activity-list {
    padding: 0 1rem 1rem;
  }

  .activity-link {
    padding: 1rem 0;
    gap: 0.75rem;
  }

  input,
  select,
  textarea,
  .filter-select {
    font-size: 16px;
  }

  .login-card {
    padding: 1.5rem;
  }

  .login-title {
    font-size: 1.2rem;
  }
}

@media (max-width: 480px) {
  .page-content {
    padding: 0.75rem;
  }

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

  .toolbar .btn {
    width: 100%;
  }

  .header-welcome {
    display: none;
  }

  .table-container .data-table,
  .table-wrap .data-table {
    min-width: 480px;
  }

  .page-title {
    font-size: 1.1rem;
  }

  .card-title {
    font-size: 1rem;
  }

  .btn-sm {
    padding: 0.45rem 0.65rem;
    font-size: 0.85rem;
  }
}

.dashboard-immeuble-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.dashboard-immeuble-bar label {
  font-weight: 500;
  color: var(--text-secondary);
}

.dashboard-immeuble-bar .filter-select {
  min-width: 220px;
}

.stats-immeuble {
  margin-bottom: 1.5rem;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}

/* ========== MODALS ========== */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal-overlay.active {
  display: flex;
}
.modal {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-width: 480px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
}
/* Modal « Changer le locataire » (bail / lot) : un peu plus haut + liste déroulante lisible */
#modal-changer-locataire .modal.modal-changer-locataire {
  min-height: 24rem;
}
#modal-changer-locataire .lot-search-dropdown {
  max-height: 260px;
}
.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-header h3 { font-size: 1.25rem; margin: 0; }
.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-muted);
  padding: 0.25rem;
  line-height: 1;
}
.modal-close:hover { color: var(--text); }
.modal-body { padding: 1.5rem; }
.modal-body .form-group { margin-bottom: 1rem; }
.modal-body .form-group:last-child { margin-bottom: 0; }
.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
}
.form-error { color: var(--danger); font-size: 0.875rem; margin-top: 0.25rem; }

/* ========== THÈMES ========== */

/* Thème Clair (ex. mobile first) */
[data-theme="clair"] {
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --primary-light: #e0e7ff;
  --accent: #0d9488;
  --accent-light: #ccfbf1;
  --success: #16a34a;
  --success-light: #dcfce7;
  --warning: #ca8a04;
  --danger: #dc2626;
  --danger-light: #fee2e2;
  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --bg-sidebar: #ffffff;
  --bg-sidebar-hover: #f8fafc;
  --text: #1e293b;
  --text-secondary: #64748b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --radius: 16px;
  --radius-sm: 8px;
  --radius-lg: 24px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

[data-theme="clair"] body {
  font-family: 'Inter', system-ui, sans-serif;
}

[data-theme="clair"] .sidebar {
  background: #ffffff;
  border-right: 1px solid #e2e8f0;
}

[data-theme="clair"] .sidebar-header,
[data-theme="clair"] .sidebar-header a,
[data-theme="clair"] .nav-link,
[data-theme="clair"] .nav-section-toggle .nav-section-title {
  color: #64748b !important;
}

[data-theme="clair"] .nav-section-title {
  color: #94a3b8 !important;
}

[data-theme="clair"] .nav-link:hover,
[data-theme="clair"] .nav-section-toggle .nav-section-title:hover {
  color: #1e293b !important;
}

[data-theme="clair"] .nav-link.active {
  background: #e0e7ff;
  color: #4f46e5 !important;
}

[data-theme="clair"] .sidebar-footer {
  border-top-color: #e2e8f0;
}

[data-theme="clair"] .theme-label {
  color: #94a3b8 !important;
}

[data-theme="clair"] .theme-select {
  background: #ffffff;
  border-color: #e2e8f0;
  color: #1e293b;
}

[data-theme="clair"] .theme-select option {
  background: #ffffff;
  color: #1e293b;
}

[data-theme="clair"] .btn {
  border-radius: 9999px;
}

[data-theme="clair"] .btn-primary:hover {
  transform: translateY(-2px);
}

[data-theme="clair"] .card,
[data-theme="clair"] .stat-card {
  border-radius: 16px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

[data-theme="clair"] .login-page {
  background: radial-gradient(circle at 50% 0%, #e0e7ff 0%, #f8fafc 60%);
}

[data-theme="clair"] .login-card {
  border-radius: 24px;
}

[data-theme="clair"] .login-page::before {
  background: radial-gradient(circle, rgba(99, 102, 241, 0.1) 0%, transparent 70%);
}

