/* ════════════════════════════════════════════════════════════════════════════
   MANAY — CSS PARTAGÉ (style.css)
   Ce fichier contient TOUS les styles communs à toutes les pages.
   Les styles spécifiques à chaque page vont dans dashboard.css, operations.css, etc.
   ════════════════════════════════════════════════════════════════════════════ */


/* ════════════════════════════════════════════════════════════════════════════
   VARIABLES
   ════════════════════════════════════════════════════════════════════════════ */
:root {
  --bg: #f8fafc;
  --card: #ffffff;
  --muted: #64748b;
  --text: #1e293b;
  --primary: #6366f1;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --accent: #8b5cf6;
  --border: #e2e8f0;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --ring: rgba(99,102,241,.35);
}


/* ════════════════════════════════════════════════════════════════════════════
   RESET & BASE
   ════════════════════════════════════════════════════════════════════════════ */
* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto,
               Ubuntu, Cantarell, Noto Sans, Helvetica Neue, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  padding-bottom: 3rem;
}


/* ════════════════════════════════════════════════════════════════════════════
   HEADER
   ════════════════════════════════════════════════════════════════════════════ */
.header {
  background: white;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 40;
}

.header-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}

/* Brand / Logo */
.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--text);
  text-decoration: none;
}

.brand:link,
.brand:visited,
.brand:hover {
  color: var(--text);
  text-decoration: none;
}

.logo-img {
  width: 32px;
  height: 32px;
  object-fit: contain;
}

/* Navigation pill */
.nav {
  display: flex;
  gap: 0.25rem;
  background: var(--bg);
  padding: 4px;
  border-radius: 10px;
}

.nav a {
  text-decoration: none;
  color: var(--muted);
  padding: 0.5rem 1rem;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.2s;
}

.nav a:hover {
  color: var(--text);
}

.nav a.active {
  background: white;
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

/* User menu */
.user-menu {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition: transform 0.2s;
  text-transform: uppercase;
}

.avatar:hover {
  transform: scale(1.05);
}

/* Dropdown */
.dropdown {
  position: relative;
}

.dropdown-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.5rem 0.35rem 0.35rem;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.15s;
  border: 1px solid transparent;
}

.dropdown-toggle:hover {
  background: var(--bg);
  border-color: var(--border);
}

.dropdown-toggle .user-name {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text);
}

.dropdown-toggle .chevron {
  width: 16px;
  height: 16px;
  color: var(--muted);
  transition: transform 0.2s;
}

.dropdown:hover .chevron,
.dropdown.open .chevron {
  transform: rotate(180deg);
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 180px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.12);
  padding: 0.5rem;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all 0.2s ease;
  z-index: 100;
}

.dropdown:hover .dropdown-menu,
.dropdown.open .dropdown-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.dropdown-menu a,
.dropdown-menu button {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
  padding: 0.6rem 0.75rem;
  border-radius: 8px;
  text-decoration: none;
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 500;
  border: none;
  background: none;
  cursor: pointer;
  transition: all 0.15s;
  text-align: left;
}

.dropdown-menu a:hover,
.dropdown-menu button:hover {
  background: var(--bg);
}

.dropdown-menu svg {
  width: 18px;
  height: 18px;
  color: var(--muted);
}

.dropdown-divider {
  height: 1px;
  background: var(--border);
  margin: 0.5rem 0;
}

.dropdown-menu .logout-btn {
  color: var(--danger);
}

.dropdown-menu .logout-btn:hover {
  background: rgba(239, 68, 68, 0.08);
}

.dropdown-menu .logout-btn svg {
  color: var(--danger);
}


/* ════════════════════════════════════════════════════════════════════════════
   BARRE DE RECHERCHE COMPACTE (partagée)
   ════════════════════════════════════════════════════════════════════════════ */
.search-compact {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 1.5rem;
}

.search-compact .input {
  flex: 1;
  min-width: 0;
}


/* ════════════════════════════════════════════════════════════════════════════
   LAYOUT
   ════════════════════════════════════════════════════════════════════════════ */
.container {
  max-width: 1280px;
  margin: 2rem auto;
  padding: 0 1rem;
}

.container-narrow {
  max-width: 900px;
  margin: 2rem auto;
  padding: 0 1rem;
}


/* ════════════════════════════════════════════════════════════════════════════
   TITRES DE PAGE
   ════════════════════════════════════════════════════════════════════════════ */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1.5rem;
  gap: 1rem;
  flex-wrap: wrap;
}

.page-title {
  font-size: 1.8rem;
  font-weight: 800;
  margin: 0 0 0.25rem;
  color: var(--text);
}

.subtitle {
  color: var(--muted);
  margin: 0.25rem 0 1.75rem 0;
  font-size: 0.95rem;
}


/* ════════════════════════════════════════════════════════════════════════════
   SECTIONS (CARTES)
   ════════════════════════════════════════════════════════════════════════════ */
.section {
  background: white;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: var(--shadow);
  margin-bottom: 1.5rem;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1rem;
}

.section-title {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
}

