/* ============================================================
   OIPI - Gestion Parc Informatique
   Thème : Bleu pétrole · Vert · Orange
   ============================================================ */

:root {
  /* --- Couleur principale : Bleu pétrole --- */
  --primary:         #004D61;
  --primary-dark:    #003347;
  --primary-light:   #006B85;
  --primary-xlight:  #CCE8EF;

  /* --- Couleur secondaire : Vert --- */
  --secondary:       #019541;
  --secondary-dark:  #016E30;
  --secondary-light: #02B84F;
  --secondary-xlight:#D4F2E2;

  /* --- Accent : Orange institutionnel --- */
  --accent:          #EE7907;
  --accent-dark:     #C86200;
  --accent-light:    #FF9B3A;
  --accent-xlight:   #FEF0DC;

  /* --- Fond & Texte --- */
  --bg:              #F4F6F8;
  --text:            #212121;
  --text-muted:      #5A6A73;

  /* --- Layout --- */
  --sidebar-w:       260px;
  --topbar-h:        56px;
  --transition:      0.25s ease;
  --shadow-sm:       0 1px 6px rgba(0,0,0,.08);
  --shadow-md:       0 4px 20px rgba(0,0,0,.12);
  --radius:          10px;
  --radius-sm:       6px;
}

/* ---- Reset & Base ---- */
* { box-sizing: border-box; }
body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  margin: 0;
}

/* ---- Bootstrap Overrides ---- */
.bg-primary-custom { background: linear-gradient(135deg, var(--primary-dark), var(--primary)) !important; }

/* Boutons principaux → bleu pétrole */
.btn-success  { background: var(--primary);  border-color: var(--primary); }
.btn-success:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-outline-success { color: var(--primary); border-color: var(--primary); }
.btn-outline-success:hover { background: var(--primary); border-color: var(--primary); color: #fff; }
.text-success { color: var(--primary) !important; }
.bg-success   { background-color: var(--primary) !important; }
.badge.bg-success { background-color: var(--primary) !important; }

/* Bouton accent orange */
.btn-accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-accent:hover { background: var(--accent-dark); border-color: var(--accent-dark); color: #fff; }

/* Bouton vert secondaire */
.btn-secondary-color { background: var(--secondary); border-color: var(--secondary); color: #fff; }
.btn-secondary-color:hover { background: var(--secondary-dark); border-color: var(--secondary-dark); color: #fff; }

.form-check-input:checked,
.form-control:focus,
.form-select:focus {
  border-color: var(--primary-light);
  box-shadow: 0 0 0 .2rem rgba(0,77,97,.2);
}
.table-success { --bs-table-bg: var(--secondary-xlight); --bs-table-border-color: #A8DBBF; }

/* ---- Topbar ---- */
#topNavbar {
  height: var(--topbar-h);
  z-index: 1050;
  left: 0; right: 0;
}
#topNavbar .navbar-brand { font-size: 1rem; }
#topNavbar .logo-img { border-radius: 6px; object-fit: contain; }

/* ---- Layout ---- */
.app-wrapper {
  display: flex;
  padding-top: var(--topbar-h);
  min-height: 100vh;
}
.app-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-width: 0;
  transition: margin-left var(--transition);
  padding: 0;
}
.app-content .container-fluid { padding: 1.5rem; }

/* ---- Sidebar — Bleu pétrole dégradé ---- */
.sidebar {
  position: fixed;
  top: var(--topbar-h);
  left: 0;
  bottom: 0;
  width: var(--sidebar-w);
  background: linear-gradient(180deg, var(--primary-dark) 0%, var(--primary) 60%, var(--primary-light) 100%);
  color: #fff;
  overflow-y: auto;
  overflow-x: hidden;
  transition: width var(--transition), transform var(--transition);
  z-index: 1040;
  display: flex;
  flex-direction: column;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.2) transparent;
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.2); border-radius: 4px; }

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255,255,255,.1);
  font-size: .95rem;
  font-weight: 700;
  letter-spacing: .5px;
}
.sidebar-brand img { border-radius: 6px; filter: brightness(1.1); }

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid rgba(255,255,255,.1);
  margin-bottom: 6px;
}
.user-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: rgba(255,255,255,.2);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .9rem;
  border: 2px solid rgba(255,255,255,.3);
  flex-shrink: 0;
}
.user-info { display: flex; flex-direction: column; min-width: 0; }
.user-name { font-size: .85rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: .7rem; color: rgba(255,255,255,.6); }

