/* =====================================================================
   HOTELIA - Feuille de style principale
   Objectif : comprendre l etat de l hotel en moins de 5 secondes.
   Barre laterale sombre, zone de travail claire, cartes de chambres
   colorees, boutons larges, lisible sur telephone comme sur ordinateur.
   ===================================================================== */

:root {
  --side-bg:        #111827;
  --side-bg-soft:   #1b2436;
  --side-text:      #cbd5e1;
  --side-text-dim:  #94a3b8;
  --side-active:    #2563eb;

  --bg:             #f4f6fa;
  --surface:        #ffffff;
  --border:         #e3e8ef;
  --text:           #1e293b;
  --text-dim:       #64748b;

  --ok:        #16a34a;  --ok-bg:   #eafaef;  --ok-br:   #b7ebc6;
  --busy:      #dc2626;  --busy-bg: #fdeceb;  --busy-br: #f7c2bf;
  --booked:    #ea8600;  --booked-bg:#fff5e6; --booked-br:#fbdca6;
  --clean:     #2563eb;  --clean-bg:#eaf1fe;  --clean-br:#c2d6fb;
  --off:       #64748b;  --off-bg:  #f1f3f7;  --off-br:  #d8dde6;

  --radius:    14px;
  --shadow:    0 1px 2px rgba(16,24,40,.06), 0 6px 18px rgba(16,24,40,.05);
  --shadow-lg: 0 12px 34px rgba(16,24,40,.14);
  --sidebar-w: 250px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  -webkit-text-size-adjust: 100%;
}

/* ---------- Structure ------------------------------------------------ */
.layout { display: flex; min-height: 100vh; }

.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.content { padding: 20px; flex: 1; }

@media (max-width: 575.98px) { .content { padding: 12px; } }

/* ---------- Barre laterale ------------------------------------------- */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--side-bg);
  color: var(--side-text);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 1040;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  min-height: 68px;
}
.sidebar-brand img { max-height: 34px; max-width: 130px; border-radius: 6px; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 10px;
  background: var(--side-active);
  display: grid; place-items: center;
  color: #fff; font-size: 17px;
}
.brand-text {
  font-weight: 700; color: #fff; font-size: 1.02rem; line-height: 1.15;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sidebar-close {
  margin-left: auto; background: none; border: 0; color: var(--side-text);
  font-size: 20px; padding: 4px 8px;
}

.sidebar-nav { padding: 12px 10px; overflow-y: auto; flex: 1; }