.section-title .badge {
  font-size: 0.75rem;
  color: var(--muted);
  padding: 0.2rem 0.5rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(148,163,184,.08);
  font-weight: 600;
}

/* Section groupes (profil) */
.section-group {
  margin-bottom: 2.5rem;
}

.section-group-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}


/* ════════════════════════════════════════════════════════════════════════════
   BADGE
   ════════════════════════════════════════════════════════════════════════════ */
.badge {
  font-size: 0.75rem;
  background: rgba(148,163,184,0.1);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.15rem 0.6rem;
  color: var(--muted);
  font-weight: 600;
}


/* ════════════════════════════════════════════════════════════════════════════
   BOUTONS
   ════════════════════════════════════════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.85rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: white;
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.2s;
}

.btn:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
  transform: translateY(-1px);
}

.btn.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

.btn.primary:hover {
  background: #4f46e5;
}

.btn.success {
  background: var(--success);
  border-color: var(--success);
  color: white;
}

.btn.success:hover {
  background: #16a34a;
}

.btn.warning {
  background: var(--warning);
  border-color: var(--warning);
  color: white;
}

.btn.warning:hover {
  background: #d97706;
}

.btn.danger {
  background: var(--danger);
  border-color: var(--danger);
  color: white;
}

.btn.danger:hover {
  background: #dc2626;
}

.btn.sm {
  padding: 0.4rem 0.6rem;
  font-size: 0.85rem;
}

/* Bouton "Nouvelle opération" (proéminent) */
.btn-new {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 1.1rem;
  border-radius: 10px;
  border: none;
  background: var(--primary);
  color: white;
  text-decoration: none;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 600;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(99,102,241,0.25);
}

.btn-new:hover {
  background: #4f46e5;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(99,102,241,0.35);
}

/* Bouton icône (petits boutons carrés) */
.btn-icon {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--muted);
  transition: all 0.2s;
}

.btn-icon:hover {
  border-color: var(--danger);
  color: var(--danger);
  background: rgba(239, 68, 68, 0.05);
}


/* ════════════════════════════════════════════════════════════════════════════
   FORMULAIRES
   ════════════════════════════════════════════════════════════════════════════ */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.form-group.full {
  grid-column: 1 / -1;
}

.form-group label {
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 600;
}

.required::after {
  content: ' *';
  color: var(--danger);
}

.input,
.select,
.textarea {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: white;
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  transition: all 0.2s ease;
}

.textarea {
  resize: vertical;
  min-height: 80px;
}

.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(99,102,241,0.1);
  border-color: var(--primary);
}

.help-text {
  font-size: 0.8rem;
  color: var(--muted);
}


/* ════════════════════════════════════════════════════════════════════════════
   ALERTES / FLASH MESSAGES
   ════════════════════════════════════════════════════════════════════════════ */

/* Flash messages (position fixe en haut) */
.flash-messages {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.flash-msg {
  padding: 1rem 1.5rem;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,.15);
  background: white;
  border: 1px solid var(--border);
  font-size: 0.9rem;
}

.flash-msg.flash-success {
  background: #d1fae5;
  color: #065f46;
  border-color: #a7f3d0;
}

.flash-msg.flash-warning {
  background: #fef3c7;
  color: #92400e;
  border-color: #fde68a;
}

.flash-msg.flash-error {
  background: #fef2f2;
  color: #991b1b;
  border-color: #fecaca;
}

/* Alertes inline (dans les pages) */
.alert {
  padding: 0.85rem 1rem;
  border-radius: 10px;
  margin-bottom: 1.5rem;
  border: 1px solid;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.9rem;
}

.alert.warning {
  background: #fef3c7;
  color: #92400e;
  border-color: #fde68a;
}

.alert.success {
  background: #d1fae5;
  color: #065f46;
  border-color: #a7f3d0;
}

.alert.error {
  background: #fef2f2;
  color: #991b1b;
  border-color: #fecaca;
}


/* ════════════════════════════════════════════════════════════════════════════
   STATUS BADGES
   ════════════════════════════════════════════════════════════════════════════ */
.status {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.65rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(148,163,184,0.06);
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
}

.status.ok {
  color: var(--success);
  border-color: rgba(34,197,94,0.3);
  background: rgba(34,197,94,0.1);
}

.status.warn {
  color: var(--warning);
  border-color: rgba(245,158,11,0.3);
  background: rgba(245,158,11,0.1);
}

.status.bad {
  color: var(--danger);
  border-color: rgba(239,68,68,0.3);
  background: rgba(239,68,68,0.1);
}

.status.info {
  color: var(--primary);
  border-color: rgba(99,102,241,0.3);
  background: rgba(99,102,241,0.1);
}

.status.purple {
  color: var(--accent);
  border-color: rgba(139,92,246,0.3);
  background: rgba(139,92,246,0.1);
}


/* ════════════════════════════════════════════════════════════════════════════
   EMPTY STATE
   ════════════════════════════════════════════════════════════════════════════ */
.empty-state {
  text-align: center;
  padding: 4rem 2rem;
}

