
:root {
  --primary: #0d4c92;
  --primary-2: #0a386d;
  --accent: #21c6a7;
  --bg: #f6f9fb;
  --ink: #102a43;
  --muted: #5b708b;
  --radius: 18px;
  --shadow: 0 10px 30px rgba(16, 42, 67, 0.12);
  --border-soft: #d7e2ee;
  --danger: #ef4444;
}

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

html,
body {
  margin: 0;
  padding: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, #e0f2fe 0, transparent 55%),
    radial-gradient(circle at bottom right, #bbf7d0 0, transparent 55%),
    var(--bg);
}

/* Conteneurs principaux */

.page-login,
.page-prestataire,
.page-admin,
.page-index {
  min-height: 100vh;
  padding: 16px;
}

@media (min-width: 768px) {
  .page-login,
  .page-prestataire,
  .page-admin,
  .page-index {
    padding: 24px;
  }
}

.page-login {
  display: grid;
  place-items: center;
}

.shell {
  max-width: 960px;
  margin: 0 auto;
  background: #ffffff;
  border-radius: 24px;
  padding: 22px 18px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border-soft);
}

@media (min-width: 768px) {
  .shell {
    padding: 28px 24px;
  }
}

.centered-shell {
  display: grid;
  place-items: center;
}

.centered-shell .grid {
  width: 100%;
}

/* Titres & texte */

h1,
h2,
h3 {
  margin: 0;
  letter-spacing: 0.02em;
}

h1 {
  font-size: 1.4rem;
}

h2 {
  font-size: 1.1rem;
  margin-bottom: 0.4rem;
}

.muted {
  color: var(--muted);
  font-size: 0.85rem;
}

/* Cartes */

.card {
  background: #ffffff;
  border-radius: 20px;
  padding: 16px;
  border: 1px solid var(--border-soft);
  box-shadow: var(--shadow);
}

.card + .card {
  margin-top: 16px;
}

/* Grilles */

.grid {
  display: grid;
  gap: 16px;
}

/* Mise en page spécifique */

.page-login {
  display: grid;
  place-items: center;
}

.page-login .card {
  width: min(420px, 100%);
}

.page-prestataire > .grid {
  max-width: 1100px;
  margin: 0 auto;
}

.page-top {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  height: 32px;
  width: auto;
  opacity: 0.9;
}

.lock-wrapper {
  min-height: 60vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lock-card {
  width: min(420px, 100%);
}

.install-cta {
  display: none;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px dashed var(--border-soft);
  border-radius: 12px;
  background: #f8fafc;
  margin-top: 8px;
}

.install-help {
  display: none;
  font-size: 0.85rem;
  color: var(--muted);
}

@media (min-width: 960px) {
  .page-prestataire > .grid {
    grid-template-columns: 1.6fr 1.1fr;
    align-items: flex-start;
  }
}

.page-admin > .card,
.page-prestataire > .card,
.page-admin > .grid {
  max-width: 1280px;
  margin-left: auto;
  margin-right: auto;
}

.card {
  overflow-x: auto;
  max-width: 100%;
  overflow-y: hidden;
}

.admin-layout {
  display: grid;
  gap: 18px;
  overflow: hidden;
}

@media (min-width: 1200px) {
  .admin-layout {
    grid-template-columns: 1.5fr 1fr;
    align-items: start;
  }
}

.admin-col {
  min-width: 0;
}

.admin-col.secondary .card {
  margin-top: 0;
}

.logement-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.logement-carousel {
  grid-template-columns: 1fr;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.logement-carousel .logement-card {
  width: 100%;
}

.logement-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.logement-carousel {
  grid-template-columns: 1fr;
}

.logement-carousel .logement-card {
  width: 100%;
}

.collapsible-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
}

.collapsible .caret {
  font-size: 0.9rem;
  color: var(--muted);
}

.fab-chat {
  position: fixed;
  right: 18px;
  bottom: 18px;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
  font-size: 1.3rem;
  box-shadow: var(--shadow);
  cursor: pointer;
  z-index: 1000;
}

.chat-modal {
  position: fixed;
  inset: 0;
  display: none;
  z-index: 999;
}

.chat-modal.open {
  display: block;
}

.chat-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  animation: fadeIn 180ms ease;
}

.chat-panel {
  position: absolute;
  right: 8px;
  bottom: 80px;
  width: min(920px, 96vw);
  max-height: 80vh;
  background: #fff;
  border-radius: 16px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border-soft);
  padding: 12px;
  animation: slideUp 220ms ease;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

.burger {
  display: none;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid var(--border-soft);
  background: #fff;
  box-shadow: var(--shadow);
}

.admin-header {
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 10;
  padding: 6px 0 8px;
}

.mobile-nav {
  display: none;
  flex-direction: column;
  gap: 8px;
  padding: 8px 0;
}

.mobile-nav a {
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--border-soft);
  text-decoration: none;
  color: var(--ink);
  background: #fff;
}

.mobile-nav.open {
  display: flex;
}

@media (min-width: 1200px) {
  .admin-layout .grid {
    grid-template-columns: repeat(2, minmax(320px, 1fr));
  }
}

