/* =====================================================
   AFRI-CONTACT — Gestion des Appels d'Offres
   Web-first, responsive. Rouge #CC1020 / Gris #5A5F6B
   ===================================================== */

:root {
  --rouge:        #CC1020;
  --rouge-dark:   #A00C18;
  --rouge-light:  rgba(204,16,32,.1);
  --gris:         #5A5F6B;
  --gris-dark:    #3C4049;
  --gris-light:   #f4f6f9;
  --sidebar-w:    260px;
  --sidebar-w-sm: 64px;
  --topbar-h:     54px;
  --border:       #e2e6ea;
  --shadow:       0 2px 8px rgba(0,0,0,.07);
  --radius:       10px;
}

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

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--gris-light);
  color: #343a40;
  margin: 0;
  overflow-x: hidden;
}

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

/* ── Layout ───────────────────────────────────────── */
#app-wrapper {
  display: flex;
  min-height: 100vh;
}

/* ── SIDEBAR ──────────────────────────────────────── */
#sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--gris-dark);
  color: #c8ccd4;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 200;
  overflow-y: auto;
  overflow-x: hidden;
  transition: width .22s ease, transform .22s ease;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.1) transparent;
}

/* Collapsed (desktop) */
#sidebar.collapsed { width: var(--sidebar-w-sm); }
#sidebar.collapsed .nav-link-text,
#sidebar.collapsed .nav-section-title,
#sidebar.collapsed .sidebar-tagline,
#sidebar.collapsed .logo-text-wrap,
#sidebar.collapsed .user-details { display: none !important; }
#sidebar.collapsed .nav-link { justify-content: center; padding: 10px 0; }
#sidebar.collapsed .logo-container { justify-content: center; padding: 16px 0; }
#sidebar.collapsed .user-info { justify-content: center; }
#sidebar.collapsed .sidebar-footer-btns { flex-direction: column; }

/* Mobile: slide in/out */
@media (max-width: 767.98px) {
  #sidebar {
    transform: translateX(-100%);
    width: var(--sidebar-w);
    box-shadow: 4px 0 20px rgba(0,0,0,.3);
  }
  #sidebar.mobile-open { transform: translateX(0); }
  #sidebar-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 199;
  }
  #sidebar-overlay.show { display: block; }
}

/* Sidebar header */
.sidebar-header {
  padding: 16px 14px 12px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  flex-shrink: 0;
}

.logo-container {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
}

.logo-img {
  max-width: 140px;
  max-height: 48px;
  object-fit: contain;
  display: block;
}

.logo-text-wrap { line-height: 1; }
.logo-ac      { color: var(--rouge); font-size: 1.25rem; font-weight: 900; }
.logo-contact { color: #d0d4db; font-size: 1.25rem; font-weight: 400; }

.sidebar-tagline {
  font-size: .65rem;
  color: #7a8090;
  margin-top: 4px;
  white-space: nowrap;
}

/* Nav */
.nav-section-title {
  font-size: .6rem;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: #666c7a;
  padding: 14px 16px 4px;
  text-transform: uppercase;
  white-space: nowrap;
}

#sidebar .nav-link {
  color: #b0b5c0;
  padding: 9px 16px;
  border-radius: 7px;
  margin: 1px 8px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: .87rem;
  transition: background .13s, color .13s;
  white-space: nowrap;
}
#sidebar .nav-link:hover { background: rgba(255,255,255,.07); color: #fff; }
#sidebar .nav-link.active { background: var(--rouge); color: #fff; font-weight: 600; }
#sidebar .nav-link i { font-size: .95rem; width: 18px; text-align: center; flex-shrink: 0; }

/* Sidebar footer */
.sidebar-footer {
  margin-top: auto;
  padding: 14px;
  border-top: 1px solid rgba(255,255,255,.08);
  flex-shrink: 0;
}

.user-info { display: flex; align-items: center; gap: 10px; }

.user-avatar {
  width: 34px; height: 34px;
  background: var(--rouge);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .72rem; color: #fff;
  flex-shrink: 0; text-transform: uppercase;
}

