/* ============================================================
   Mestre Père et Fils — Style principal
   Charte graphique : mestre-pere-et-fils.fr
   Couleur : #ab0932 | Cinzel (titres) + Roboto (corps)
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;600;700&family=Roboto:ital,wght@0,300;0,400;0,500;0,700;1,400&display=swap');

:root {
  --wine:         #ab0932;
  --wine-dark:    #83071f;
  --wine-light:   #c91440;
  --sidebar-bg:   #1a1215;
  --sidebar-w:    260px;
  --body-bg:      #f5f4f3;
  --card-shadow:  0 2px 16px rgba(0,0,0,0.07);
  --radius:       12px;
  --topbar-h:     60px;
  --transition:   0.2s ease;
}

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

body {
  font-family: 'Roboto', sans-serif;
  background: var(--body-bg);
  color: #2d3748;
  margin: 0;
  font-size: 14px;
}

h1, h2, h3, h4, h5, h6, .font-cinzel {
  font-family: 'Cinzel', serif;
}

/* ============================================================
   LAYOUT
   ============================================================ */
#wrapper {
  display: flex;
  min-height: 100vh;
}

/* ---- Sidebar ---- */
#sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  z-index: 1000;
  transition: transform var(--transition);
  overflow-y: auto;
}

#sidebar .sidebar-brand {
  padding: 24px 20px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
}

#sidebar .sidebar-brand .brand-logo {
  width: 100%;
  max-width: 140px;
  height: auto;
  border-radius: 6px;
  margin-bottom: 12px;
  display: block;
}

#sidebar .sidebar-brand h5 {
  color: #fff;
  font-family: 'Cinzel', serif;
  font-size: 11px;
  font-weight: 600;
  margin: 0;
  line-height: 1.4;
  letter-spacing: 0.5px;
}

#sidebar .sidebar-brand small {
  color: rgba(255,255,255,0.4);
  font-size: 10px;
  font-family: 'Roboto', sans-serif;
}

/* Nav items */
#sidebar .nav-section {
  padding: 16px 12px 4px;
  font-size: 10px;
  font-weight: 600;
  color: rgba(255,255,255,0.3);
  text-transform: uppercase;
  letter-spacing: 1px;
}

#sidebar .nav-item a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  color: rgba(255,255,255,0.6);
  text-decoration: none;
  border-radius: 8px;
  margin: 2px 8px;
  font-size: 13.5px;
  font-weight: 500;
  transition: all var(--transition);
}

#sidebar .nav-item a i {
  width: 18px;
  text-align: center;
  font-size: 14px;
}

#sidebar .nav-item a:hover {
  background: rgba(255,255,255,0.07);
  color: #fff;
}

#sidebar .nav-item a.active {
  background: var(--wine);
  color: #fff;
}

#sidebar .sidebar-footer {
  margin-top: auto;
  padding: 16px;
  border-top: 1px solid rgba(255,255,255,0.07);
}

#sidebar .exo-badge {
  background: rgba(255,255,255,0.07);
  border-radius: 8px;
  padding: 8px 12px;
  margin-bottom: 10px;
  font-size: 12px;
  color: rgba(255,255,255,0.6);
}

#sidebar .exo-badge strong {
  color: #fff;
  display: block;
  font-size: 13px;
}

#sidebar .btn-logout {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 12px;
  background: rgba(220,53,69,0.15);
  border: none;
  border-radius: 8px;
  color: #fc8a94;
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  transition: all var(--transition);
}

#sidebar .btn-logout:hover {
  background: rgba(220,53,69,0.3);
  color: #fff;
}

/* ---- Main content ---- */
#main {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ---- Topbar ---- */
#topbar {
  height: var(--topbar-h);
  background: #fff;
  border-bottom: 1px solid #e9ecef;
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 100;
}

#topbar .page-title {
  font-size: 16px;
  font-weight: 600;
  color: #1a202c;
  margin: 0;
  flex: 1;
}

#topbar .topbar-user {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #64748b;
}