.empty-state-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
}

.empty-state-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.5rem;
}

.empty-state-text {
  color: var(--muted);
  margin-bottom: 1.5rem;
}

.empty-state-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  flex-wrap: wrap;
}


/* ════════════════════════════════════════════════════════════════════════════
   MODALES
   ════════════════════════════════════════════════════════════════════════════ */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 100;
  place-items: center;
  padding: 1rem;
}

.modal-overlay.active {
  display: grid;
}

.modal {
  background: white;
  border-radius: 16px;
  padding: 1.5rem;
  max-width: 420px;
  width: 100%;
  box-shadow: 0 20px 50px rgba(0,0,0,0.2);
}

.modal h3 {
  margin: 0 0 0.5rem;
}

.modal > p {
  color: var(--muted);
  margin: 0 0 1rem;
  font-size: 0.9rem;
}

.modal .form-group {
  margin-bottom: 1rem;
}

.modal .actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.25rem;
}

.modal .actions .btn {
  flex: 1;
}


/* ════════════════════════════════════════════════════════════════════════════
   OVERLAY
   ════════════════════════════════════════════════════════════════════════════ */
.overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,.3);
  z-index: 999;
  backdrop-filter: blur(2px);
}


/* ════════════════════════════════════════════════════════════════════════════
   UTILITAIRES
   ════════════════════════════════════════════════════════════════════════════ */
.flex-row {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.flex-row.align-center {
  align-items: center;
}

.flex-row.justify-between {
  justify-content: space-between;
}

.text-center { text-align: center; }
.text-right  { text-align: right; }
.text-muted  { color: var(--muted); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.font-bold   { font-weight: 700; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }


/* ════════════════════════════════════════════════════════════════════════════
   FOOTER
   ════════════════════════════════════════════════════════════════════════════ */
.footer {
  text-align: center;
  padding: 1.5rem;
  margin-top: 2rem;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.85rem;
}

.footer a {
  color: var(--muted);
  text-decoration: none;
}

.footer a:hover {
  text-decoration: underline;
}

.footer-sep {
  margin: 0 0.75rem;
}


/* ════════════════════════════════════════════════════════════════════════════
   RESPONSIVE — GLOBAL
   ════════════════════════════════════════════════════════════════════════════ */
/* ════════════════════════════════════════════════════════════════════════════
   BOTTOM NAV (mobile uniquement)
   ════════════════════════════════════════════════════════════════════════════ */
.bottom-nav {
  display: none;
}

@media (max-width: 640px) {
  .bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 58px;
    background: white;
    border-top: 1px solid var(--border);
    z-index: 50;
    box-shadow: 0 -2px 12px rgba(0,0,0,0.07);
  }

  .bottom-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.18rem;
    text-decoration: none;
    color: var(--muted);
    font-size: 0.65rem;
    font-weight: 500;
    transition: color 0.15s;
    -webkit-tap-highlight-color: transparent;
  }

  .bottom-nav-item svg {
    width: 22px;
    height: 22px;
    stroke-width: 1.8;
  }

  .bottom-nav-item.active {
    color: var(--primary);
  }

  .bottom-nav-item:hover {
    color: var(--primary);
  }
}

@media (max-width: 768px) {

  /* Header compact */
  .header-inner {
    height: 56px;
    padding: 0 1rem;
    flex-wrap: nowrap;
  }

  /* Nav desktop masquée sur mobile (remplacée par bottom-nav) */
  .nav {
    display: none;
  }

  .dropdown-toggle .user-name {
    display: none;
  }

  /* Layout */
  .container,
  .container-narrow {
    padding: 0 0.75rem;
    margin-top: 1.25rem;
  }

  .page-header {
    flex-direction: column;
    align-items: stretch;
  }

  .page-title {
    font-size: 1.4rem;
  }

  /* Sections */
  .section {
    padding: 1rem;
    border-radius: 10px;
  }

  /* Buttons */
  .btn {
    padding: 0.5rem 0.7rem;
    font-size: 0.85rem;
  }

  /* Forms */
  .form-grid {
    grid-template-columns: 1fr;
  }

  /* Modals */
  .modal {
    max-width: 100%;
    border-radius: 12px;
  }

  /* Utility overrides */
  .flex-row {
    flex-direction: column;
  }

  .flex-row.row-mobile {
    flex-direction: row;
  }
}

@media (max-width: 640px) {
  /* Recherche compacte */
  .search-compact {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
    margin-bottom: 1rem;
  }

  .search-compact .btn {
    width: 100%;
    justify-content: center;
  }

  /* Espace pour bottom nav */
  body {
    padding-bottom: 58px;
  }

  /* Header encore plus compact */
  .header-inner {
    height: 52px;
    padding: 0 0.85rem;
  }

  .logo-img {
    width: 28px;
    height: 28px;
  }

  .brand span {
    font-size: 1rem;
  }
}

@media (max-width: 480px) {
  .page-title {
    font-size: 1.25rem;
  }

  .subtitle {
    font-size: 0.85rem;
  }
}