.user-details { display: flex; flex-direction: column; overflow: hidden; }
.user-name  { font-size: .8rem; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role  { font-size: .68rem; color: #888; }

.sidebar-footer-btns { display: flex; gap: 6px; margin-top: 8px; }

/* ── MAIN CONTENT ─────────────────────────────────── */
#main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  transition: margin-left .22s ease;
}

#main-content.expanded { margin-left: var(--sidebar-w-sm); }

@media (max-width: 767.98px) {
  #main-content { margin-left: 0; }
}

/* ── TOPBAR ───────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  background: #fff;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 16px;
  position: sticky;
  top: 0; z-index: 100;
  box-shadow: 0 1px 4px rgba(0,0,0,.05);
  gap: 12px;
}

.topbar .breadcrumb { margin: 0; font-size: .82rem; }
.topbar .breadcrumb-item a { color: var(--rouge); }

.topbar-date {
  margin-left: auto;
  font-size: .8rem;
  color: #9aa0ac;
  white-space: nowrap;
}

/* ── CONTENT AREA ─────────────────────────────────── */
.content-area {
  padding: 20px 24px;
  flex: 1;
}
@media (max-width: 575.98px) { .content-area { padding: 14px 12px; } }

/* ── PAGE TITLE ───────────────────────────────────── */
.page-title {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--gris-dark);
  border-bottom: 3px solid var(--rouge);
  padding-bottom: 6px;
  margin-bottom: 20px;
  display: inline-block;
}

/* ── CARDS ────────────────────────────────────────── */
.card {
  border: none;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  background: #fff;
}
.card-header {
  background: #fff;
  border-bottom: 2px solid #f0f1f3;
  font-weight: 600;
  font-size: .88rem;
  border-radius: var(--radius) var(--radius) 0 0 !important;
  padding: 12px 16px;
}
.card-body { padding: 16px; }

/* ── STAT CARDS ───────────────────────────────────── */
.stat-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 16px 20px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 14px;
  transition: transform .15s, box-shadow .15s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0,0,0,.1); }

