/* ════════════════════════════════════════════════════════════════════════
   style.css — Design system partagé LocaGes
   ════════════════════════════════════════════════════════════════════════ */

:root {
  /* Fond et surfaces */
  --bg:            #EEF2F7;
  --surface:       #FFFFFF;
  --surface-alt:   #F5F8FC;
  --border:        #C8D6E8;
  --border-light:  #DDE7F2;

  /* Couleur principale */
  --accent:        #1A5C96;
  --accent-hover:  #144A7A;
  --accent-light:  #EAF2FB;
  --accent-2:      #2980B9;

  /* Texte */
  --text:          #1C2D3F;
  --text-2:        #3A5068;
  --muted:         #6B809A;
  --muted-light:   #9BB0C5;

  /* États sémantiques */
  --success:        #0B7B57;  --success-bg:    #EAFAF3;  --success-border:#B2DECE;
  --warning:        #B45309;  --warning-bg:    #FFF8EC;  --warning-border:#F9D89B;
  --error:          #C0392B;  --error-bg:      #FDF2F1;  --error-border:  #F0B9B3;
  --info:           #1A5C96;  --info-bg:       #EAF2FB;  --info-border:   #A8C8E8;

  /* Layout */
  --nav-h:      62px;
  --footer-h:   30px;
  --container:  1120px;
  --sidebar-w:  240px;
  --radius-sm:  6px;
  --radius:     10px;
  --radius-lg:  16px;
  --radius-xl:  24px;

  /* Ombres */
  --shadow-xs: 0 1px 2px rgba(28,45,63,.06);
  --shadow-sm: 0 1px 4px rgba(28,45,63,.08), 0 1px 2px rgba(28,45,63,.04);
  --shadow:    0 4px 16px rgba(28,45,63,.08), 0 1px 4px rgba(28,45,63,.06);
  --shadow-lg: 0 10px 32px rgba(28,45,63,.10), 0 2px 8px rgba(28,45,63,.06);
}

/* ── Reset ──────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-font-smoothing: antialiased; scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 15px;
  line-height: 1.5;
  display: flex;
  flex-direction: column;
}

/* ── Navigation ─────────────────────────────────────────────────────────── */
.app-nav {
  position: sticky; top: 0; z-index: 200;
  height: var(--nav-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-xs);
  display: flex; align-items: center;
}

.app-nav .nav-inner {
  width: 100%; max-width: var(--container);
  margin: 0 auto; padding: 0 24px;
  display: flex; align-items: center; gap: 8px;
}

.nav-brand {
  display: flex; align-items: center; gap: 10px;
  text-decoration: none; color: var(--text);
  flex-shrink: 0; margin-right: 24px;
}

.nav-logo {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; color: white; flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(26,92,150,.25);
}

.nav-brand-name { font-size: .875rem; font-weight: 700; letter-spacing: -.015em; line-height: 1; }
.nav-brand-sub  { font-size: .72rem; color: var(--muted); line-height: 1; margin-top: 2px; }

.nav-links { display: flex; align-items: center; gap: 2px; flex: 1; }

.nav-link {
  display: flex; align-items: center; gap: 7px;
  padding: 6px 13px; border-radius: var(--radius-sm);
  text-decoration: none; font-size: .845rem; font-weight: 500;
  color: var(--muted);
  transition: background .15s, color .15s;
  white-space: nowrap;
}
.nav-link:hover  { background: var(--accent-light); color: var(--accent); }
.nav-link.active { background: var(--accent-light); color: var(--accent); font-weight: 600; }

.nav-right { display: flex; align-items: center; gap: 12px; margin-left: auto; flex-shrink: 0; }