.sidebar-nav { flex: 1; padding: 4px 0; }
.sidebar-nav .nav-item { margin: 1px 8px; }
.sidebar-nav .nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  color: rgba(255,255,255,.85);
  border-radius: var(--radius-sm);
  font-size: .84rem;
  transition: background var(--transition), color var(--transition);
  white-space: nowrap;
  overflow: hidden;
}
.sidebar-nav .nav-link:hover { background: rgba(255,255,255,.12); color: #fff; }
/* Active avec accent orange */
.sidebar-nav .nav-link.active {
  background: rgba(255,255,255,.18);
  color: #fff;
  font-weight: 600;
  box-shadow: inset 3px 0 0 var(--accent);
}
.nav-icon { width: 18px; flex-shrink: 0; text-align: center; font-size: .85rem; opacity: .9; }
.nav-label { flex: 1; }
.nav-section-title {
  padding: 8px 20px 3px;
  font-size: .65rem;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: rgba(255,255,255,.45);
  margin-top: 6px;
}

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid rgba(255,255,255,.1);
  font-size: .78rem;
}

/* Sidebar collapsed */
body.sidebar-collapsed .sidebar { width: 56px; }
body.sidebar-collapsed .sidebar-brand span,
body.sidebar-collapsed .user-info,
body.sidebar-collapsed .nav-label,
body.sidebar-collapsed .nav-section-title,
body.sidebar-collapsed .sidebar-footer .flex-grow-1 { display: none; }
body.sidebar-collapsed .sidebar-brand { justify-content: center; padding: 14px 8px; }
body.sidebar-collapsed .sidebar-user { justify-content: center; padding: 12px 0; }
body.sidebar-collapsed .sidebar-nav .nav-link { justify-content: center; padding: 10px; }
body.sidebar-collapsed .sidebar-nav .nav-item { margin: 1px 4px; }
body.sidebar-collapsed .app-content { margin-left: 56px; }

/* ---- Page Headers ---- */
.page-header { margin-bottom: .5rem; }
.page-header h2 { font-size: 1.4rem; font-weight: 700; color: var(--primary-dark); margin-bottom: 0; }