.stat-icon {
  width: 50px; height: 50px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem; flex-shrink: 0;
}
.stat-icon.rouge  { background: var(--rouge-light);        color: var(--rouge); }
.stat-icon.bleu   { background: rgba(13,110,253,.1);        color: #0d6efd; }
.stat-icon.vert   { background: rgba(25,135,84,.1);         color: #198754; }
.stat-icon.orange { background: rgba(253,126,20,.1);        color: #fd7e14; }
.stat-icon.gris   { background: rgba(90,95,107,.1);         color: var(--gris); }

.stat-value { font-size: 1.75rem; font-weight: 700; line-height: 1; color: var(--gris-dark); }
.stat-label { font-size: .78rem; color: #888; margin-top: 2px; }

/* ── BUTTONS ──────────────────────────────────────── */
.btn-rouge, .btn-primary {
  background: var(--rouge);
  border-color: var(--rouge);
  color: #fff !important;
}
.btn-rouge:hover, .btn-primary:hover,
.btn-rouge:focus, .btn-primary:focus {
  background: var(--rouge-dark);
  border-color: var(--rouge-dark);
}
.btn-outline-rouge {
  border-color: var(--rouge);
  color: var(--rouge);
}
.btn-outline-rouge:hover { background: var(--rouge); color: #fff; }

/* Bootstrap overrides */
.text-primary { color: var(--rouge) !important; }
.bg-primary    { background: var(--rouge) !important; }
.border-primary{ border-color: var(--rouge) !important; }

/* ── BADGES / STATUS ──────────────────────────────── */
.badge-statut {
  font-size: .7rem;
  padding: 4px 10px;
  border-radius: 20px;
  font-weight: 600;
}
.countdown {
  font-size: .7rem;
  padding: 3px 8px;
  border-radius: 20px;
  white-space: nowrap;
}

/* ── PROGRESS BAR ─────────────────────────────────── */
.progress { height: 7px; border-radius: 4px; }
.progress-bar { background: var(--rouge); }

/* ── TABLE ────────────────────────────────────────── */
.table { font-size: .87rem; }
.table th {
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--gris);
  font-weight: 600;
  border-bottom-width: 2px;
  white-space: nowrap;
}
.table td { vertical-align: middle; }
.table-responsive { border-radius: var(--radius); }

/* ── CHECKLIST ────────────────────────────────────── */
.checklist-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 12px;
  border-radius: 6px;
  margin-bottom: 3px;
  background: #f8f9fa;
  transition: background .1s;
}
.checklist-item:hover { background: #e9ecef; }
.checklist-item.done  { background: rgba(25,135,84,.07); }
.checklist-item.done .item-label { text-decoration: line-through; color: #999; }
.checklist-item input[type="checkbox"] {
  width: 17px; height: 17px;
  cursor: pointer; flex-shrink: 0;
  accent-color: var(--rouge);
}
.item-label { flex: 1; margin: 0; cursor: pointer; font-size: .86rem; }

/* ── TACHES ───────────────────────────────────────── */
.tache-card { border-left: 4px solid var(--border); }
.tache-card.haute   { border-left-color: #dc3545; }
.tache-card.normale { border-left-color: #ffc107; }
.tache-card.basse   { border-left-color: #0dcaf0; }
.tache-card.retard  { background: rgba(220,53,69,.04); }

/* ── AO URGENCE ───────────────────────────────────── */
.ao-urgence { animation: pulse-rouge 1.5s infinite; }
@keyframes pulse-rouge {
  0%,100% { box-shadow: 0 0 0 0 rgba(204,16,32,.3); }
  50%      { box-shadow: 0 0 0 6px rgba(204,16,32,0); }
}

/* ── SECTION HEADER ───────────────────────────────── */
.section-header {
  background: linear-gradient(135deg, var(--rouge) 0%, var(--rouge-dark) 100%);
  color: #fff;
  padding: 16px 20px;
  border-radius: var(--radius);
  margin-bottom: 16px;
}
@media (max-width: 575.98px) { .section-header { padding: 12px 14px; } }

/* ── DROP ZONE ────────────────────────────────────── */
.drop-zone {
  border: 2px dashed #ccc;
  border-radius: 8px;
  padding: 24px 16px;
  text-align: center;
  cursor: pointer;
  transition: all .2s;
  background: #fafafa;
}
.drop-zone:hover, .drop-zone.drag-over {
  border-color: var(--rouge);
  background: var(--rouge-light);
}

/* ── EXPIRATION STATUTS ───────────────────────────── */
.exp-expire   { color: #dc3545; font-weight: 600; }
.exp-alerte   { color: #fd7e14; font-weight: 600; }
.exp-valide   { color: #198754; }
.exp-permanent{ color: #888; }

/* ── EMPTY STATE ──────────────────────────────────── */
.empty-state { text-align: center; padding: 48px 20px; color: #aaa; }
.empty-state i { font-size: 2.8rem; margin-bottom: 10px; display: block; }

/* ── LOGIN PAGE ───────────────────────────────────── */
.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, var(--gris-dark) 0%, #1a1e24 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.login-card {
  background: #fff;
  border-radius: 16px;
  padding: 44px 36px;
  width: 100%; max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
@media (max-width: 479px) { .login-card { padding: 28px 20px; } }

.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo .logo-ac      { font-size: 1.9rem; font-weight: 900; color: var(--rouge); }
.login-logo .logo-contact { font-size: 1.9rem; color: var(--gris); }

/* ── RESPONSIVE HELPERS ───────────────────────────── */
/* Table sur mobile : rendre scrollable */
@media (max-width: 767.98px) {
  .table-responsive-stack td,
  .table-responsive-stack th { white-space: nowrap; }

  .stat-card { padding: 12px 14px; }
  .stat-icon { width: 42px; height: 42px; font-size: 1.1rem; }
  .stat-value { font-size: 1.4rem; }

  .section-header h2 { font-size: 1.1rem; }

  /* Nav tabs scroll horizontal */
  .nav-tabs { flex-wrap: nowrap; overflow-x: auto; }
  .nav-tabs::-webkit-scrollbar { height: 3px; }
  .nav-tabs .nav-link { white-space: nowrap; font-size: .82rem; padding: 8px 12px; }

  /* Boutons en colonne sur mobile */
  .btn-group-mobile { display: flex; flex-direction: column; gap: 6px; }
  .btn-group-mobile .btn { width: 100%; }
}

@media (max-width: 575.98px) {
  .page-title { font-size: 1.1rem; }
  .card-body { padding: 12px; }
  .content-area { padding: 12px 10px; }
  .topbar { padding: 0 10px; }

  /* Cacher certaines colonnes de table sur mobile */
  .hide-mobile { display: none !important; }

  /* Réduire les marges des grilles */
  .row.g-3, .row.g-4 { --bs-gutter-x: 10px; --bs-gutter-y: 10px; }
}

/* ── PRINT ────────────────────────────────────────── */
@media print {
  #sidebar, .topbar, .btn, .dropdown { display: none !important; }
  #main-content { margin-left: 0 !important; }
  .content-area { padding: 0; }
  .card { box-shadow: none; border: 1px solid #dee2e6; }
}

/* ── SCROLLBAR (Webkit) ───────────────────────────── */
#sidebar::-webkit-scrollbar { width: 4px; }
#sidebar::-webkit-scrollbar-track { background: transparent; }
#sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); border-radius: 4px; }
