/* ==========================================================================
   MODULE CAISSE & FACTURATION UNIFIÉE - CLINIQUE NOFLAY
   Fichier : assets/css/caisse.css
   ========================================================================== */

/* --- 1. Structure du Layout --- */
.app-layout {
  display: flex;
  min-height: 100vh;
  background-color: var(--bg-app, #f8fafc);
}

/* Sidebar Caisse */
.sidebar {
  width: 260px;
  background: var(--slate-900, #0f172a);
  color: #f8fafc;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.sidebar-header {
  padding: 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-logo {
  width: 42px;
  height: 42px;
  object-fit: contain;
}

.sidebar-header h2 {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0;
  color: #ffffff;
}

.sidebar-nav {
  padding: 1.25rem 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.sidebar-nav .nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  color: #cbd5e1;
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 600;
  border-radius: 8px;
  transition: all 0.2s ease;
}

.sidebar-nav .nav-link svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.sidebar-nav .nav-link:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

.sidebar-nav .nav-link.active {
  background: var(--primary-600, #0284c7);
  color: #ffffff;
}

/* Contenu Principal */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 2rem;
  overflow: auto;
}

.top-header {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 1.25rem 1.75rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.top-header h1 {
  font-size: 1.35rem;
  font-weight: 800;
  color: #0f172a;
  margin: 0 0 0.25rem 0;
}

.top-header .subtitle {
  font-size: 0.85rem;
  color: #64748b;
  margin: 0;
}

/* --- 2. Cartes KPI --- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.75rem;
}

.kpi-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 1.25rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.kpi-card.highlight {
  border-left: 4px solid #0284c7;
  background: #f0f9ff;
}

.kpi-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.kpi-value {
  font-size: 1.7rem;
  font-weight: 800;
  color: #0f172a;
  line-height: 1.1;
}

.kpi-card.highlight .kpi-value {
  color: #0284c7;
}

/* --- 3. Tableau des Factures --- */
.table-container {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}

.section-title {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid #e2e8f0;
  background: #f8fafc;
}

.section-title h2 {
  font-size: 1rem;
  font-weight: 700;
  color: #1e293b;
  margin: 0;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.data-table th {
  background: #f8fafc;
  padding: 0.85rem 1rem;
  font-size: 0.78rem;
  font-weight: 700;
  color: #475569;
  border-bottom: 1px solid #e2e8f0;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.data-table td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid #f1f5f9;
  font-size: 0.88rem;
  vertical-align: middle;
}

.data-table tr:hover td {
  background: #f8fafc;
}

.data-table code {
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: monospace;
  font-weight: 700;
  color: #0f172a;
  font-size: 0.82rem;
}

.badge-service {
  display: inline-block;
  background: #e0f2fe;
  color: #0369a1;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
}

/* --- 4. Modales d'Encaissement --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.modal-container {
  background: #ffffff;
  border-radius: 12px;
  width: 95%;
  max-width: 850px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.25), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #ffffff;
  flex-shrink: 0;
}

.modal-header h3 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  color: #0f172a;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.6rem;
  cursor: pointer;
  color: #94a3b8;
  line-height: 1;
}

.modal-close:hover {
  color: #0f172a;
}

#modaleActesExternes form {
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 1.5rem;
  gap: 1.1rem;
  flex: 1;
}

.patient-summary-box {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 1rem 1.25rem;
  margin: 1.25rem 1.5rem 0.5rem 1.5rem;
}

.form-group {
  padding: 0.5rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

#modaleActesExternes .form-group {
  padding-left: 0;
  padding-right: 0;
}

.form-group label {
  font-size: 0.8rem;
  font-weight: 600;
  color: #334155;
}

.form-group select,
.form-group input,
.form-group textarea {
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 0.55rem 0.75rem;
  font-size: 0.88rem;
  font-family: inherit;
  width: 100%;
  outline: none;
}

.form-group select:focus,
.form-group input:focus {
  border-color: #0284c7;
  box-shadow: 0 0 0 2px rgba(2, 132, 199, 0.15);
}

.form-row {
  display: flex;
  gap: 1rem;
  padding: 0;
}

.col-4 { flex: 4; }
.col-6 { flex: 6; }
.col-8 { flex: 8; }

.modal-footer {
  padding: 1rem 1.5rem;
  background: #f8fafc;
  border-top: 1px solid #e2e8f0;
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  flex-shrink: 0;
  margin-top: 0.5rem;
}

/* --- 5. Barre de Recherche et Suggestions Flottantes --- */
.search-actes-wrapper {
  position: relative;
  width: 100%;
}

.actes-search-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: #ffffff;
  border: 1.5px solid #0284c7;
  border-radius: 8px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
  max-height: 220px;
  overflow-y: auto;
  z-index: 1050;
  margin-top: 4px;
  padding: 4px;
}

.actes-search-results.d-none {
  display: none !important;
}

.acte-suggestion-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 9px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s ease;
  border-bottom: 1px solid #f1f5f9;
}

.acte-suggestion-item:last-child {
  border-bottom: none;
}

.acte-suggestion-item:hover {
  background: #f0f9ff;
}

.acte-suggestion-item strong {
  font-size: 0.88rem;
  color: #0f172a;
}

.acte-suggestion-item .item-meta {
  display: flex;
  align-items: center;
  gap: 8px;
}

.acte-suggestion-item .item-price {
  font-size: 0.85rem;
  font-weight: 800;
  color: #0284c7;
}

.badge-service-mini {
  font-size: 0.72rem;
  padding: 2px 6px;
  border-radius: 4px;
  background: #e2e8f0;
  color: #475569;
  font-weight: 600;
}

/* --- 6. Tableau des Actes Sélectionnés (Liste visible et suppression) --- */
.selected-actes-table-box {
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #ffffff;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.02);
  min-height:fit-content; /*Modifier par moi même. Vérifie si c'est pertinent !*/
}

.selected-actes-table-box label {
  display: block;
  padding: 9px 14px;
  font-size: 0.82rem;
  font-weight: 700;
  color: #1e293b;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
}

.selected-actes-table-box .data-table {
  width: 100%;
  margin: 0;
}

.selected-actes-table-box .data-table th {
  background: #f1f5f9;
  padding: 8px 12px;
  font-size: 0.75rem;
}

.selected-actes-table-box .data-table td {
  padding: 8px 12px;
  border-bottom: 1px solid #f1f5f9;
}

.recap-financier-box {
  background: #f1f5f9;
  border-radius: 8px;
  padding: 12px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border: 1px solid #cbd5e1;
}

.recap-line {
  font-size: 0.88rem;
  color: #475569;
}

.recap-line.highlight strong {
  font-size: 1.25rem;
  color: #0284c7;
}

/* Bouton de suppression d'acte ✕ */
.btn-delete-row {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  background: #fee2e2;
  color: #dc2626;
  border: 1px solid #fca5a5;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.95rem;
  transition: all 0.15s ease;
}

.btn-delete-row:hover {
  background: #dc2626;
  color: #ffffff;
}

.d-none { display: none !important; }
