/* ============================================================
   PRESENCE PN – Feuille de Présence
   Thème : Bootstrap 5 + Sidebar layout
   ============================================================ */

:root {
  --sidebar-w: 260px;
  --sidebar-bg: #1a3a5c;
  --sidebar-hover: rgba(255,255,255,.08);
  --sidebar-active: rgba(255,255,255,.15);
  --topnav-h: 56px;
  --primary: #282B62;
  --primary-dark: #1e2049;
  --body-bg: #f1f5f9;
  --card-shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 8px rgba(0,0,0,.04);
  --card-hover-shadow: 0 4px 16px rgba(0,0,0,.12);
  --transition: .2s ease;
}

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

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--body-bg);
  color: #334155;
  min-height: 100vh;
  overflow-x: hidden;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  z-index: 1040;
  transition: transform var(--transition), width var(--transition);
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.15) transparent;
}

.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); }

/* Brand */
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: 1.25rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,.08);
  flex-shrink: 0;
}
.sidebar-brand-icon {
  width: 38px; height: 38px;
  background: var(--primary);
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-size: 1.1rem;
  flex-shrink: 0;
}
.sidebar-brand-text { color: #fff; font-size: .9rem; line-height: 1.3; }

/* Nav list */
.sidebar-nav {
  list-style: none;
  padding: .5rem 0;
  margin: 0;
  flex: 1;
}
.sidebar-nav-item { margin: 1px .5rem; }
.sidebar-nav-link {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .55rem .85rem;
  color: rgba(255,255,255,.75);
  font-size: .875rem;
  font-weight: 500;
  transition: background var(--transition), color var(--transition);
  white-space: nowrap;
}
.sidebar-nav-link:hover { background: var(--sidebar-hover); color: #fff; }
.sidebar-nav-item.active .sidebar-nav-link {
  background: var(--sidebar-active);
  color: #fff;
}
.sidebar-nav-icon { width: 18px; text-align: center; flex-shrink: 0; font-size: .9rem; }

.sidebar-divider {
  height: 1px;
  background: rgba(255,255,255,.07);
  margin: .5rem 1rem;
}
.sidebar-heading {
  padding: .5rem 1.35rem .25rem;
  font-size: .65rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: rgba(255,255,255,.35);
}

/* Footer */
.sidebar-footer {
  padding: .85rem 1rem;
  border-top: 1px solid rgba(255,255,255,.08);
  flex-shrink: 0;
}
.sidebar-avatar {
  width: 32px; height: 32px;
  background: var(--primary);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: .75rem; font-weight: 700;
  flex-shrink: 0;
}
.sidebar-logout { font-size: 1rem; transition: color var(--transition); }
.sidebar-logout:hover { color: #fff !important; }

/* ============================================================
   MAIN WRAPPER
   ============================================================ */
.main-wrapper {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  transition: margin-left var(--transition);
  display: flex;
  flex-direction: column;
}

/* Top navbar */
.topnav {
  height: var(--topnav-h);
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  position: sticky; top: 0;
  z-index: 1030;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}

.btn-icon {
  width: 36px; height: 36px;
  border: 1px solid #e2e8f0;
  background: transparent;
  display: flex; align-items: center; justify-content: center;
  color: #64748b;
  font-size: .9rem;
  transition: background var(--transition), color var(--transition);
  padding: 0;
}
.btn-icon:hover { background: #f1f5f9; color: var(--primary); }

.breadcrumb-item a { color: #64748b; }
.breadcrumb-item.active { color: #334155; }

/* Page content */
.page-content {
  flex: 1;
  padding: 1.5rem;
}

/* ============================================================
   SIDEBAR COLLAPSED
   ============================================================ */
.sidebar-collapsed .sidebar {
  width: 60px;
}
.sidebar-collapsed .sidebar-brand-text,
.sidebar-collapsed .sidebar-nav-link span,
.sidebar-collapsed .sidebar-heading,
.sidebar-collapsed .sidebar-footer .lh-1,
.sidebar-collapsed .sidebar-logout,
.sidebar-collapsed .sidebar-divider { display: none; }
.sidebar-collapsed .sidebar-brand { justify-content: center; padding: 1.25rem .5rem; }
.sidebar-collapsed .sidebar-nav-link { justify-content: center; padding: .55rem; }
.sidebar-collapsed .sidebar-nav-icon { width: auto; font-size: 1.1rem; }
.sidebar-collapsed .sidebar-footer { padding: .85rem .5rem; }
.sidebar-collapsed .sidebar-footer .d-flex { justify-content: center; }
.sidebar-collapsed .sidebar-nav-item { position: relative; }
.sidebar-collapsed .main-wrapper { margin-left: 60px; }

/* ============================================================
   STAT CARDS
   ============================================================ */
.stat-card {
  background: #fff;
  padding: 1.25rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  box-shadow: var(--card-shadow);
  transition: box-shadow var(--transition), transform var(--transition);
}
.stat-card:hover { box-shadow: var(--card-hover-shadow); transform: translateY(-2px); }
.stat-icon {
  width: 52px; height: 52px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}
.stat-icon.blue   { background: #eff6ff; color: #282B62; }
.stat-icon.green  { background: #f0fdf4; color: #16a34a; }
.stat-icon.orange { background: #fff7ed; color: #ea580c; }
.stat-icon.purple { background: #faf5ff; color: #9333ea; }
.stat-icon.red    { background: #fef2f2; color: #dc2626; }
.stat-info .stat-value { font-size: 1.75rem; font-weight: 700; line-height: 1; color: #1e293b; }
.stat-info .stat-label { font-size: .8rem; color: #64748b; margin-top: .25rem; }

/* ============================================================
   CARDS
   ============================================================ */
.card {
  border: none;
  border-radius: 0 !important;
  box-shadow: var(--card-shadow);
}
.card-header {
  background: #fff;
  border-bottom: 1px solid #f1f5f9;
  border-radius: 0 !important;
  padding: 1rem 1.25rem;
  font-weight: 600;
  font-size: .9rem;
}
.card-body { padding: 1.25rem !important; }

/* ============================================================
   TABLES
   ============================================================ */
.table th {
  font-size: .78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: #64748b;
  background: #f8fafc;
}
.table td { font-size: .875rem; vertical-align: middle; }
.table-hover tbody tr:hover { background: #f8fafc; }

/* DataTables overrides */
div.dataTables_wrapper div.dataTables_filter input {
  border-radius: 0 !important;
  border: 1px solid #e2e8f0;
  padding: .35rem .75rem;
  font-size: .875rem;
}
div.dataTables_wrapper div.dataTables_length select {
  border-radius: 0 !important;
  border: 1px solid #e2e8f0;
  padding: .35rem .5rem;
}
.dataTables_info, .dataTables_length, .dataTables_filter { font-size: .8rem !important; }

/* ============================================================
   FORMS
   ============================================================ */
.form-label { font-size: .85rem; font-weight: 600; color: #475569; }
.form-control, .form-select {
  border-radius: 0 !important;
  border: 1px solid #e2e8f0;
  font-size: .875rem;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn { border-radius: 0 !important; font-size: .875rem; font-weight: 500; }
.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-sm { font-size: .78rem; padding: .3rem .65rem; }
.btn-action { width: 30px; height: 30px; padding: 0; display: inline-flex; align-items: center; justify-content: center; }

/* ============================================================
   PAGE HEADER
   ============================================================ */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.page-header-title { font-size: 1.3rem; font-weight: 700; color: #1e293b; margin: 0; }
.page-header-subtitle { font-size: .825rem; color: #64748b; margin: .15rem 0 0; }

/* ============================================================
   PRESENCE GRID (saisie)
   ============================================================ */
.presence-grid { display: grid; gap: .75rem; }
.presence-row {
  background: #fff;
  padding: .85rem 1rem;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .75rem;
  box-shadow: var(--card-shadow);
  transition: box-shadow var(--transition);
}
.presence-row:hover { box-shadow: var(--card-hover-shadow); }
.presence-name { font-weight: 600; font-size: .9rem; min-width: 160px; flex: 1; }
.presence-company { font-size: .78rem; color: #64748b; }

.presence-btn-group { display: flex; gap: .4rem; }
.pres-btn {
  padding: .35rem .75rem;
  border: 2px solid transparent;
  font-size: .8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  background: #f1f5f9;
  color: #64748b;
}
.pres-btn:hover { opacity: .85; }
.pres-btn.selected-present  { background: #16a34a; color: #fff; border-color: #16a34a; }
.pres-btn.selected-absent   { background: #dc2626; color: #fff; border-color: #dc2626; }
.pres-btn.selected-retard   { background: #d97706; color: #fff; border-color: #d97706; }
.pres-btn.selected-excuse   { background: #0891b2; color: #fff; border-color: #0891b2; }

/* ============================================================
   FEUILLE DE PRÉSENCE (impression)
   ============================================================ */
@media print {
  body { background: #fff !important; font-family: Arial, sans-serif; }
  .sidebar, .topnav, .no-print { display: none !important; }
  .main-wrapper { margin-left: 0 !important; }
  .page-content { padding: 0 !important; }
  .feuille-container { box-shadow: none !important; padding: 0 !important; }
  .page-break { page-break-before: always; }
}

.feuille-container {
  background: #fff;
  padding: 2rem;
  box-shadow: var(--card-shadow);
}
.feuille-header { border-bottom: 3px solid #1a3a5c; padding-bottom: 1rem; margin-bottom: 1.5rem; }
.feuille-org-name { font-size: 1.4rem; font-weight: 700; color: #1a3a5c; }
.feuille-title { font-size: 1rem; font-weight: 700; text-align: center; color: #1a3a5c;
  text-transform: uppercase; letter-spacing: .05em; margin: 1rem 0; }
.feuille-table { width: 100%; border-collapse: collapse; font-size: .8rem; }
.feuille-table th, .feuille-table td {
  border: 1px solid #334155;
  padding: .4rem .5rem;
  text-align: center;
}
.feuille-table th { background: #1a3a5c; color: #fff; font-size: .72rem; }
.feuille-table td:nth-child(2) { text-align: left; }
.feuille-table tr:nth-child(even) td { background: #f8fafc; }
.cell-present  { background: #d1fae5 !important; color: #065f46; font-weight: 700; }
.cell-absent   { background: #fee2e2 !important; color: #991b1b; font-weight: 700; }
.cell-retard   { background: #fef3c7 !important; color: #92400e; font-weight: 700; }
.cell-excuse   { background: #cffafe !important; color: #164e63; font-weight: 700; }
.cell-empty    { color: #94a3b8; }

.signature-box {
  border: 1px solid #334155;
  padding: 1rem;
  min-height: 80px;
  margin-top: .5rem;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 767.98px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.mobile-open {
    transform: translateX(0);
  }
  .main-wrapper { margin-left: 0; }
  .sidebar-collapsed .main-wrapper { margin-left: 0; }
  .page-content { padding: 1rem; }
  .topnav { padding: 0 1rem; }
  .stat-card { padding: 1rem; }
  .stat-icon { width: 44px; height: 44px; font-size: 1.2rem; }
  .stat-info .stat-value { font-size: 1.4rem; }
}

/* ============================================================
   MISC UTILITIES
   ============================================================ */
.overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 1039;
}
.overlay.show { display: block; }

.badge { font-size: .72rem; }
.table-actions { white-space: nowrap; }

.progress-sm { height: 6px; }

/* Neutraliser tous les border-radius Bootstrap restants */
*, *::before, *::after { border-radius: 0 !important; }
