/* ─── open — Styles applicatifs ──────────────────────────────────────────── */

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

.hidden { display: none !important; }

/* ─── Layout responsive ──────────────────────────────────────────────────── */
.app-layout      { display: flex; min-height: 100vh; }

.app-sidebar {
  width: 220px;
  min-width: 220px;
  background: #fff;
  border-right: 0.5px solid #E5E7EB;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 50;
  overflow-y: auto;
  transition: transform 0.22s ease;
}

.app-main {
  flex: 1;
  margin-left: 220px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.app-topbar {
  height: 44px;
  background: #fff;
  border-bottom: 0.5px solid #E5E7EB;
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 40;
}

.app-content { flex: 1; padding: 24px; overflow-y: auto; }

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.35);
  z-index: 45;
}

/* Hamburger — masqué sur desktop */
.btn-hamburger {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  color: #374151;
  font-size: 18px;
  line-height: 1;
  flex-shrink: 0;
}

/* Tables responsive */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ─── Mobile (≤768px) ────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .app-sidebar { transform: translateX(-100%); }
  .app-sidebar.open { transform: translateX(0); }

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

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

  .btn-hamburger { display: flex; align-items: center; }

  .app-content { padding: 16px; }

  .app-topbar { padding: 0 14px; gap: 10px; }

  /* Masquer les colonnes secondaires dans les tableaux */
  .col-hide-mobile { display: none !important; }

  /* Grilles 2 colonnes → 1 sur mobile */
  .grid-2-mobile-1 { grid-template-columns: 1fr !important; }

  /* Panels latéraux (detail views) → passer en colonne */
  .detail-layout { grid-template-columns: 1fr !important; }
}

/* ─── Badges statut OT / devis / commande / facture ────────────────────── */
.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 4px;
  white-space: nowrap;
  line-height: 1.6;
}

.badge-urgente        { background: #FCEBEB; color: #A32D2D; }
.badge-haute          { background: #FAEEDA; color: #633806; }
.badge-normale        { background: #E6F1FB; color: #0C447C; }
.badge-basse          { background: #F3F4F6; color: #374151; }

.badge-brouillon      { background: #F3F4F6; color: #374151; }
.badge-planifie       { background: #E6F1FB; color: #0C447C; }
.badge-en_cours       { background: #EEEDFE; color: #3C3489; }
.badge-suspendu       { background: #FAEEDA; color: #633806; }
.badge-termine        { background: #EAF3DE; color: #27500A; }
.badge-annule         { background: #F3F4F6; color: #6B7280; }

.badge-envoye,
.badge-envoyee        { background: #E6F1FB; color: #0C447C; }
.badge-accepte        { background: #EAF3DE; color: #27500A; }
.badge-refuse         { background: #FCEBEB; color: #A32D2D; }
.badge-expire         { background: #FAEEDA; color: #633806; }
.badge-payee          { background: #EAF3DE; color: #27500A; }
.badge-partiellement_payee { background: #FAEEDA; color: #633806; }
.badge-en_retard      { background: #FCEBEB; color: #A32D2D; }

/* ─── Boutons ────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 500;
  border-radius: 6px;
  cursor: pointer;
  text-decoration: none;
  border: none;
  transition: filter 0.1s;
}
.btn:hover { filter: brightness(0.93); }

.btn-primary { background: #185FA5; color: #fff; }
.btn-secondary {
  background: transparent;
  color: #374151;
  border: 0.5px solid #D1D5DB;
}
.btn-danger { background: #FCEBEB; color: #A32D2D; }

/* ─── Formulaires ────────────────────────────────────────────────────────── */
.form-input {
  width: 100%;
  padding: 9px 12px;
  border: 0.5px solid #D1D5DB;
  border-radius: 6px;
  font-size: 14px;
  color: #111827;
  background: #fff;
  outline: none;
  transition: border-color 0.15s;
}
.form-input:focus { border-color: #185FA5; }

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: #374151;
  margin-bottom: 4px;
}

/* ─── Carte générique ────────────────────────────────────────────────────── */
.card {
  background: #fff;
  border: 0.5px solid #E5E7EB;
  border-radius: 8px;
  overflow: hidden;
}

.card-header {
  padding: 14px 20px;
  border-bottom: 0.5px solid #F3F4F6;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-title {
  font-size: 14px;
  font-weight: 600;
  color: #111827;
  margin: 0;
}

.card-body { padding: 20px; }

/* ─── Tableau ────────────────────────────────────────────────────────────── */
.table-wrapper { overflow-x: auto; }
table.open-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.open-table th {
  text-align: left;
  padding: 8px 12px;
  color: #6B7280;
  font-weight: 500;
  border-bottom: 0.5px solid #E5E7EB;
}
.open-table td {
  padding: 10px 12px;
  border-bottom: 0.5px solid #F3F4F6;
  color: #111827;
}
.open-table tbody tr:hover { background: #F9FAFB; }

/* ─── Modal ──────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.35);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal {
  background: #fff;
  border-radius: 8px;
  padding: 24px;
  min-width: 340px;
  max-width: 540px;
  border: 0.5px solid #E5E7EB;
}

/* ─── Planning — créneaux ────────────────────────────────────────────────── */
.event {
  position: absolute;
  left: 4px; right: 4px;
  border-radius: 4px;
  padding: 4px 8px;
  overflow: hidden;
  cursor: pointer;
}
.event-title {
  font-size: 12px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.event-sub {
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ─── Scrollbar discrète ─────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #E5E7EB; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #D1D5DB; }