.sidebar .nav-link {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  margin-bottom: 3px;
  border-radius: 10px;
  color: var(--side-text);
  text-decoration: none;
  font-weight: 500;
  transition: background .12s ease, color .12s ease;
}
.sidebar .nav-link i { width: 20px; text-align: center; font-size: 16px; opacity: .9; }
.sidebar .nav-link:hover { background: var(--side-bg-soft); color: #fff; }
.sidebar .nav-link.active { background: var(--side-active); color: #fff; }
.sidebar .nav-link.active i { opacity: 1; }

.sidebar-footer { padding: 10px; border-top: 1px solid rgba(255,255,255,.08); }
.sidebar-footer .nav-link span { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.sidebar-footer strong { color: #fff; font-size: .92rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-footer small { color: var(--side-text-dim); font-size: .76rem; }
.nav-logout:hover { background: #7f1d1d !important; color: #fff !important; }

.sidebar-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(15,23,42,.55);
  z-index: 1035;
}

@media (max-width: 991.98px) {
  .sidebar {
    position: fixed; left: 0; top: 0;
    transform: translateX(-100%);
    transition: transform .22s ease;
    box-shadow: var(--shadow-lg);
  }
  body.sidebar-open .sidebar { transform: translateX(0); }
  body.sidebar-open .sidebar-backdrop { display: block; }
  body.sidebar-open { overflow: hidden; }
}

/* ---------- Barre superieure ----------------------------------------- */
.topbar {
  position: sticky; top: 0; z-index: 1020;
  display: flex; align-items: center; gap: 12px;
  padding: 12px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  min-height: 68px;
}
.topbar-title {
  font-size: 1.18rem; font-weight: 700; margin: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.btn-icon {
  background: none; border: 1px solid var(--border); border-radius: 10px;
  width: 42px; height: 42px; font-size: 17px; color: var(--text);
}
.btn-topbar { white-space: nowrap; }

/* Cloche des avis a l administration, avec sa pastille de non-lus. */
.btn-bell {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  text-decoration: none; flex: 0 0 auto;
}
.btn-bell .bell-count {
  position: absolute; top: -6px; right: -6px; min-width: 18px; height: 18px;
  padding: 0 5px; border-radius: 999px; background: var(--busy); color: #fff;
  font-size: .68rem; font-weight: 700; line-height: 18px; text-align: center;
}
.btn-bell .bell-count[hidden] { display: none; }

.topbar-search { position: relative; margin-left: auto; flex: 0 1 360px; min-width: 0; }
.topbar-search > i {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  color: var(--text-dim); pointer-events: none;
}
.topbar-search input {
  width: 100%; height: 44px;
  padding: 0 14px 0 40px;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--bg); font-size: .95rem;
}
.topbar-search input:focus { outline: 2px solid var(--side-active); outline-offset: -1px; background: #fff; }

.search-results {
  position: absolute; top: 52px; left: 0; right: 0;
  background: #fff; border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow-lg); max-height: 62vh; overflow-y: auto; z-index: 1200;
}
.search-results a {
  display: flex; gap: 12px; align-items: center;
  padding: 11px 14px; text-decoration: none; color: var(--text);
  border-bottom: 1px solid var(--border);
}
.search-results a:last-child { border-bottom: 0; }
.search-results a:hover, .search-results a.is-active { background: var(--clean-bg); }
.search-results .sr-icon {
  width: 34px; height: 34px; border-radius: 9px; background: var(--bg);
  display: grid; place-items: center; color: var(--text-dim); flex-shrink: 0;
}
.search-results .sr-title { font-weight: 600; font-size: .93rem; }
.search-results .sr-sub { font-size: .8rem; color: var(--text-dim); }
.search-empty { padding: 16px; color: var(--text-dim); text-align: center; font-size: .9rem; }

@media (max-width: 767.98px) {
  .topbar { flex-wrap: wrap; padding: 10px 12px; }
  .topbar-title { font-size: 1.05rem; order: 1; }
  .topbar-search { order: 3; flex: 1 1 100%; margin-left: 0; }
  .btn-topbar { order: 2; }
}

/* ---------- Cartes et blocs ------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-header {
  background: transparent;
  border-bottom: 1px solid var(--border);
  padding: 14px 18px;
  font-weight: 700;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.card-body { padding: 18px; }

.section-title {
  font-size: .78rem; text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-dim); font-weight: 700; margin: 22px 0 10px;
}

/* ---------- Tuiles de statistiques ------------------------------------ */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(165px, 1fr));
  gap: 14px;
}
.stat {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 18px;
  box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 14px;
  text-decoration: none; color: inherit;
}
a.stat:hover { border-color: #c7d2fe; box-shadow: var(--shadow-lg); }
.stat-icon {
  width: 46px; height: 46px; border-radius: 12px;
  display: grid; place-items: center; font-size: 19px; flex-shrink: 0;
}
.stat > span:last-child { min-width: 0; }
.stat-value { display: block; font-size: 1.6rem; font-weight: 800; line-height: 1.05; }
.stat-label { display: block; font-size: .82rem; color: var(--text-dim); font-weight: 600; margin-top: 2px; }
.stat-money .stat-value { font-size: 1.28rem; }

.i-ok    { background: var(--ok-bg);     color: var(--ok); }
.i-busy  { background: var(--busy-bg);   color: var(--busy); }
.i-book  { background: var(--booked-bg); color: var(--booked); }
.i-clean { background: var(--clean-bg);  color: var(--clean); }
.i-off   { background: var(--off-bg);    color: var(--off); }

/* ---------- Filtres ---------------------------------------------------- */
.filters {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px; margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.filters .form-label { font-size: .78rem; font-weight: 700; color: var(--text-dim); margin-bottom: 4px; }
.form-control, .form-select { min-height: 44px; border-radius: 10px; border-color: var(--border); }
.form-control:focus, .form-select:focus { border-color: var(--side-active); box-shadow: 0 0 0 3px rgba(37,99,235,.14); }
.form-label { font-weight: 600; font-size: .88rem; }

/* Legende des couleurs */
.legend { display: flex; flex-wrap: wrap; gap: 8px; }
.legend span,
.legend .legend-chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: .8rem; font-weight: 600; padding: 5px 11px; border-radius: 999px;
  border: 1px solid transparent;
}
.legend .dot { width: 10px; height: 10px; border-radius: 50%; }

/* Pastilles cliquables : elles filtrent le plan sur un etat. */
.legend .legend-chip {
  text-decoration: none; cursor: pointer;
  transition: transform .08s ease, box-shadow .12s ease;
}
.legend .legend-chip:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.legend .legend-chip:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.legend .legend-chip.is-on {
  border-width: 2px; padding: 4px 10px;
  box-shadow: inset 0 0 0 1px currentColor;
}

/* ---------- Cartes de chambres ----------------------------------------- */
.room-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(215px, 1fr));
  gap: 14px;
}
@media (max-width: 400px) { .room-grid { grid-template-columns: 1fr; } }

.room-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 6px solid var(--off);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  display: flex; flex-direction: column; gap: 8px;
  min-height: 190px;
  transition: transform .12s ease, box-shadow .12s ease;
}
.room-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }

.room-card .room-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.room-num { font-size: 1.75rem; font-weight: 800; line-height: 1; }
.room-cat { font-size: .78rem; font-weight: 700; color: var(--text-dim); text-transform: uppercase; letter-spacing: .04em; }
.room-price { font-size: 1.02rem; font-weight: 700; }
.room-meta { font-size: .82rem; color: var(--text-dim); }
.room-guest { font-size: .88rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.room-actions { margin-top: auto; display: flex; flex-direction: column; gap: 7px; }
.room-actions .btn { min-height: 42px; font-weight: 700; }

.room-badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: .78rem; font-weight: 800; letter-spacing: .04em;
  padding: 5px 11px; border-radius: 999px; text-transform: uppercase;
}
.room-floor {
  font-size: .72rem; color: var(--text-dim); background: var(--bg);
  padding: 3px 8px; border-radius: 6px; font-weight: 600;
}

/* La couleur s applique aussi bien a la carte (descendant) qu au badge seul. */
.room-card.st-AVAILABLE   { border-left-color: var(--ok); }
.room-card.st-OCCUPIED    { border-left-color: var(--busy); }
.room-card.st-RESERVED    { border-left-color: var(--booked); }
.room-card.st-CLEANING    { border-left-color: var(--clean); }
.room-card.st-MAINTENANCE { border-left-color: var(--off); }

.st-AVAILABLE   .room-badge, .room-badge.st-AVAILABLE   { background: var(--ok-bg);     color: var(--ok); }
.st-OCCUPIED    .room-badge, .room-badge.st-OCCUPIED    { background: var(--busy-bg);   color: var(--busy); }
.st-RESERVED    .room-badge, .room-badge.st-RESERVED    { background: var(--booked-bg); color: var(--booked); }
.st-CLEANING    .room-badge, .room-badge.st-CLEANING    { background: var(--clean-bg);  color: var(--clean); }
.st-MAINTENANCE .room-badge, .room-badge.st-MAINTENANCE { background: var(--off-bg);    color: var(--off); }

.room-warn {
  font-size: .76rem; font-weight: 700; color: var(--busy);
  background: var(--busy-bg); border-radius: 8px; padding: 4px 8px;
}
.room-note {
  font-size: .76rem; font-weight: 600; color: var(--booked);
  background: var(--booked-bg); border-radius: 8px; padding: 4px 8px;
}