#topbar .user-avatar {
  width: 32px; height: 32px;
  background: var(--wine);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 13px; font-weight: 600;
}

/* ---- Page content ---- */
#content {
  padding: 24px;
  flex: 1;
}

/* ============================================================
   CARDS
   ============================================================ */
.card {
  border: none;
  border-radius: var(--radius);
  box-shadow: var(--card-shadow);
  background: #fff;
}

.card-header {
  background: transparent;
  border-bottom: 1px solid #f1f3f5;
  padding: 16px 20px;
  font-weight: 600;
  font-size: 14px;
}

/* KPI Cards */
.kpi-card {
  border-radius: var(--radius);
  padding: 20px;
  background: #fff;
  box-shadow: var(--card-shadow);
  display: flex;
  align-items: center;
  gap: 16px;
}

.kpi-icon {
  width: 52px; height: 52px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.kpi-icon.wine   { background: rgba(114,47,55,0.12); color: var(--wine); }
.kpi-icon.blue   { background: rgba(13,110,253,0.1);  color: #0d6efd; }
.kpi-icon.green  { background: rgba(25,135,84,0.1);   color: #198754; }
.kpi-icon.orange { background: rgba(253,126,20,0.1);  color: #fd7e14; }
.kpi-icon.red    { background: rgba(220,53,69,0.1);   color: #dc3545; }

.kpi-value {
  font-size: 22px;
  font-weight: 700;
  color: #1a202c;
  line-height: 1.1;
}

.kpi-label {
  font-size: 12px;
  color: #64748b;
  margin-top: 2px;
}

/* ============================================================
   TABLES
   ============================================================ */
.table th {
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #64748b;
  border-bottom: 2px solid #e9ecef;
  white-space: nowrap;
}

.table td { vertical-align: middle; font-size: 13.5px; }

.table-hover tbody tr:hover { background: rgba(114,47,55,0.03); }

/* DataTables overrides */
.dataTables_wrapper .dataTables_length select,
.dataTables_wrapper .dataTables_filter input {
  border-radius: 8px;
  border: 1px solid #dee2e6;
  padding: 4px 8px;
}

/* ============================================================
   BADGES / STATUS
   ============================================================ */
.badge { font-size: 11px; font-weight: 500; padding: 4px 8px; border-radius: 6px; }

.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 6px;
}

/* ============================================================
   FORMS
   ============================================================ */
.form-label {
  font-size: 12px;
  font-weight: 600;
  color: #475569;
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.form-control, .form-select {
  border-radius: 8px;
  border: 1px solid #dee2e6;
  font-size: 14px;
  padding: 8px 12px;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.form-control:focus, .form-select:focus {
  border-color: var(--wine);
  box-shadow: 0 0 0 3px rgba(114,47,55,0.12);
}

.form-section {
  background: #f8fafc;
  border: 1px solid #e9ecef;
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
}

.form-section-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--wine);
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid #e9ecef;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Checkboxes style */
.form-check-input:checked {
  background-color: var(--wine);
  border-color: var(--wine);
}

/* Switch-style checkboxes */
.check-group {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}

.check-item {
  display: flex;
  align-items: center;
  gap: 6px;
  background: white;
  border: 1px solid #dee2e6;
  border-radius: 8px;
  padding: 8px 12px;
  cursor: pointer;
  transition: all var(--transition);
  font-size: 13px;
}

.check-item:hover { border-color: var(--wine); }
.check-item input:checked + span { color: var(--wine); font-weight: 600; }

/* Select2 overrides */
.select2-container--bootstrap-5 .select2-selection {
  border-radius: 8px !important;
  min-height: 38px !important;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 500;
  padding: 8px 16px;
  transition: all var(--transition);
}

.btn-wine {
  background: var(--wine);
  color: #fff;
  border: none;
}

.btn-wine:hover { background: var(--wine-dark); color: #fff; }

.btn-sm { padding: 4px 10px; font-size: 12px; }

/* ============================================================
   TRAITES — Grille des échéances
   ============================================================ */
.echeance-cell {
  min-width: 130px;
  text-align: center;
}

.echeance-cell .date-ech {
  font-size: 11px;
  color: #64748b;
  display: block;
  margin-bottom: 4px;
}

.echeance-cell .montant-ech {
  font-size: 11px;
  color: #1a202c;
  font-weight: 600;
  display: block;
  margin-top: 2px;
}

.statut-select-wrap select {
  width: 100%;
  border-radius: 6px;
  border: 1px solid #dee2e6;
  font-size: 11px;
  padding: 3px 6px;
  cursor: pointer;
}

/* ============================================================
   ALERTS / FLASH
   ============================================================ */
.flash-msg {
  position: fixed;
  top: 70px;
  right: 20px;
  z-index: 9999;
  min-width: 300px;
  border-radius: 10px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
}

/* ============================================================
   LOGIN PAGE
   ============================================================ */
.login-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(150deg, #120408 0%, #2a0e18 45%, #0e1a2b 100%);
  padding: 24px;
  font-family: 'Roboto', sans-serif;
}

.login-card {
  width: 100%;
  max-width: 440px;
  background: #fff;
  border-radius: 20px;
  padding: 44px 48px;
  box-shadow: 0 32px 80px rgba(0,0,0,0.45);
}

.login-brand {
  text-align: center;
  margin-bottom: 36px;
  padding-bottom: 28px;
  border-bottom: 1px solid #f1f3f5;
}

.login-brand img {
  max-width: 110px;
  border-radius: 8px;
  margin-bottom: 14px;
  display: block;
  margin-left: auto;
  margin-right: auto;
}

.login-brand h2 {
  font-family: 'Cinzel', serif;
  font-size: 18px;
  font-weight: 700;
  color: #1a0a0d;
  margin: 0 0 4px;
}
.login-brand p  { color: #64748b; font-size: 12.5px; margin: 0; letter-spacing: 0.2px; }

.login-card .form-label {
  font-size: 11px; font-weight: 600; color: #374151;
  letter-spacing: 0.5px; text-transform: uppercase; margin-bottom: 6px;
}
.login-card .form-control {
  font-size: 14px; border-color: #e5e7eb;
  border-radius: 0 8px 8px 0; padding: 10px 14px; background: #fafafa;
}
.login-card .form-control:focus {
  border-color: var(--wine); box-shadow: 0 0 0 3px rgba(171,9,50,0.1); background: #fff;
}
.login-card .input-group-text {
  background: #f9fafb; border-color: #e5e7eb; color: #9ca3af;
  border-radius: 8px 0 0 8px; padding: 10px 14px;
}
.login-card .btn-wine { padding: 12px; font-size: 14px; border-radius: 10px; }
.login-error {
  background: #fef2f2; border: 1px solid #fecaca; border-radius: 10px;
  padding: 10px 14px; font-size: 13px; color: #dc2626; margin-bottom: 20px;
}
.login-footer-text {
  text-align: center; font-size: 11px; color: #9ca3af; margin-top: 24px;
}
@media (max-width: 480px) { .login-card { padding: 32px 24px; } }

/* ============================================================
   ECHÉANCE — Formulaire interne
   ============================================================ */
.echeance-block {
  background: white;
  border: 1px solid #e9ecef;
  border-radius: 10px;
  padding: 16px;
}

.echeance-block .echeance-num {
  font-size: 12px;
  font-weight: 700;
  color: var(--wine);
  text-transform: uppercase;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid #e9ecef;
}

/* ============================================================
   ANNULÉ
   ============================================================ */
tr.annule { opacity: 0.5; text-decoration: line-through; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
  #sidebar { transform: translateX(-100%); }
  #sidebar.open { transform: translateX(0); }
  #main { margin-left: 0; }
  #topbar { padding: 0 16px; }
  #content { padding: 16px; }
  .kpi-card { flex-direction: column; text-align: center; }
}

/* Hamburger button */
#sidebar-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 20px;
  color: #1a202c;
  cursor: pointer;
  padding: 4px;
}

@media (max-width: 768px) {
  #sidebar-toggle { display: block; }
}

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

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