/* === Reset & base === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary:       #2B6A87;
  --primary-dark:  #1d4f68;
  --primary-light: #eaf5f7;
  --primary-mid:   #72C4C4;
  --orange:  #f57c00;
  --red:     #c62828;
  --blue:    #1565c0;
  --gray-bg:     #f3f7f8;
  --gray-border: #ddd;
  --text:        #1e3a4a;
  --text-light:  #607d8b;
  --surface:     white;
  --shadow: 0 2px 8px rgba(0,0,0,0.12);
  --radius: 6px;
  --font: 'Segoe UI', system-ui, sans-serif;
}

/* === Dark mode === */
[data-theme="dark"] {
  --gray-bg:     #0e1c26;
  --gray-border: #2a3f52;
  --text:        #cce3ee;
  --text-light:  #6fa0b8;
  --primary-light: #0c2535;
  --surface:     #162736;
  --shadow:      0 2px 8px rgba(0,0,0,0.5);
  color-scheme: dark;
}
[data-theme="dark"] body { background: var(--gray-bg); color: var(--text); }
[data-theme="dark"] input,
[data-theme="dark"] select,
[data-theme="dark"] textarea {
  background: var(--surface);
  color: var(--text);
  border-color: var(--gray-border);
}
/* Carte du site — fond sombre sur les bulles, texte clair */
[data-theme="dark"] .bm-box { background: #162736 !important; }
[data-theme="dark"] .bm-name { color: #cce3ee; }
[data-theme="dark"] .bm-floors { color: #6fa0b8; }

/* Vue bâtiment — titre en blanc */
[data-theme="dark"] .building-header h2 { color: white; }
[data-theme="dark"] .bm-box { border-color: var(--gray-border) !important; }
[data-theme="dark"] .desk-table thead tr { background: #1e3347; }
[data-theme="dark"] .desk-table tbody tr:hover { background: #1a2e3e !important; }
[data-theme="dark"] .desk-table th,
[data-theme="dark"] .desk-table td { border-color: var(--gray-border); color: var(--text); }
[data-theme="dark"] .floor-tab { background: var(--surface); color: var(--text); border-color: var(--gray-border); }
[data-theme="dark"] .floor-tab.active { background: var(--primary); color: white; }
[data-theme="dark"] .week-day { background: var(--surface); color: var(--text); border-color: var(--gray-border); }
[data-theme="dark"] .week-day.active { background: var(--primary); color: white; }
[data-theme="dark"] .legend { background: var(--surface); border-color: var(--gray-border); }
[data-theme="dark"] .my-booking-widget { background: var(--surface); border-color: var(--gray-border); }
[data-theme="dark"] .my-booking-widget.no-booking:hover { background: #1e3347; }
[data-theme="dark"] .btn-outline { background: transparent; border-color: rgba(255,255,255,0.35); }
[data-theme="dark"] .view-toggle button { background: var(--surface); color: var(--text); border-color: var(--gray-border); }
[data-theme="dark"] .view-toggle button.active { background: var(--primary); color: white; }
[data-theme="dark"] .export-dropdown .export-menu button:hover { background: var(--primary-light); }
[data-theme="dark"] .modal-overlay, [data-theme="dark"] #modal-overlay { background: rgba(0,0,0,0.7); }
[data-theme="dark"] .building-plan-container { background: #111e28; }
[data-theme="dark"] .suggestion-item:hover,
[data-theme="dark"] .org-select-option:hover { background: var(--primary-light); }

/* Plan SVG — murs en teinte primaire (teal) : noir → blanc → sepia → rotation teinte */
[data-theme="dark"] #plan-layer {
  filter: brightness(0) invert(1) sepia(1) hue-rotate(148deg) saturate(2) brightness(0.7);
}

/* Bureaux SVG */
[data-theme="dark"] .desk-group.free   .desk-rect { fill: #0d2e38; stroke: var(--primary-mid); }
[data-theme="dark"] .desk-group.free:hover .desk-rect { fill: #0f3a47; }
[data-theme="dark"] .desk-group.booked .desk-rect { fill: #3b1010; stroke: #ef5350; }
[data-theme="dark"] .desk-group.booked:hover .desk-rect { fill: #4a1515; }
[data-theme="dark"] .desk-group.fixed  .desk-rect { fill: #0d1e3d; stroke: #42a5f5; }
[data-theme="dark"] .desk-group.oos    .desk-rect { fill: #1e1e1e; stroke: #4a4a4a; }
[data-theme="dark"] .desk-group.mine   .desk-rect { fill: #0d2e15; stroke: #66bb6a; stroke-width: 2; }
[data-theme="dark"] .desk-group.mine:hover .desk-rect { fill: #0f3a1c; }
[data-theme="dark"] .desk-label { fill: #cce3ee; }

/* Légende */
[data-theme="dark"] .legend-item { color: var(--text-light); }
[data-theme="dark"] .legend-item.free::before   { background: #0d2e38; border-color: var(--primary-mid); }
[data-theme="dark"] .legend-item.booked::before,
[data-theme="dark"] .legend-item.busy::before   { background: #3b1010; border-color: #ef5350; }
[data-theme="dark"] .legend-item.full::before   { background: #4a1515; border-color: #ef5350; }
[data-theme="dark"] .legend-item.fixed::before  { background: #0d1e3d; border-color: #42a5f5; }
[data-theme="dark"] .legend-item.oos::before    { background: #1e1e1e; border-color: #4a4a4a; }
[data-theme="dark"] .legend-item.mine::before   { background: #0d2e15; border-color: #66bb6a; }

body {
  font-family: var(--font);
  background: var(--gray-bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* === Header === */
header {
  background: var(--primary);
  color: white;
  padding: 0 1.5rem;
  height: 56px;
  display: flex;
  align-items: center;
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
}

.logo {
  font-size: 1.1rem; font-weight: 600; letter-spacing: 0.02em;
  display: flex; align-items: center; gap: 0.6rem;
}
.logo-img {
  height: 36px;
  width: auto;
}

.app-footer {
  text-align: right;
  padding: 0.5rem 1.5rem;
  font-size: 0.7rem;
  color: var(--text-light);
  opacity: 0.55;
  pointer-events: none;
  user-select: none;
}

#user-area { display: flex; align-items: center; gap: 0.75rem; }
.btn-theme {
  background: none; border: none; cursor: pointer;
  font-size: 1.2rem; line-height: 1;
  color: white; opacity: 0.75;
  padding: 0.2rem 0.3rem;
  transition: opacity 0.15s, transform 0.2s;
}
.btn-theme:hover { opacity: 1; transform: scale(1.2); }

/* Bouton flottant pour le contexte Teams (header masqué) */
.btn-theme-teams {
  display: none;
  position: fixed;
  top: 0.5rem;
  right: 0.5rem;
  z-index: 500;
  color: var(--text-light);
  opacity: 0.5;
  font-size: 1rem;
}
body.in-teams .btn-theme-teams { display: block; }

#user-name {
  font-size: 0.9rem;
  opacity: 0.9;
}
#user-name.is-admin::after {
  content: ' ⭐';
  font-size: 0.8em;
}

/* === Main / Views === */
main { flex: 1; max-width: 1400px; margin: 0 auto; width: 100%; padding: 1.5rem; }

.view { width: 100%; }
.hidden { display: none !important; }

/* === Login === */
.login-box {
  max-width: 420px;
  margin: 5rem auto;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 2.5rem;
  box-shadow: var(--shadow);
  text-align: center;
}
.login-box h1 { color: var(--primary); margin-bottom: 0.75rem; }
.login-box p { color: var(--text-light); margin-bottom: 1.5rem; }

/* === Buttons === */
.btn-primary {
  background: var(--primary);
  color: white;
  border: none;
  padding: 0.5rem 1.25rem;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.95rem;
  transition: background 0.15s;
}
.btn-primary:hover { background: var(--primary-dark); }

.btn-large { padding: 0.85rem 2rem; font-size: 1.05rem; }

.btn-outline {
  background: transparent;
  color: white;
  border: 1.5px solid rgba(255,255,255,0.6);
  padding: 0.4rem 1rem;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.9rem;
  transition: border-color 0.15s;
}
.btn-outline:hover { border-color: white; }

.btn-danger {
  background: var(--red);
  color: white;
  border: none;
  padding: 0.4rem 0.9rem;
  border-radius: var(--radius);
  cursor: pointer;
}

.btn-sm { padding: 0.25rem 0.6rem; font-size: 0.85rem; }
.btn-back {
  background: none;
  border: none;
  color: var(--primary);
  cursor: pointer;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0;
}
.btn-back:hover { text-decoration: underline; }
.btn-icon {
  background: none;
  border: 1px solid var(--gray-border);
  border-radius: var(--radius);
  padding: 0.3rem 0.6rem;
  cursor: pointer;
  font-size: 1rem;
}
.btn-icon:hover { background: var(--gray-bg); }

/* === Site map === */
.site-map-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}
.site-map-header h2 { color: var(--primary); }

.site-map-container {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.site-map-container svg { width: 100%; height: auto; display: block; }

.date-nav { display: flex; align-items: center; gap: 0.5rem; }
.date-nav input[type=date] {
  border: 1px solid var(--gray-border);
  border-radius: var(--radius);
  padding: 0.3rem 0.6rem;
  font-size: 0.9rem;
}

/* SVG text styles */
.svg-watermark { font-size: 12px; fill: #999; }
.building-name { font-size: 11px; font-weight: 600; fill: #333; }
.building-count { font-size: 10px; fill: #555; }
.building-floors { font-size: 9px; fill: #888; }

/* === Building view === */
.building-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.building-header h2 { color: var(--primary); flex: 1; }
.building-actions { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }

.export-dropdown { position: relative; }
.export-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  background: var(--surface);
  border: 1px solid var(--gray-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  min-width: 220px;
  z-index: 200;
  overflow: hidden;
}
.export-menu button {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  padding: 0.6rem 1rem;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--text);
}
.export-menu button:hover { background: var(--primary-light); }
.export-menu button + button { border-top: 1px solid var(--gray-border); }

.view-toggle { display: flex; border: 1px solid var(--gray-border); border-radius: var(--radius); overflow: hidden; }
.view-toggle button {
  background: var(--surface);
  border: none;
  padding: 0.35rem 0.9rem;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background 0.15s;
}
.view-toggle button.active { background: var(--primary); color: white; }

.floor-tabs { display: flex; gap: 0.5rem; margin-bottom: 1rem; }
.floor-tab {
  background: var(--surface);
  border: 1.5px solid var(--gray-border);
  border-radius: var(--radius);
  padding: 0.4rem 1rem;
  cursor: pointer;
  font-size: 0.9rem;
}
.floor-tab.active { border-color: var(--primary); color: var(--primary); font-weight: 600; }

.building-plan-container {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 1rem;
}
.building-plan-container svg { width: 100%; height: auto; max-height: 75vh; display: block; }

/* === Desk SVG styles === */
.desk-rect { transition: fill 0.12s, stroke 0.12s; }

.desk-group.free .desk-rect { fill: var(--primary-light); stroke: var(--primary-mid); stroke-width: 1.5; }
.desk-group.free:hover .desk-rect { fill: #c4e8eb; }

.desk-group.booked .desk-rect { fill: #ffebee; stroke: var(--red); stroke-width: 1.5; }
.desk-group.booked:hover .desk-rect { fill: #ffcdd2; }

.desk-group.fixed .desk-rect { fill: #e3f2fd; stroke: var(--blue); stroke-width: 1.5; }
.desk-group.oos .desk-rect { fill: #f5f5f5; stroke: #bbb; stroke-width: 1; }

.desk-label { font-size: 10px; font-family: var(--font); fill: #222; pointer-events: none; letter-spacing: 0.01em; }
.booked-dot { fill: var(--red); }

/* Edit mode */
.building-plan-container svg.edit-mode { cursor: crosshair; }
.btn-icon.active { background: var(--primary); color: white; border-color: var(--primary); }

.desk-group.edit-desk .desk-rect { fill: #eef2ff; stroke: #6366f1; stroke-width: 1.5; stroke-dasharray: 5 3; }
/* Édition inline du label sur le plan */
.desk-inline-input {
  position: fixed;
  z-index: 500;
  text-align: center;
  background: transparent;
  border: 1.5px solid rgba(30, 120, 220, 0.75);
  border-radius: 3px;
  outline: none;
  font-family: var(--font);
  font-weight: 500;
  color: #111;
  padding: 0;
  box-sizing: border-box;
}

.rotate-handle-bg { fill: white; stroke: #aaa; stroke-width: 0.8; opacity: 0.9; }
.rotate-handle:hover .rotate-handle-bg { fill: var(--primary-light); stroke: var(--primary); }
.rotate-handle-icon { font-size: 9px; fill: #555; pointer-events: none; }
.rotate-handle:hover .rotate-handle-icon { fill: var(--primary); }
.desk-group.edit-desk.desk-fixed .desk-rect { fill: #e3f2fd; stroke: var(--blue); }
.desk-group.edit-desk.desk-out_of_service .desk-rect { fill: #f5f5f5; stroke: #bbb; }

/* Panneau édition de poste (clic en mode édition) */
.desk-edit-panel {
  position: fixed;
  background: var(--surface);
  border: 1px solid var(--gray-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0.75rem;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-width: 180px;
  transform: translateX(-50%);
}
.dep-row { display: flex; flex-direction: column; gap: 0.2rem; }
.dep-row label { font-size: 0.75rem; color: var(--text-light); font-weight: 500; }
.dep-row input, .dep-row select { padding: 0.3rem 0.5rem; border: 1px solid var(--gray-border); border-radius: 4px; font-size: 0.85rem; }
.dep-actions { display: flex; gap: 0.4rem; justify-content: flex-end; margin-top: 0.2rem; }
.btn-outline-dark { background: transparent; border: 1px solid var(--gray-border); color: var(--text); border-radius: var(--radius); padding: 0.25rem 0.6rem; cursor: pointer; font-size: 0.8rem; }
.btn-outline-dark:hover { background: var(--gray-bg); }
.dep-sizes { display: flex; gap: 0.3rem; }
.dep-size-btn { background: var(--surface); border: 1px solid var(--gray-border); border-radius: 4px; padding: 0.2rem 0.5rem; font-size: 0.8rem; font-weight: 600; cursor: pointer; color: var(--text); }
.dep-size-btn:hover { border-color: var(--primary); color: var(--primary); }
.dep-size-btn.active { background: var(--primary); color: white; border-color: var(--primary); }

/* === Edit toolbar === */
.edit-toolbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--primary-light);
  border: 1.5px solid var(--primary-mid);
  border-radius: var(--radius);
  padding: 0.65rem 1rem;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}
.edit-hint { flex: 1; font-size: 0.88rem; color: var(--primary-dark); }
.edit-toolbar input[type=text], .edit-toolbar select {
  border: 1px solid var(--gray-border);
  border-radius: var(--radius);
  padding: 0.35rem 0.6rem;
  font-size: 0.9rem;
}

/* === Desk table === */
.desk-table { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.desk-table th { background: var(--primary); color: white; padding: 0.65rem 1rem; text-align: left; font-size: 0.9rem; }
.desk-table td { padding: 0.55rem 1rem; border-bottom: 1px solid #eee; font-size: 0.9rem; }
.desk-table tr:last-child td { border-bottom: none; }
.desk-row.booked td:first-child { color: var(--red); }
.desk-row.free td:first-child { color: var(--primary); }
.desk-row.oos { opacity: 0.5; }

/* === Legend === */
.legend { display: flex; gap: 1rem; margin-top: 0.75rem; flex-wrap: wrap; }
.legend-item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--text-light);
}
.legend-item::before {
  content: '';
  width: 14px;
  height: 14px;
  border-radius: 3px;
  border: 1.5px solid;
}
.legend-item.free::before { background: var(--primary-light); border-color: var(--primary-mid); }
.legend-item.booked::before, .legend-item.busy::before { background: #ffebee; border-color: var(--red); }
.legend-item.full::before { background: #ffcdd2; border-color: var(--red); }
.legend-item.fixed::before { background: #e3f2fd; border-color: var(--blue); }
.legend-item.oos::before { background: #f5f5f5; border-color: #bbb; }

/* === Modal === */
#modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}
#modal-box {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
  padding: 2rem;
  max-width: 520px;
  width: 95%;
  position: relative;
  max-height: 90vh;
  overflow-y: auto;
}
#modal-close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  color: var(--text-light);
}

/* === Forms === */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-size: 0.88rem; color: var(--text-light); margin-bottom: 0.3rem; }
.form-group input, .form-group select, .form-group textarea {
  width: 100%;
  border: 1px solid var(--gray-border);
  border-radius: var(--radius);
  padding: 0.45rem 0.75rem;
  font-size: 0.95rem;
  font-family: var(--font);
}
.form-group input[readonly] { background: var(--gray-bg); }
.form-actions { display: flex; gap: 0.75rem; justify-content: flex-end; margin-top: 1.25rem; }

.recurrence-section { margin-top: 0.5rem; }
.recurrence-section summary { cursor: pointer; color: var(--primary); font-size: 0.9rem; margin-bottom: 0.5rem; }

.day-picker { display: flex; gap: 0.75rem; flex-wrap: wrap; }
.day-picker label { display: flex; align-items: center; gap: 0.3rem; font-size: 0.88rem; cursor: pointer; }

/* Avatars */
.header-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  object-fit: cover;
  border: 1.5px solid rgba(255,255,255,0.55);
  flex-shrink: 0;
}
.header-avatar-initials {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-mid);
  color: white;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
  user-select: none;
}
.tt-row { display: flex; align-items: center; gap: 0.5rem; }
.tt-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 1.5px solid rgba(255,255,255,0.3);
}
.sugg-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--primary-light);
}
.booking-for-select {
  width: 100%;
  border: 1px solid var(--gray-border);
  border-radius: var(--radius);
  padding: 0.45rem 0.75rem;
  font-size: 0.95rem;
  font-family: var(--font);
}

/* Suggestions dropdown */
.suggestions-dropdown {
  border: 1px solid var(--gray-border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  max-height: 200px;
  overflow-y: auto;
  margin-top: 2px;
}
.suggestion-item {
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.6rem;
}
.suggestion-item:hover { background: var(--primary-light); }
.suggestion-item small { color: var(--text-light); font-size: 0.8rem; }
.selected-user { font-size: 0.85rem; color: var(--primary); margin-top: 0.25rem; display: block; }

/* === Org select (dropdown avec avatars) === */
.org-select { position: relative; }
.org-select-trigger {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--gray-border);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  user-select: none;
}
.org-select-trigger:focus { outline: 2px solid var(--primary); outline-offset: 1px; }
.org-select-trigger span:first-of-type { flex: 1; }
.org-select-arrow { font-size: 0.7rem; color: var(--text-light); }
.org-select-list {
  position: absolute; left: 0; right: 0; z-index: 200;
  border: 1px solid var(--gray-border);
  border-radius: var(--radius);
  background: var(--surface);
  max-height: 220px;
  overflow-y: auto;
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
  margin-top: 2px;
}
.org-select-option {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.45rem 0.75rem;
  cursor: pointer;
}
.org-select-option:hover { background: var(--primary-light); }
.org-select-option small { color: var(--text-light); font-size: 0.8rem; }
.org-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  display: none;
}

/* === Table avatars === */
.table-user { display: flex; align-items: center; gap: 0.4rem; }
.table-avatar {
  width: 24px; height: 24px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  display: none;
}

/* === Mes réservations === */
.mybk-header {
  display: flex; align-items: center; gap: 1rem;
  margin-bottom: 1.5rem;
}
.mybk-header h2 { color: var(--primary); }
[data-theme="dark"] .mybk-header h2 { color: white; }
.mybk-empty {
  display: flex; flex-direction: column; align-items: center;
  gap: 0.75rem; margin-top: 4rem; color: var(--text-light);
}
.mybk-empty .mbw-icon { font-size: 2.5rem; }
.mybk-list { display: flex; flex-direction: column; gap: 0.75rem; max-width: 700px; }
.mybk-item {
  display: flex; align-items: center; gap: 1rem;
  background: var(--surface); border: 1px solid var(--gray-border);
  border-radius: var(--radius); padding: 0.75rem 1rem;
  box-shadow: var(--shadow);
}
.mybk-item.mybk-past { opacity: 0.55; }
.mybk-date { font-size: 0.82rem; color: var(--text-light); min-width: 200px; }
.mybk-info { flex: 1; display: flex; align-items: center; flex-wrap: wrap; gap: 0.3rem; font-size: 0.9rem; }
.mybk-building { color: var(--primary); cursor: pointer; font-weight: 600; }
.mybk-building:hover { text-decoration: underline; }
.mybk-sep { color: var(--text-light); }
.mybk-note { font-size: 0.8rem; color: var(--text-light); font-style: italic; margin-left: 0.5rem; }
.mybk-cancel { margin-left: auto; flex-shrink: 0; }
/* Bureau favori */
.desk-group.fav .desk-rect { stroke-width: 2.5; stroke-dasharray: 5 2; }
.fav-star { font-size: 9px; fill: #f57c00; pointer-events: none; }
.btn-fav { background: none; border: none; padding: 0 0.25rem; font-size: 1rem; line-height: 1; cursor: pointer; color: var(--text-light); }
.btn-fav:hover, .btn-fav.is-fav { color: #f57c00; }
.desk-actions-cell { white-space: nowrap; }
.my-booking-widget.fav-hint { cursor: pointer; border-left: 3px solid #f57c00; }
.fav-star-icon { color: #f57c00; }

.mybk-none { color: var(--text-light); font-size: 0.9rem; margin: 0; }
.mybk-toggle-past { align-self: flex-start; margin-top: 0.25rem; font-size: 0.82rem; color: var(--text-light); }
.btn-mybookings { font-size: 0.85rem; padding: 0.3rem 0.75rem; }

/* === Recherche universelle === */
.search-container {
  flex: 1;
  max-width: 480px;
  margin: 0 1.5rem;
  position: relative;
}
.search-input {
  width: 100%;
  padding: 0.4rem 0.9rem;
  border-radius: 20px;
  border: none;
  background: rgba(255,255,255,0.15);
  color: white;
  font-size: 0.9rem;
  outline: none;
  transition: background 0.2s;
}
.search-input::placeholder { color: rgba(255,255,255,0.6); }
.search-input:focus { background: rgba(255,255,255,0.25); }
.search-input::-webkit-search-cancel-button { filter: invert(1) opacity(0.6); cursor: pointer; }

.search-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0; right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.15);
  z-index: 1000;
  overflow: hidden;
  max-height: 420px;
  overflow-y: auto;
}
.sr-section {
  padding: 0.45rem 0.9rem 0.2rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-light);
}
.sr-divider { height: 1px; background: var(--border); margin: 0.25rem 0; }
.sr-loading, .sr-empty { padding: 0.9rem; text-align: center; color: var(--text-light); font-size: 0.9rem; }
.sr-item {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.55rem 0.9rem;
  cursor: pointer;
  transition: background 0.12s;
}
.sr-item:hover { background: var(--gray-bg); }
.sr-desk-icon { font-size: 1rem; flex-shrink: 0; }
.sr-item-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 0.05rem; }
.sr-name { font-size: 0.9rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sr-sub { font-size: 0.78rem; color: var(--text-light); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sr-badge {
  font-size: 0.75rem; font-weight: 600;
  padding: 0.15rem 0.5rem; border-radius: 10px;
  flex-shrink: 0;
}
.sr-free  { background: #e8f5e9; color: #2e7d32; }
.sr-busy  { background: #ffebee; color: #c62828; }
.sr-fixed { background: #e3f2fd; color: #1565c0; }
.sr-mine  { background: #e8f5e9; color: #1b5e20; }

/* Avatar collègue dans les résultats */
.sr-avatar-wrap { position: relative; flex-shrink: 0; }
.sr-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  object-fit: cover; display: block;
}
.sr-initials {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--primary-mid, #2B6A87);
  color: white; font-size: 0.75rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.sr-dot {
  position: absolute; bottom: 0; right: 0;
  width: 9px; height: 9px; border-radius: 50%;
  border: 2px solid var(--surface);
}
.sr-dot-green { background: #43a047; }
.sr-dot-gray  { background: #9e9e9e; }

/* Modale semaine collègue */
.uwm { min-width: 320px; }
.uwm-header { margin-bottom: 1rem; }
.uwm-name { font-size: 1.1rem; display: block; }
.uwm-week-label { font-size: 0.82rem; color: var(--text-light); }
.uwm-days { display: flex; flex-direction: column; gap: 0.4rem; }
.uwm-day {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.45rem 0.6rem; border-radius: 7px;
  background: var(--gray-bg);
}
.uwm-today { background: color-mix(in srgb, var(--primary) 10%, transparent); font-weight: 600; }
.uwm-day-name { font-size: 0.82rem; color: var(--text-light); min-width: 48px; flex-shrink: 0; }
.uwm-today .uwm-day-name { color: var(--primary); font-weight: 700; }
.uwm-status { flex: 1; font-size: 0.88rem; }
.uwm-loading { color: var(--text-light); }
.uwm-absent { color: var(--text-light); }
.uwm-link {
  color: var(--primary); text-decoration: none; cursor: pointer;
  font-size: 0.88rem;
}
.uwm-link:hover { text-decoration: underline; }

[data-theme="dark"] .sr-free  { background: #1b2e1c; color: #81c784; }
[data-theme="dark"] .sr-busy  { background: #2e1a1a; color: #ef9a9a; }
[data-theme="dark"] .sr-fixed { background: #1a2535; color: #90caf9; }
[data-theme="dark"] .sr-mine  { background: #1b2e1c; color: #a5d6a7; }

/* === Toast === */
#toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius);
  font-size: 0.95rem;
  box-shadow: var(--shadow);
  z-index: 2000;
  animation: slideIn 0.2s ease;
}
.toast-success { background: var(--primary); color: white; }
.toast-error { background: var(--red); color: white; }
.toast-info { background: var(--primary-mid); color: white; }

@keyframes slideIn {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* === Leaflet map === */
#leaflet-map {
  height: 75vh;
  min-height: 400px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

/* Marqueurs bâtiments */
.building-marker { background: none; border: none; }
.bm-box {
  border: 2px solid;
  border-radius: 6px;
  padding: 4px 7px;
  white-space: normal;
  word-break: break-word;
  max-width: 95px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.18);
  cursor: pointer;
  font-family: var(--font);
  text-align: center;
  transition: transform 0.1s;
  line-height: 1.25;
}
.bm-box:hover { transform: scale(1.04); }
.bm-name { font-weight: 600; font-size: 11px; color: #212121; }
.bm-count { font-size: 9.5px; font-weight: 500; }
.bm-floors { font-size: 8.5px; color: #888; }
.bm-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  margin: 2px auto 0;
}

/* === Responsive mobile (≤ 640px) === */
@media (max-width: 640px) {
  /* Base */
  main { padding: 0.75rem; }

  /* Header */
  .logo { font-size: 0.85rem; }
  #user-name { display: none; }

  /* Site map */
  .site-map-header { flex-direction: column; align-items: flex-start; gap: 0.5rem; }
  #leaflet-map { height: 55vh; min-height: 260px; }

  /* Building header — empile titre + actions */
  .building-header { flex-direction: column; align-items: flex-start; gap: 0.5rem; }
  .building-header h2 { font-size: 1.1rem; }
  .building-actions { width: 100%; justify-content: space-between; gap: 0.5rem; }

  /* Date nav — compact */
  .date-nav input[type=date] { font-size: 0.8rem; padding: 0.2rem 0.35rem; }

  /* Floor tabs — scroll horizontal */
  .floor-tabs { overflow-x: auto; flex-wrap: nowrap; padding-bottom: 0.25rem; -webkit-overflow-scrolling: touch; }
  .floor-tab { white-space: nowrap; flex-shrink: 0; padding: 0.3rem 0.75rem; }

  /* Plan SVG — hauteur réduite + blocage zoom navigateur pour pinch custom */
  .building-plan-container { touch-action: none; }
  .building-plan-container svg { max-height: 55vh; overflow: visible; }

  /* Table — scroll horizontal */
  .desk-table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--radius); box-shadow: var(--shadow); }
  .desk-table { min-width: 520px; box-shadow: none; border-radius: 0; }

  /* Modal — padding réduit, pleine largeur */
  #modal-box { padding: 1.25rem; width: 98%; }

  /* Toast — centré en bas */
  #toast { right: 0.75rem; left: 0.75rem; text-align: center; bottom: 1rem; }

  /* Bouton édition caché sur mobile (trop complexe au toucher) */
  #btn-edit-mode { display: none; }

  /* Formulaire réservation — champs heure côte à côte */
  .form-actions { flex-direction: column; }
  .form-actions button { width: 100%; }
}

/* === Contexte Teams (onglet intégré) === */
/* Teams fournit son propre chrome (barre de titre, identité) — on allège l'UI */
body.in-teams header { display: none; }
body.in-teams main { padding-top: 0.75rem; }

/* === Loading / Error === */
.loading, .error {
  text-align: center;
  padding: 3rem;
  color: var(--text-light);
}
.error { color: var(--red); }

@keyframes spin {
  to { transform: rotate(360deg); }
}
.loading::before {
  content: '';
  display: inline-block;
  width: 22px; height: 22px;
  border: 3px solid var(--primary-light);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
  margin-right: 0.5rem;
}

/* === Booking confirmation banner === */
@keyframes confirmSlideIn {
  from { transform: translateX(-50%) translateY(-24px); opacity: 0; }
  to   { transform: translateX(-50%) translateY(0);     opacity: 1; }
}
@keyframes confirmSlideOut {
  from { transform: translateX(-50%) translateY(0);     opacity: 1; }
  to   { transform: translateX(-50%) translateY(-24px); opacity: 0; }
}
@keyframes checkDraw {
  from { stroke-dashoffset: 60; }
  to   { stroke-dashoffset: 0; }
}
@keyframes circlePop {
  0%   { transform: scale(0.6); }
  65%  { transform: scale(1.12); }
  100% { transform: scale(1); }
}

#booking-confirm {
  position: fixed;
  top: 72px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 3000;
  background: #2e7d32;
  color: white;
  border-radius: 12px;
  padding: 0.85rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  box-shadow: 0 8px 28px rgba(0,0,0,0.22);
  animation: confirmSlideIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
  min-width: 260px;
  max-width: 400px;
  white-space: nowrap;
}
#booking-confirm.out { animation: confirmSlideOut 0.3s ease forwards; }
.bk-check-svg {
  width: 40px; height: 40px; flex-shrink: 0;
  animation: circlePop 0.4s 0.1s ease both;
}
.bk-check-svg circle { fill: rgba(255,255,255,0.18); }
.bk-check-path {
  stroke: white; stroke-width: 2.5;
  stroke-linecap: round; stroke-linejoin: round;
  fill: none;
  stroke-dasharray: 60; stroke-dashoffset: 60;
  animation: checkDraw 0.45s 0.25s ease forwards;
}
#booking-confirm strong { display: block; font-size: 1rem; }
#booking-confirm small  { opacity: 0.85; font-size: 0.88rem; }

/* === Desk tooltip === */
#desk-tooltip {
  position: fixed;
  z-index: 5000;
  background: rgba(30, 58, 74, 0.93);
  color: white;
  border-radius: var(--radius);
  padding: 0.35rem 0.7rem;
  font-size: 0.82rem;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.1s;
  line-height: 1.5;
  max-width: 220px;
}
#desk-tooltip.visible { opacity: 1; }
#desk-tooltip strong { display: block; font-size: 0.88rem; }
#desk-tooltip span    { display: block; opacity: 0.8; }

/* Week label in building date-nav */
.week-label-building {
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-light);
  min-width: 120px;
  text-align: center;
}

/* Week dots on SVG desks */
.week-dot { cursor: pointer; }
.week-dot:hover {
  stroke: rgba(255,255,255,0.95);
  stroke-width: 2.5;
}
@media (hover: none) and (pointer: coarse) {
  .week-dot { pointer-events: none; }
}

/* === Week navigation === */
.site-map-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.week-nav-row {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0.65rem 1rem;
  margin-bottom: 1rem;
}
.week-nav-top {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.6rem;
}
.week-label {
  flex: 1;
  text-align: center;
  font-size: 0.88rem;
  color: var(--text-light);
  font-weight: 500;
}
.week-days {
  display: flex;
  gap: 0.5rem;
}
.week-day {
  flex: 1;
  background: var(--surface);
  border: 1.5px solid var(--gray-border);
  border-radius: var(--radius);
  padding: 0.5rem 0.25rem 0.4rem;
  cursor: pointer;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.1rem;
  transition: border-color 0.15s, background 0.15s;
}
.week-day:hover { border-color: var(--primary-mid); background: var(--primary-light); }
.week-day.active {
  border-color: var(--primary);
  background: var(--primary);
  color: white;
}
.wd-name { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; opacity: 0.65; }
.week-day.active .wd-name { opacity: 0.8; }
.wd-date { font-size: 1.2rem; font-weight: 700; line-height: 1.1; }
.wd-count { font-size: 0.72rem; font-weight: 600; color: var(--primary); min-height: 1em; }
.week-day.active .wd-count { color: rgba(255,255,255,0.9); }
.wd-count.busy { color: #2e7d32; }

@media (max-width: 640px) {
  .site-map-controls { flex-wrap: wrap; gap: 0.35rem; }
  .week-days { gap: 0.2rem; }
  .week-day { padding: 0.4rem 0.1rem; }
  .wd-date { font-size: 1rem; }
  .week-label { font-size: 0.8rem; }
}

/* === Mine desk (réservé par l'utilisateur connecté) === */
.desk-group.mine .desk-rect { fill: #e8f5e9; stroke: #2e7d32; stroke-width: 2; }
.desk-group.mine:hover .desk-rect { fill: #c8e6c9; }
.legend-item.mine::before { background: #e8f5e9; border-color: #2e7d32; }

/* === Widget "Ma réservation" === */
.my-booking-widget {
  background: var(--surface);
  border-radius: var(--radius);
  border-left: 4px solid var(--primary);
  box-shadow: var(--shadow);
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  transition: background 0.15s;
}
.my-booking-widget:hover { background: var(--primary-light); }
.my-booking-widget.no-booking {
  cursor: default;
  border-left-color: var(--gray-border);
}
.my-booking-widget.no-booking:hover { background: var(--surface); }
.mbw-icon { font-size: 1.5rem; line-height: 1; }
.mbw-text strong { display: block; font-size: 0.95rem; color: var(--text); }
.mbw-text small { color: var(--text-light); font-size: 0.85rem; }