@media (max-width: 900px) {
  .burger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  .admin-layout {
    grid-template-columns: 1fr;
  }
  .admin-col.secondary {
    order: -1;
  }
  .fab-chat {
    bottom: 12px;
    right: 12px;
  }

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

@media (max-width: 640px) {
  .card {
    overflow-x: auto;
  }
  .messages-wrapper {
    grid-template-columns: 1fr;
  }
}

.messages-wrapper,
.threads-panel,
.conversation-panel {
  min-width: 0;
  overflow: auto;
}

/* Liens cartes pour index */

.page-index .grid {
  grid-template-columns: 1fr;
}

@media (min-width: 640px) {
  .page-index .grid {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  }
}

.page-index a.card {
  text-decoration: none;
  color: inherit;
  transition: transform 120ms ease, box-shadow 120ms ease, border-color 120ms ease;
  background: #f9fbff;
}

.page-index a.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.16);
  border-color: var(--accent);
}

.card .title {
  font-weight: 700;
  margin-bottom: 4px;
}

/* Boutons */

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px;
  border-radius: 999px;
  border: none;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  background: linear-gradient(135deg, var(--accent), #18a58d);
  color: #053334;
  box-shadow: var(--shadow);
  transition: transform 120ms ease, box-shadow 120ms ease, filter 120ms ease;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 30px rgba(15, 23, 42, 0.25);
  filter: brightness(1.02);
}

button:active {
  transform: translateY(0);
  box-shadow: 0 4px 10px rgba(15, 23, 42, 0.25);
}

.btn-ghost {
  background: #ffffff;
  color: var(--ink);
  box-shadow: none;
  border: 1px solid var(--border-soft);
}

.btn-ghost:hover {
  background: #f1f5f9;
}

/* Formulaires */

form {
  margin-top: 8px;
}

label {
  display: block;
  margin: 10px 0 4px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
}

input,
select,
textarea {
  width: 100%;
  padding: 10px 11px;
  border-radius: 12px;
  border: 1px solid #d2e0f0;
  font-size: 0.9rem;
  font-family: inherit;
  color: var(--ink);
  background: #ffffff;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}

textarea {
  resize: vertical;
  min-height: 90px;
}

/* Messages */

.msg {
  margin-top: 8px;
  min-height: 18px;
  font-size: 0.8rem;
  color: var(--danger);
}

/* Tableaux */

.table-wrapper {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-top: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  background: #ffffff;
  min-width: 620px;
}

th,
td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid #e2e8f0;
  vertical-align: top;
}

th {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  background: #f8fafc;
}

/* Badges & tags */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid #bfdbfe;
  background: #e0f2fe;
  font-size: 0.75rem;
  color: #075985;
}

.badge.terminée {
  background: #d1fae5;
  border-color: #a7f3d0;
  color: #065f46;
}

.badge.non-realisee,
.badge.non-réalisée {
  background: #fee2e2;
  border-color: #fecaca;
  color: #991b1b;
}

.tag {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  font-size: 0.75rem;
  margin-right: 6px;
  margin-bottom: 6px;
}

/* Logements */

.logement-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

@media (min-width: 768px) {
  .logement-grid {
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  }
}

.logement-card {
  border-radius: 16px;
  border: 1px solid var(--border-soft);
  padding: 12px;
  background: #ffffff;
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.06);
}

.logement-card h3 {
  font-size: 0.98rem;
  margin-bottom: 4px;
}

/* Toast */

.toast {
  position: fixed;
  left: 50%;
  bottom: 12px;
  transform: translate(-50%, 10px);
  padding: 10px 16px;
  border-radius: 999px;
  border: 1px solid #cbd5e1;
  background: #0f172a;
  color: #e5e7eb;
  font-size: 0.85rem;
  box-shadow: 0 20px 40px rgba(15, 23, 42, 0.45);
  opacity: 0;
  pointer-events: none;
  transition: all 160ms ease-out;
  max-width: calc(100% - 32px);
  z-index: 50;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* Messagerie */

.messages-wrapper {
  display: grid;
  gap: 12px;
}

@media (min-width: 900px) {
  .messages-wrapper {
    grid-template-columns: 280px 1fr;
  }
}

.threads-panel {
  border: 1px solid var(--border-soft);
  border-radius: 16px;
  padding: 12px;
  background: #f9fbff;
}

.threads-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  font-weight: 700;
}

.thread-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.thread-item {
  padding: 10px;
  border-radius: 12px;
  border: 1px solid var(--border-soft);
  background: #fff;
  cursor: pointer;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

.thread-item:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow);
}

.thread-item.active {
  border-color: var(--accent);
  box-shadow: var(--shadow);
  background: #f2fffb;
}

.thread-item .title {
  font-weight: 700;
}

.thread-item .meta {
  font-size: 0.82rem;
  color: var(--muted);
}

.unread-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  padding: 2px 6px;
  border-radius: 999px;
  background: #ef4444;
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  margin-left: 8px;
}

.conversation-panel {
  border: 1px solid var(--border-soft);
  border-radius: 16px;
  padding: 12px;
  background: #fff;
  display: flex;
  flex-direction: column;
  min-height: 280px;
}

.conversation-header {
  margin-bottom: 8px;
  font-weight: 700;
}

.messages-list {
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  padding: 10px;
  background: #f8fafc;
  max-height: 320px;
  overflow-y: auto;
}

.message-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 10px;
  padding: 10px;
  border-radius: 10px;
  background: #fff;
  border: 1px solid var(--border-soft);
}

.message-item.admin {
  background: #eef2ff;
  border-color: #c7d2fe;
}

.message-item.prestataire {
  background: #ecfeff;
  border-color: #bae6fd;
}

.message-meta {
  font-size: 0.8rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Responsive mobile fin */

@media (max-width: 640px) {
  h1 {
    font-size: 1.25rem;
  }

  h2 {
    font-size: 1.02rem;
  }

  .card {
    padding: 14px;
  }

  button {
    width: 100%;
  }

  table {
    min-width: 520px;
  }
}