.nav-user {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 12px 4px 6px; border-radius: 32px;
  border: 1px solid var(--border-light); background: var(--surface-alt);
  font-size: .8rem; color: var(--text-2);
}
.nav-user-avatar { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; border: 1.5px solid var(--border); }
.nav-user-name   { font-weight: 500; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Footer ─────────────────────────────────────────────────────────────── */
.app-footer { margin-top: auto; background: var(--surface); border-top: 1px solid var(--border-light); min-height: var(--footer-h); }

.app-footer .footer-inner {
  max-width: var(--container); margin: 0 auto; padding: 0 24px;
  height: var(--footer-h); display: flex; align-items: center;
  justify-content: space-between; gap: 16px; flex-wrap: wrap;
}

.footer-user     { display: flex; align-items: center; gap: 6px; font-size: .7rem; color: var(--muted); }
.footer-avatar   { width: 16px; height: 16px; border-radius: 50%; object-fit: cover; border: 1px solid var(--border); }
.footer-user strong { color: var(--text-2); font-weight: 600; }
.footer-sep      { color: var(--border); }

.footer-status { display: flex; align-items: center; gap: 5px; font-size: .68rem; font-weight: 500; }
.status-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.status-dot.ok      { background: var(--success); animation: blink 2.5s ease-in-out infinite; }
.status-dot.warning { background: var(--warning); }
.status-dot.error   { background: var(--error); }
.status-dot.loading { background: var(--muted-light); }
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: .45; } }
.footer-status.ok      { color: var(--success); }
.footer-status.warning { color: var(--warning); }
.footer-status.error   { color: var(--error); }
.footer-status.loading { color: var(--muted-light); }

/* ── Layout principal ───────────────────────────────────────────────────── */
main, .main-content { flex: 1; max-width: var(--container); width: 100%; margin: 0 auto; padding: 40px 24px; }

/* ── Boutons ────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 8px 18px; border-radius: var(--radius-sm);
  font-size: .875rem; font-weight: 500; cursor: pointer;
  text-decoration: none; border: 1px solid transparent;
  transition: background .15s, border-color .15s, color .15s, transform .1s, box-shadow .15s;
  line-height: 1; white-space: nowrap;
}
.btn:active { transform: translateY(1px); }

.btn-primary   { background: var(--accent); color: #fff; box-shadow: 0 2px 8px rgba(26,92,150,.22); }
.btn-primary:hover { background: var(--accent-hover); box-shadow: 0 4px 12px rgba(26,92,150,.3); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-light); }
.btn-ghost     { background: transparent; color: var(--muted); border-color: var(--border-light); }
.btn-ghost:hover { border-color: var(--border); color: var(--text); }
.btn-danger    { background: var(--surface); color: var(--error); border-color: var(--error-border); }
.btn-danger:hover { background: var(--error-bg); }
.btn-warning   { background: #FFF3E0; color: #E65100; border-color: #FFCC80; }
.btn-warning:hover { background: #FFE0B2; }
.btn-error     { background: #FFEBEE; color: #B71C1C; border-color: #EF9A9A; }
.btn-error:hover { background: #FFCDD2; }
.btn-sm { padding: 5px 12px; font-size: .8rem; }
.btn-lg { padding: 11px 24px; font-size: .95rem; }

/* ── Cards ──────────────────────────────────────────────────────────────── */
.card        { background: var(--surface); border: 1px solid var(--border-light); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 24px; }
.card-lg     { padding: 32px; border-radius: var(--radius-lg); box-shadow: var(--shadow); }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; gap: 12px; }
.card-title  { font-size: 1rem; font-weight: 600; color: var(--text); }
.card-subtitle { font-size: .8rem; color: var(--muted); margin-top: 2px; }

/* ── Alertes ────────────────────────────────────────────────────────────── */
.alert { display: flex; align-items: flex-start; gap: 10px; padding: 12px 16px; border-radius: var(--radius-sm); font-size: .855rem; border: 1px solid; line-height: 1.5; }
.alert-icon    { font-size: 15px; flex-shrink: 0; margin-top: 1px; }
.alert-success { background: var(--success-bg); border-color: var(--success-border); color: var(--success); }
.alert-warning { background: var(--warning-bg); border-color: var(--warning-border); color: var(--warning); }
.alert-error   { background: var(--error-bg);   border-color: var(--error-border);   color: var(--error); }
.alert-info    { background: var(--info-bg);     border-color: var(--info-border);    color: var(--info); }

/* ── Badges ─────────────────────────────────────────────────────────────── */
.badge         { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 20px; font-size: .73rem; font-weight: 600; letter-spacing: .01em; }
.badge-primary { background: var(--accent-light); color: var(--accent); }
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-error   { background: var(--error-bg); color: var(--error); }
.badge-muted   { background: var(--surface-alt); color: var(--muted); border: 1px solid var(--border-light); }