/* ---- KPI Cards ---- */
.kpi-card {
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow-sm);
  border: none;
  transition: transform var(--transition), box-shadow var(--transition);
  color: #fff;
}
.kpi-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
/* Bleu pétrole */
.kpi-primary { background: linear-gradient(135deg, var(--primary-dark), var(--primary-light)); }
/* Vert secondaire */
.kpi-success { background: linear-gradient(135deg, var(--secondary-dark), var(--secondary-light)); }
/* Orange accent */
.kpi-warning { background: linear-gradient(135deg, var(--accent-dark), var(--accent-light)); color: #fff !important; }
/* Bleu clair info */
.kpi-info    { background: linear-gradient(135deg, #005F7A, #0099BF); }

.kpi-icon { font-size: 2rem; opacity: .85; flex-shrink: 0; }
.kpi-content { flex: 1; min-width: 0; }
.kpi-value { font-size: 1.8rem; font-weight: 800; line-height: 1.1; }
.kpi-label { font-size: .78rem; opacity: .85; font-weight: 500; }
.kpi-footer { font-size: .72rem; opacity: .75; margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---- Cards ---- */
.card { border: none; border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card-header {
  background: #fff;
  border-bottom: 2px solid var(--primary-xlight);
  padding: .8rem 1rem;
  font-weight: 600;
  font-size: .88rem;
  color: var(--primary-dark);
}
.card-footer { background: #fafafa; border-top: 1px solid #eee; padding: .6rem 1rem; }

/* ---- Tables ---- */
.table th { font-size: .78rem; font-weight: 600; text-transform: uppercase; letter-spacing: .4px; white-space: nowrap; }
.table td { font-size: .82rem; vertical-align: middle; }
.table-hover tbody tr:hover { background: var(--primary-xlight); }

/* ---- Badges ---- */
.badge { font-size: .72rem; padding: .3em .55em; border-radius: 4px; font-weight: 600; }

/* Badges sémantiques */
.badge-primary  { background: var(--primary);   color: #fff; }
.badge-secondary{ background: var(--secondary);  color: #fff; }
.badge-accent   { background: var(--accent);     color: #fff; }

/* ---- Alerts ---- */
.alert { border-radius: var(--radius-sm); border: none; font-size: .88rem; }

/* ============================================================
   LOGIN PAGE — Split layout (image gauche / formulaire droit)
   ============================================================ */

.login-page { margin: 0; padding: 0; min-height: 100vh; background: var(--bg); }

.login-split {
  display: flex;
  min-height: 100vh;
}

/* ---- Panneau gauche : illustration — Bleu pétrole ---- */
.login-panel-left {
  position: relative;
  flex: 0 0 55%;
  background: linear-gradient(150deg, var(--primary-dark) 0%, var(--primary) 55%, var(--primary-light) 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 2.5rem 2rem;
  overflow: hidden;
  color: #fff;
}
.login-panel-overlay {
  position: absolute;
  inset: 0;
  background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.04'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E") repeat;
  pointer-events: none;
}

/* Bandeau orange en bas du panneau gauche */
.login-panel-left::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 4px;
  background: var(--accent);
}

/* Logo haut gauche */
.lp-logo {
  position: absolute;
  top: 1.75rem;
  left: 2rem;
  display: flex;
  align-items: center;
}
.lp-logo img { height: 48px; border-radius: 8px; object-fit: contain; }
.lp-logo-initials {
  width: 48px; height: 48px;
  background: rgba(255,255,255,.25);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem; font-weight: 900; color: #fff;
  letter-spacing: 1px;
}

/* Illustration SVG */
.lp-illustration {
  width: 100%;
  max-width: 400px;
  margin-bottom: 2rem;
  filter: drop-shadow(0 8px 24px rgba(0,0,0,.2));
  animation: lp-float 4s ease-in-out infinite;
}
.lp-illustration svg { width: 100%; height: auto; }

@keyframes lp-float {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-10px); }
}

/* Texte accrocheur */
.lp-text { text-align: center; max-width: 380px; }
.lp-text h2 {
  font-size: 1.55rem;
  font-weight: 800;
  margin-bottom: .6rem;
  text-shadow: 0 2px 8px rgba(0,0,0,.2);
}
.lp-text p {
  font-size: .9rem;
  opacity: .85;
  line-height: 1.6;
  margin-bottom: 1.2rem;
}
.lp-features {
  list-style: none;
  padding: 0; margin: 0;
  display: inline-flex;
  flex-direction: column;
  gap: .45rem;
  text-align: left;
}
.lp-features li {
  font-size: .85rem;
  opacity: .9;
  display: flex;
  align-items: center;
  gap: .5rem;
}
/* Icônes features : vert secondaire */
.lp-features li i { color: var(--secondary-light); font-size: .8rem; }

/* Copyright bas */
.lp-copy {
  position: absolute;
  bottom: 1.6rem;
  font-size: .72rem;
  opacity: .6;
  text-align: center;
}

/* ---- Panneau droit : formulaire ---- */
.login-panel-right {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  padding: 2.5rem 1.5rem;
  overflow-y: auto;
}

.login-form-wrap {
  width: 100%;
  max-width: 400px;
}

/* En-tête formulaire */
.lf-header {
  text-align: center;
  margin-bottom: 2rem;
}
.lf-logo-box {
  display: flex;
  justify-content: center;
  margin-bottom: 1rem;
}
.lf-logo-box img {
  height: 72px;
  border-radius: 12px;
  object-fit: contain;
  filter: drop-shadow(0 4px 12px rgba(0,77,97,.25));
}
.lf-logo-initials {
  width: 72px; height: 72px;
  background: linear-gradient(135deg, var(--primary-dark), var(--primary-light));
  border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.6rem; font-weight: 900; color: #fff;
  letter-spacing: 2px;
  box-shadow: 0 4px 16px rgba(0,77,97,.3);
}
.lf-title {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--primary-dark);
  margin-bottom: .3rem;
}
.lf-subtitle {
  font-size: .88rem;
  color: var(--text-muted);
  margin: 0;
}

/* Séparateur accent sous le titre */
.lf-header::after {
  content: '';
  display: block;
  width: 40px;
  height: 3px;
  background: var(--accent);
  border-radius: 2px;
  margin: .75rem auto 0;
}

/* Champs */
.lf-field { margin-bottom: 1.25rem; }
.lf-label {
  display: block;
  font-size: .82rem;
  font-weight: 600;
  color: var(--primary-dark);
  margin-bottom: .45rem;
  letter-spacing: .3px;
}
.lf-label i { color: var(--primary-light); margin-right: .3rem; font-size: .78rem; }
.lf-input-wrap { position: relative; }
.lf-input {
  width: 100%;
  padding: .75rem 1rem;
  border: 1.5px solid #C5D5DC;
  border-radius: 10px;
  font-size: .95rem;
  color: var(--text);
  background: #EEF4F7;
  transition: border-color .2s, box-shadow .2s, background .2s;
  outline: none;
}
.lf-input:focus {
  border-color: var(--primary-light);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(0,107,133,.15);
}
.lf-input::placeholder { color: #94A8B3; }
.lf-input-password .lf-input { padding-right: 3rem; }
.lf-eye-btn {
  position: absolute;
  right: .85rem; top: 50%;
  transform: translateY(-50%);
  background: none; border: none;
  color: #7A9EAA; cursor: pointer;
  padding: .2rem;
  transition: color .2s;
  font-size: .95rem;
}
.lf-eye-btn:hover { color: var(--primary); }

/* Options (remember / forgot) */
.lf-options {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  font-size: .82rem;
}
.lf-remember {
  display: flex; align-items: center; gap: .4rem;
  cursor: pointer; color: var(--text-muted); user-select: none;
}
.lf-remember input[type="checkbox"] {
  accent-color: var(--primary);
  width: 15px; height: 15px;
  cursor: pointer;
}
.lf-forgot {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
  transition: color .2s;
}
.lf-forgot:hover { color: var(--accent-dark); text-decoration: underline; }

/* Bouton submit — bleu pétrole avec liseré orange au hover */
.lf-submit-btn {
  width: 100%;
  padding: .85rem;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: .5px;
  cursor: pointer;
  transition: opacity .2s, transform .15s, box-shadow .2s;
  box-shadow: 0 4px 14px rgba(0,77,97,.35);
  position: relative;
  overflow: hidden;
}
.lf-submit-btn::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 3px;
  background: var(--accent);
  opacity: 0;
  transition: opacity .2s;
}
.lf-submit-btn:hover {
  opacity: .93;
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(0,77,97,.45);
}
.lf-submit-btn:hover::after { opacity: 1; }
.lf-submit-btn:active { transform: translateY(0); }

/* Bloc démo */
.lf-demo {
  margin-top: 1.75rem;
  background: var(--primary-xlight);
  border: 1px solid #AAD0DC;
  border-radius: 10px;
  padding: .9rem 1rem;
}
.lf-demo-title {
  font-size: .78rem;
  font-weight: 700;
  color: var(--primary-dark);
  margin-bottom: .55rem;
}
.lf-demo-title i { color: var(--primary-light); margin-right: .3rem; }
.lf-demo-grid { display: flex; flex-direction: column; gap: .3rem; }
.lf-demo-row {
  font-size: .78rem;
  color: var(--primary-dark);
  display: flex; align-items: center; gap: .4rem;
}
.lf-demo-role {
  font-weight: 700;
  background: var(--primary);
  color: #fff;
  border-radius: 4px;
  padding: 1px 6px;
  font-size: .72rem;
  min-width: 72px;
  text-align: center;
}
.lf-demo-row code {
  background: rgba(0,77,97,.1);
  color: var(--primary-dark);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: .76rem;
}
.lf-demo-warn {
  font-size: .68rem;
  color: var(--accent-dark);
  margin-top: .5rem;
  margin-bottom: 0;
  font-weight: 600;
}
.lf-demo-warn::before { content: "⚠ "; }

/* ---- Responsive login ---- */
@media (max-width: 768px) {
  /* Masquer entièrement le panneau gauche (illustration) sur mobile */
  .login-panel-left { display: none; }

  /* Le formulaire occupe tout l'écran */
  .login-split { flex-direction: column; }
  .login-panel-right {
    flex: 1;
    min-height: 100vh;
    padding: 2.5rem 1.25rem;
    background: var(--bg);
  }

  /* Fond de page cohérent avec la nouvelle palette */
  .login-page { background: var(--bg); }
}

/* ---- Hover card (search) ---- */
.hover-card { transition: transform var(--transition), box-shadow var(--transition); }
.hover-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md) !important; }

/* ---- Logo fallback ---- */
.logo-fallback {
  width: 40px; height: 40px;
  background: rgba(255,255,255,.3);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 900; font-size: 1.1rem; color: #fff;
}

/* ---- Print styles ---- */
@media print {
  .sidebar, #topNavbar, .btn, .btn-group, .page-header .d-flex > a, .alert { display: none !important; }
  .app-content { margin: 0 !important; padding: 0 !important; }
  .app-content .container-fluid { padding: 0 !important; }
  .card { box-shadow: none !important; border: 1px solid #ddd !important; }
  body { background: #fff !important; font-size: 11pt; }
  table { font-size: 9pt; }
}

/* ============================================================
   RESPONSIVE APP — sidebar mobile (< 768px)
   ============================================================ */
@media (max-width: 768px) {

  /* --- Sidebar : tiroir gauche fixe --- */
  .sidebar {
    transform: translateX(-100%);
    width: 280px !important;        /* largeur fixe, jamais icon-only */
    top: var(--topbar-h);
    z-index: 1045;
    box-shadow: none;
    transition: transform var(--transition), box-shadow var(--transition);
  }

  .sidebar.mobile-open {
    transform: translateX(0);
    box-shadow: 6px 0 24px rgba(0,0,0,.28);
  }

  /* --- Contenu : pleine largeur --- */
  .app-content { margin-left: 0 !important; }

  /* --- Backdrop semi-transparent --- */
  .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 1044;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    cursor: pointer;
  }
  .sidebar-backdrop.active { display: block; }

  /* --- Neutraliser COMPLÈTEMENT sidebar-collapsed sur mobile ---
     On force toujours le mode "étendu" avec labels + icônes à gauche */
  body.sidebar-collapsed .sidebar {
    width: 280px !important;
    transform: translateX(-100%);
  }
  body.sidebar-collapsed .sidebar.mobile-open {
    transform: translateX(0);
  }

  /* Réafficher tous les éléments masqués par sidebar-collapsed */
  body.sidebar-collapsed .sidebar-brand span,
  body.sidebar-collapsed .user-info,
  body.sidebar-collapsed .nav-label,
  body.sidebar-collapsed .nav-section-title,
  body.sidebar-collapsed .sidebar-footer .flex-grow-1 {
    display: revert !important;
  }

  /* Rétablir les paddings et alignements gauche */
  body.sidebar-collapsed .sidebar-brand {
    justify-content: flex-start !important;
    padding: 14px 16px !important;
  }
  body.sidebar-collapsed .sidebar-user {
    justify-content: flex-start !important;
    padding: 12px 16px !important;
  }
  body.sidebar-collapsed .sidebar-nav .nav-link {
    justify-content: flex-start !important;
    padding: 8px 12px !important;
  }
  body.sidebar-collapsed .sidebar-nav .nav-item {
    margin: 1px 8px !important;
  }

  /* --- Icônes TOUJOURS alignées à gauche sur mobile --- */
  .sidebar-nav .nav-link {
    justify-content: flex-start !important;
    align-items: center !important;
  }
  .nav-icon {
    flex-shrink: 0;
    width: 22px;
    text-align: center;
  }
  .nav-label {
    display: inline !important;
    flex: 1;
  }

  /* --- KPI responsive --- */
  .kpi-value { font-size: 1.4rem; }
  .kpi-card  { padding: 12px; }
}