/* ---------- Boutons ---------------------------------------------------- */
.btn { border-radius: 10px; font-weight: 600; }
.btn-lg, .btn-big { min-height: 52px; font-size: 1.02rem; font-weight: 700; border-radius: 12px; }
.btn-primary { background: var(--side-active); border-color: var(--side-active); }
.btn-success { background: var(--ok); border-color: var(--ok); }
.btn-danger  { background: var(--busy); border-color: var(--busy); }
.btn-warning { background: var(--booked); border-color: var(--booked); color: #fff; }
.btn-warning:hover { color: #fff; }

.action-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; }

/* ---------- Tableaux --------------------------------------------------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius); }
.table { margin: 0; }
.table > thead > tr > th {
  background: #f8fafc; font-size: .76rem; text-transform: uppercase;
  letter-spacing: .04em; color: var(--text-dim); border-bottom: 2px solid var(--border);
  white-space: nowrap; padding: 11px 12px;
}
.table > tbody > tr > td { padding: 11px 12px; vertical-align: middle; }
.table-hover > tbody > tr:hover > * { background: #f8fbff; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Tableau etroit : place dans une demi-colonne, il doit montrer TOUTES
   ses colonnes sans barre de defilement. Les titres passent a la ligne
   au lieu de pousser le tableau hors de l ecran. */
/* Les titres passent a la ligne aux espaces et aux <br> voulus, jamais
   au milieu d un mot : "STO CK THE ORI QUE" ne se lit pas. */
.table-tight > thead > tr > th { white-space: normal; line-height: 1.15; padding: 9px 6px; }
.table-tight > tbody > tr > td { padding: 9px 6px; }
/* Les mentions en petit sous un chiffre (cout d achat, date du dernier
   comptage) ne doivent pas elargir leur colonne. */
.table-tight .num .help-text { white-space: normal; }
.table-tight .col-act { width: 1%; }
.table-tight .col-act .btn { padding: 4px 9px; }
/* Sur un telephone, chaque pixel compte : on resserre encore. */
@media (max-width: 575.98px) {
  .table-tight > thead > tr > th,
  .table-tight > tbody > tr > td { padding: 8px 5px; }
}

/* ---------- Pagination ---------------------------------------------------- */
/* Pendant le chargement d une page de liste : le tableau s estompe une
   fraction de seconde, rien ne bouge a l ecran. */
.is-loading { opacity: .45; pointer-events: none; transition: opacity .12s ease; }

.pagination-bar {
  display: flex; flex-wrap: wrap; align-items: center;
  gap: 10px; justify-content: space-between;
}
.pagination-links { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; }
.pagination-links .btn { min-width: 38px; }
.pagination-links .btn.disabled { opacity: .45; pointer-events: none; }
.pagination-gap { color: var(--text-dim); padding: 0 4px; }

@media (max-width: 575.98px) {
  .pagination-bar { justify-content: center; text-align: center; }
  .pagination-links { justify-content: center; }
}

/* ---------- Encadre financier ------------------------------------------- */
.money-box {
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); overflow: hidden;
}
.money-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 11px 16px; border-bottom: 1px solid var(--border); gap: 12px;
}
.money-row:last-child { border-bottom: 0; }
.money-row span { color: var(--text-dim); font-weight: 600; }
.money-row b { font-size: 1.04rem; font-variant-numeric: tabular-nums; }
.money-total { background: #f8fafc; }
.money-total b { font-size: 1.2rem; }
.money-due { background: var(--busy-bg); }
.money-due span, .money-due b { color: var(--busy); }
.money-due b { font-size: 1.5rem; font-weight: 800; }
.money-paid { background: var(--ok-bg); }
.money-paid span, .money-paid b { color: var(--ok); }

/* ---------- Etapes du check-in ------------------------------------------ */
.steps { display: flex; gap: 8px; margin-bottom: 18px; flex-wrap: wrap; }
.step {
  flex: 1; min-width: 120px;
  display: flex; align-items: center; gap: 9px;
  padding: 11px 13px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--border);
  font-weight: 700; font-size: .88rem; color: var(--text-dim);
}
.step-num {
  width: 27px; height: 27px; border-radius: 50%;
  background: var(--bg); color: var(--text-dim);
  display: grid; place-items: center; font-size: .82rem; flex-shrink: 0;
}
.step.is-active { border-color: var(--side-active); color: var(--side-active); background: var(--clean-bg); }
.step.is-active .step-num { background: var(--side-active); color: #fff; }
.step.is-done { color: var(--ok); border-color: var(--ok-br); background: var(--ok-bg); }
.step.is-done .step-num { background: var(--ok); color: #fff; }

.step-panel { display: none; }
.step-panel.is-active { display: block; }

/* ---------- Calendrier d occupation -------------------------------------- */
.calendar-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.calendar { border-collapse: separate; border-spacing: 0; width: 100%; min-width: 760px; }
.calendar th, .calendar td { border-bottom: 1px solid var(--border); border-right: 1px solid var(--border); padding: 0; }
.calendar th {
  background: #f8fafc; font-size: .74rem; font-weight: 700; color: var(--text-dim);
  padding: 7px 4px; text-align: center; white-space: nowrap;
}
.calendar th.cal-room, .calendar td.cal-room {
  position: sticky; left: 0; z-index: 2; background: var(--surface);
  min-width: 104px; padding: 7px 11px; text-align: left; font-weight: 700;
  border-right: 2px solid var(--border);
}
.calendar th.cal-room { background: #f8fafc; z-index: 3; }
.calendar th.is-today { background: var(--clean-bg); color: var(--clean); }
.cal-cell { height: 38px; text-align: center; font-size: .68rem; font-weight: 700; }
.cal-free { background: #fff; }
.cal-OCC  { background: var(--busy);   color: #fff; }
.cal-RES  { background: var(--booked); color: #fff; }
.cal-MNT  { background: var(--off);    color: #fff; }
.cal-cell a { color: inherit; text-decoration: none; display: block; padding: 10px 2px; }
.cal-weekend { background: #fafbfe; }

/* ---------- Fenetres modales --------------------------------------------- */
.modal-content { border: 0; border-radius: 16px; box-shadow: var(--shadow-lg); }
.modal-header { border-bottom: 1px solid var(--border); padding: 16px 20px; }
.modal-title { font-weight: 700; }
.modal-body { padding: 20px; }
.modal-footer { border-top: 1px solid var(--border); padding: 14px 20px; }

/* ---------- Divers -------------------------------------------------------- */
.alert { border-radius: 12px; border: 1px solid transparent; font-weight: 500; }
.alert i { margin-right: 6px; }
.badge-soft {
  display: inline-block; padding: 4px 10px; border-radius: 999px;
  font-size: .76rem; font-weight: 700;
}
.empty-state { text-align: center; padding: 44px 20px; color: var(--text-dim); }
.empty-state i { font-size: 40px; opacity: .35; margin-bottom: 12px; display: block; }

.body-centered {
  min-height: 100vh; display: grid; place-items: center;
  background: linear-gradient(140deg, #111827 0%, #1e3a8a 100%);
  padding: 20px;
}
.centered-wrap { width: 100%; max-width: 420px; }

.login-card { background: #fff; border-radius: 18px; box-shadow: var(--shadow-lg); padding: 30px 26px; }
.login-logo {
  width: 62px; height: 62px; border-radius: 16px; background: var(--side-active);
  display: grid; place-items: center; color: #fff; font-size: 27px; margin: 0 auto 14px;
}
.login-card h1 { font-size: 1.3rem; font-weight: 800; text-align: center; margin-bottom: 4px; }
.login-card .subtitle { text-align: center; color: var(--text-dim); font-size: .9rem; margin-bottom: 22px; }

.help-text { font-size: .82rem; color: var(--text-dim); }
.text-money { font-variant-numeric: tabular-nums; font-weight: 700; }
.text-due { color: var(--busy); font-weight: 800; }
.text-ok { color: var(--ok); font-weight: 700; }

/* Impression depuis l application */
@media print {
  .sidebar, .topbar, .sidebar-backdrop, .no-print { display: none !important; }
  .content { padding: 0; }
  body { background: #fff; }
}

/* Barres du rapport revenus / depenses : la couleur vient de la classe
   text-ok / text-due posee sur la barre, sans couleur codee en dur. */
.bar-track { height: 10px; background: var(--border); border-radius: 5px; overflow: hidden; min-width: 60px; }
.bar-fill  { height: 100%; background: currentColor; border-radius: 5px; }
.bar-label { display: flex; justify-content: space-between; gap: 8px; font-size: .85rem; margin-bottom: 4px; }