/* ── Formulaires ────────────────────────────────────────────────────────── */
.form-group   { margin-bottom: 18px; }
.form-label   { display: block; font-size: .82rem; font-weight: 600; color: var(--text-2); margin-bottom: 6px; }
.form-control {
  width: 100%; padding: 9px 13px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); font-size: .875rem;
  color: var(--text); font-family: inherit;
  transition: border-color .15s, box-shadow .15s; outline: none;
}
.form-control:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(26,92,150,.1); }
.form-control::placeholder { color: var(--muted-light); }
select.form-control   { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 100px; }

/* ── Utilitaires ────────────────────────────────────────────────────────── */
.text-muted   { color: var(--muted); }
.text-accent  { color: var(--accent); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-error   { color: var(--error); }
.text-sm      { font-size: .85rem; }
.text-xs      { font-size: .75rem; }

.flex        { display: flex; }
.flex-center { display: flex; align-items: center; }
.gap-4  { gap: 4px; }  .gap-8  { gap: 8px; }  .gap-12 { gap: 12px; }
.gap-16 { gap: 16px; } .gap-24 { gap: 24px; }
.mt-8  { margin-top: 8px; }    .mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }   .mt-32 { margin-top: 32px; }
.mb-8  { margin-bottom: 8px; } .mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }.mb-32 { margin-bottom: 32px; }

/* ── Spinner ─────────────────────────────────────────────────────────────── */
.spinner { width: 18px; height: 18px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; flex-shrink: 0; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Séparateur ─────────────────────────────────────────────────────────── */
.divider { display: flex; align-items: center; gap: 12px; color: var(--muted-light); font-size: .75rem; margin: 20px 0; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--border-light); }

/* ── Page titre ──────────────────────────────────────────────────────────── */
.page-header { margin-bottom: 32px; }
.page-title  { font-size: 1.6rem; font-weight: 700; letter-spacing: -.025em; line-height: 1.2; }
.page-title span { color: var(--accent); }
.page-desc   { font-size: .9rem; color: var(--muted); margin-top: 6px; }

/* ── Toasts ──────────────────────────────────────────────────────────────── */
#toast-container {
  position: fixed; bottom: 24px; right: 24px; z-index: 9999;
  display: flex; flex-direction: column; gap: 8px; pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; background: var(--text); color: white;
  border-radius: var(--radius); font-size: .845rem;
  box-shadow: var(--shadow-lg); pointer-events: all;
  animation: toast-in .25s ease; max-width: 340px;
}
.toast.success, .toast.toast-success { background: var(--success); }
.toast.error,   .toast.toast-error   { background: var(--error); }
.toast.warning, .toast.toast-warning { background: var(--warning); }
.toast.info,    .toast.toast-info    { background: var(--accent); }
.toast-hide { animation: toast-out .3s ease forwards; }
@keyframes toast-in  { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to   { opacity: 0; transform: translateX(20px); } }

/* ── Tuiles d'accueil ────────────────────────────────────────────────────── */
.tiles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 20px;
  margin-top: 8px;
}

.tile {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  text-decoration: none;
  color: var(--text);
  box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column; align-items: flex-start; gap: 14px;
  transition: box-shadow .2s, transform .15s, border-color .2s;
}
.tile:hover {
  box-shadow: var(--shadow);
  transform: translateY(-2px);
  border-color: var(--accent-light);
}

.tile-icon {
  width: 52px; height: 52px;
  background: var(--accent-light);
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  font-size: 24px;
}
.tile-title   { font-size: 1rem; font-weight: 700; }
.tile-desc    { font-size: .8rem; color: var(--muted); line-height: 1.5; }

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .nav-links .nav-link span { display: none; }
}

@media (max-width: 700px) {
  .app-nav { height: auto; min-height: var(--nav-h); flex-wrap: wrap; }
  .app-nav .nav-inner { flex-wrap: wrap; padding: 0 12px; gap: 0; }

  .nav-brand { padding: 10px 0; margin-right: auto; }
  .nav-brand-sub { display: none; }
  .nav-user-name { display: none; }

  .nav-links {
    order: 3;
    width: 100%;
    overflow-x: auto;
    flex-wrap: nowrap;
    gap: 2px;
    padding: 4px 0 6px;
    /* hide scrollbar visually */
    scrollbar-width: none;
  }
  .nav-links::-webkit-scrollbar { display: none; }

  .nav-link { padding: 5px 10px; font-size: .82rem; }

  .nav-right { padding: 8px 0; }

  main, .main-content { padding: 24px 16px; }
  .app-footer .footer-inner { padding: 0 16px; }
  .tiles-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 14px; }
  .tile { padding: 20px 16px; }
}

/* ── Sidebar ─────────────────────────────────────────────────────────────── */
body { margin-left: var(--sidebar-w); }

.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0; z-index: 300;
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  box-shadow: 2px 0 12px rgba(28,45,63,.06);
  display: flex; flex-direction: column;
  overflow: hidden;
}

.sb-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px; height: 62px;
  border-bottom: 1px solid var(--border-light); flex-shrink: 0;
}
.sb-brand {
  display: flex; align-items: center; gap: 10px;
  text-decoration: none; color: var(--text); flex: 1; overflow: hidden;
}
.sb-logo {
  width: 34px; height: 34px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; color: white;
}
.sb-brand-name { font-size: .875rem; font-weight: 700; line-height: 1; }
.sb-brand-sub  { font-size: .7rem;   color: var(--muted); line-height: 1; margin-top: 2px; }
.sb-close {
  display: none; background: none; border: none; cursor: pointer;
  color: var(--muted); font-size: 16px; padding: 6px; border-radius: var(--radius-sm);
}
.sb-close:hover { background: var(--accent-light); color: var(--accent); }

.sb-nav {
  flex: 1; overflow-y: auto; padding: 10px 8px;
  scrollbar-width: thin; scrollbar-color: var(--border) transparent;
}
.sb-section {
  font-size: .68rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: var(--muted-light); padding: 12px 10px 4px;
}
.sb-link {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 10px; border-radius: var(--radius-sm);
  text-decoration: none; font-size: .845rem; font-weight: 500;
  color: var(--muted); transition: background .12s, color .12s;
  white-space: nowrap; overflow: hidden;
}
.sb-link:hover { background: var(--accent-light); color: var(--accent); }
.sb-link.act   { background: var(--accent-light); color: var(--accent); font-weight: 600; }
.sb-sub { margin-left: 8px; font-size: .815rem; padding: 5px 10px; }
.sb-loading { color: var(--muted); font-size: .845rem; padding: 12px 10px; }

.sb-bottom {
  border-top: 1px solid var(--border-light); padding: 10px 12px; flex-shrink: 0;
}
.sb-user { display: flex; align-items: center; gap: 9px; margin-bottom: 8px; }
.sb-user-img { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; }
.sb-user-text { overflow: hidden; min-width: 0; }
.sb-user-name { font-size: .845rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-user-role { font-size: .72rem; color: var(--muted); text-transform: capitalize; }
.sb-status-row { display: flex; align-items: center; justify-content: space-between; }
.sb-logout { font-size: .78rem; color: var(--muted); text-decoration: none; }
.sb-logout:hover { color: var(--error); }

.sb-overlay {
  display: none; position: fixed; inset: 0; z-index: 299;
  background: rgba(28,45,63,.4); backdrop-filter: blur(1px);
}
.sb-overlay.show { display: block; }

/* Main wrapper created by page transform */
.sidebar-main { display: flex; flex-direction: column; min-height: 100vh; }

/* Mobile top bar */
.mobile-topbar {
  display: none; height: 52px; align-items: center; gap: 12px;
  padding: 0 16px;
  background: var(--surface); border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-xs); position: sticky; top: 0; z-index: 100;
}
.sb-burger {
  background: none; border: none; cursor: pointer; font-size: 20px;
  color: var(--text); padding: 4px 8px; border-radius: var(--radius-sm); line-height: 1;
}
.sb-burger:hover { background: var(--accent-light); color: var(--accent); }
.sb-topbar-brand { font-weight: 700; font-size: .9rem; color: var(--text); text-decoration: none; }

/* ── Responsive sidebar ──────────────────────────────────────────────────── */
@media (max-width: 768px) {
  body { margin-left: 0; }
  .sidebar {
    transform: translateX(-100%); transition: transform .25s ease;
    box-shadow: none;
  }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .sb-close { display: block; }
  .mobile-topbar { display: flex; }
}

@media print {
  .sidebar, .mobile-topbar, .sb-overlay { display: none !important; }
  body { margin-left: 0 !important; }
}

/* ── Shared bien-card badge (used by index + dossier) ───────────────────── */
.bien-card-badge {
  font-size: .68rem; font-weight: 700; padding: 3px 8px;
  border-radius: 10px; white-space: nowrap;
  background: #E8F5E9; color: #2E7D32;
}
.bien-card-badge.off { background: var(--surface-alt); color: var(--muted); }
