/* ============================================================
   MISSIONS BRIORD — app.css
   Mobile-first, charte Briord (noir #1a1a2e, or #c9a96e)
   ============================================================ */

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

:root {
  --noir:    #1a1a2e;
  --or:      #c9a96e;
  --or-light:#e8d5a3;
  --blanc:   #ffffff;
  --gris-bg: #f4f4f6;
  --gris-bd: #e0e0e0;
  --gris-txt:#666;
  --rouge:   #e63946;
  --orange:  #ff9800;
  --bleu:    #2196f3;
  --vert:    #4caf50;
  --violet:  #9c27b0;
  --radius:  10px;
  --shadow:  0 2px 12px rgba(0,0,0,.1);
  --header-h:56px;
  --bottom-h:64px;
}

html, body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--gris-bg);
  color: var(--noir);
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
}

a { text-decoration: none; color: inherit; }
img { max-width: 100%; }

/* ---- HEADER ---- */
.mob-header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  height: var(--header-h);
  background: var(--noir);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,.3);
}
.mob-menu-btn {
  background: none; border: none; cursor: pointer;
  width: 36px; height: 36px; display: flex; flex-direction: column;
  justify-content: center; gap: 5px; padding: 4px;
}
.mob-menu-btn span {
  display: block; height: 2px; background: var(--or); border-radius: 2px;
  transition: .3s;
}
.mob-logo {
  color: var(--or); font-weight: 700; font-size: 16px;
  display: flex; align-items: center; gap: 6px;
}
.mob-logo span { display: none; }
.mob-header-right { display: flex; align-items: center; gap: 8px; }
.mob-notif-btn {
  color: var(--blanc); font-size: 20px; position: relative;
  width: 36px; height: 36px; display: flex; align-items: center; justify-content: center;
}
.notif-badge {
  position: absolute; top: 0; right: 0;
  background: var(--rouge); color: #fff; font-size: 10px; font-weight: 700;
  border-radius: 10px; padding: 1px 5px; min-width: 16px; text-align: center;
}
.mob-add-btn {
  background: var(--or); color: var(--noir);
  width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 700; line-height: 1;
}

/* ---- DRAWER ---- */
.mob-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 150;
}
.mob-overlay.open { display: block; }
.mob-drawer {
  position: fixed; top: 0; left: -280px; bottom: 0; width: 280px;
  background: var(--noir); z-index: 200;
  transition: left .3s ease; overflow-y: auto;
  padding-bottom: 24px;
}
.mob-drawer.open { left: 0; }
.drawer-user {
  padding: 24px 16px 16px;
  border-bottom: 1px solid rgba(201,169,110,.2);
  display: flex; align-items: center; gap: 12px;
  margin-top: 8px;
}
.drawer-avatar {
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--or); color: var(--noir);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 18px; flex-shrink: 0;
}
.drawer-name { color: var(--blanc); font-weight: 600; font-size: 15px; }
.drawer-role { color: var(--or); font-size: 12px; margin-top: 2px; }
.drawer-menu { list-style: none; padding: 8px 0; }
.drawer-menu li a {
  display: flex; align-items: center; gap: 10px;
  padding: 13px 20px; color: #ccc; font-size: 15px;
  transition: background .2s, color .2s;
}
.drawer-menu li a:hover, .drawer-menu li a.active {
  background: rgba(201,169,110,.1); color: var(--or);
}
.drawer-sep {
  padding: 8px 20px 4px; color: #555; font-size: 11px;
  text-transform: uppercase; letter-spacing: 1px;
}
.logout-link { color: var(--rouge) !important; }
.badge-menu {
  background: var(--rouge); color: #fff; border-radius: 10px;
  padding: 1px 6px; font-size: 11px; font-weight: 700; margin-left: auto;
}

/* ---- MAIN CONTENT ---- */
.main-content {
  padding: var(--header-h) 0 calc(var(--bottom-h) + 16px);
  min-height: 100vh;
}

/* ---- BOTTOM NAV ---- */
.mob-bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
  height: var(--bottom-h);
  background: var(--blanc);
  border-top: 1px solid var(--gris-bd);
  display: flex; align-items: stretch;
  box-shadow: 0 -2px 10px rgba(0,0,0,.08);
}
.mob-bottom-nav a {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 3px; font-size: 10px; color: #999;
  padding: 6px 2px;
  transition: color .2s;
}
.mob-bottom-nav a span:first-child { font-size: 22px; }
.mob-bottom-nav a.active, .mob-bottom-nav a:hover { color: var(--or); }
.mob-bottom-nav .nav-add {
  background: var(--noir); color: var(--or) !important;
  border-radius: 16px 16px 0 0; margin: 0 4px;
}
.mob-bottom-nav .nav-add span:first-child { font-size: 28px; }

/* ---- CONTAINERS ---- */
.container { padding: 16px; }
.page-title {
  font-size: 20px; font-weight: 700; color: var(--noir);
  margin-bottom: 16px; display: flex; align-items: center; gap: 8px;
}

/* ---- CARDS ---- */
.card {
  background: var(--blanc); border-radius: var(--radius);
  box-shadow: var(--shadow); margin-bottom: 12px; overflow: hidden;
}
.card-header {
  padding: 14px 16px; border-bottom: 1px solid var(--gris-bd);
  font-weight: 600; font-size: 15px;
}
.card-body { padding: 16px; }

/* ---- MISSION CARD ---- */
.mission-card {
  background: var(--blanc); border-radius: var(--radius);
  box-shadow: var(--shadow); margin-bottom: 10px;
  overflow: hidden; cursor: pointer;
  transition: transform .15s, box-shadow .15s;
  display: block;
  border-left: 4px solid var(--gris-bd);
}
.mission-card:active { transform: scale(.98); }
.mission-card-inner { padding: 14px 14px 12px; }
.mission-card-top {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 6px; gap: 8px;
}
.mission-ref { font-size: 11px; color: #999; font-weight: 600; letter-spacing: .5px; }
.mission-titre { font-size: 15px; font-weight: 600; color: var(--noir); line-height: 1.3; }
.mission-desc { font-size: 13px; color: var(--gris-txt); margin: 4px 0 8px; line-height: 1.4; }
.mission-meta {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
}
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px; border-radius: 20px;
  font-size: 11px; font-weight: 600;
}
.badge-priorite { color: #fff; }
.badge-statut { color: #fff; }
.badge-projet {
  background: rgba(26,26,46,.08); color: var(--noir); font-size: 11px;
}
.badge-type { background: var(--gris-bg); color: var(--gris-txt); }
.mission-footer {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 14px; background: var(--gris-bg);
  font-size: 11px; color: #999;
}
.mission-responsable { display: flex; align-items: center; gap: 5px; }
.avatar-xs {
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--or); color: var(--noir);
  font-size: 10px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
}

/* ---- FILTRES ---- */
.filters {
  padding: 10px 16px; background: var(--blanc);
  border-bottom: 1px solid var(--gris-bd);
  display: flex; gap: 8px; overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.filters::-webkit-scrollbar { display: none; }
.filter-btn {
  flex-shrink: 0; padding: 6px 14px; border-radius: 20px;
  border: 1px solid var(--gris-bd); background: var(--blanc);
  font-size: 13px; cursor: pointer; white-space: nowrap;
  transition: all .2s;
}
.filter-btn.active { background: var(--noir); color: var(--or); border-color: var(--noir); }

/* ---- FORMULAIRES ---- */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block; font-size: 13px; font-weight: 600;
  color: var(--noir); margin-bottom: 6px;
}
.form-label .required { color: var(--rouge); margin-left: 3px; }
.form-control {
  width: 100%; padding: 12px 14px;
  border: 1.5px solid var(--gris-bd); border-radius: var(--radius);
  font-size: 15px; background: var(--blanc); color: var(--noir);
  -webkit-appearance: none; appearance: none;
  transition: border-color .2s;
}
.form-control:focus {
  outline: none; border-color: var(--or);
  box-shadow: 0 0 0 3px rgba(201,169,110,.15);
}
select.form-control { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23666' d='M6 8L0 0h12z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; padding-right: 36px; }
textarea.form-control { resize: vertical; min-height: 80px; }

/* PRIORITE SELECTOR */
.priorite-selector { display: flex; gap: 8px; }
.priorite-btn {
  flex: 1; padding: 10px 4px; border-radius: 8px;
  border: 2px solid var(--gris-bd); background: var(--blanc);
  cursor: pointer; text-align: center; transition: all .2s;
  font-size: 12px; font-weight: 600;
}
.priorite-btn.selected { border-color: currentColor; color: #fff; }
.priorite-btn[data-p="1"] { color: var(--rouge); }
.priorite-btn[data-p="2"] { color: var(--orange); }
.priorite-btn[data-p="3"] { color: var(--bleu); }
.priorite-btn[data-p="4"] { color: var(--vert); }
.priorite-btn[data-p="5"] { color: #9e9e9e; }
.priorite-btn[data-p="1"].selected { background: var(--rouge); border-color: var(--rouge); }
.priorite-btn[data-p="2"].selected { background: var(--orange); border-color: var(--orange); }
.priorite-btn[data-p="3"].selected { background: var(--bleu); border-color: var(--bleu); }
.priorite-btn[data-p="4"].selected { background: var(--vert); border-color: var(--vert); }
.priorite-btn[data-p="5"].selected { background: #9e9e9e; border-color: #9e9e9e; }

/* PHOTOS UPLOAD */
.photos-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 8px; }
.photo-slot {
  aspect-ratio: 1; border-radius: 8px; overflow: hidden;
  border: 2px dashed var(--gris-bd); background: var(--gris-bg);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; position: relative;
}
.photo-slot img { width: 100%; height: 100%; object-fit: cover; }
.photo-slot .add-icon { font-size: 28px; color: #ccc; }
.photo-slot .remove-photo {
  position: absolute; top: 4px; right: 4px;
  background: rgba(0,0,0,.6); color: #fff; border: none;
  border-radius: 50%; width: 22px; height: 22px; font-size: 14px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
}

/* BOUTONS */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 13px 20px; border-radius: var(--radius);
  font-size: 15px; font-weight: 600; cursor: pointer;
  border: none; transition: all .2s; text-align: center;
}
.btn-full { width: 100%; }
.btn-primary { background: var(--noir); color: var(--or); }
.btn-primary:hover { background: #0d0d1a; }
.btn-or { background: var(--or); color: var(--noir); }
.btn-or:hover { background: var(--or-light); }
.btn-danger { background: var(--rouge); color: #fff; }
.btn-success { background: var(--vert); color: #fff; }
.btn-outline {
  background: transparent; color: var(--noir);
  border: 1.5px solid var(--gris-bd);
}
.btn-sm { padding: 8px 14px; font-size: 13px; }

/* ---- DASHBOARD ---- */
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
.stat-card {
  background: var(--blanc); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow); text-align: center;
}
.stat-number { font-size: 28px; font-weight: 700; color: var(--noir); }
.stat-label { font-size: 12px; color: var(--gris-txt); margin-top: 4px; }
.stat-card.urgente .stat-number { color: var(--rouge); }
.stat-card.en-cours .stat-number { color: var(--orange); }
.stat-card.terminee .stat-number { color: var(--vert); }

/* ---- DETAIL MISSION ---- */
.mission-detail-header {
  background: var(--noir); color: var(--or);
  padding: 16px; margin-bottom: 16px;
}
.mission-detail-titre { font-size: 18px; font-weight: 700; color: var(--blanc); margin: 8px 0; }
.mission-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.timeline { padding: 0; list-style: none; }
.timeline-item {
  position: relative; padding: 12px 12px 12px 40px;
  border-left: 2px solid var(--gris-bd); margin-left: 14px;
}
.timeline-item:last-child { border-left-color: transparent; }
.timeline-dot {
  position: absolute; left: -9px; top: 14px;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--or); border: 2px solid var(--blanc);
}
.timeline-date { font-size: 11px; color: #999; margin-bottom: 4px; }
.timeline-content { font-size: 13px; }

/* ---- PHOTOS GALERIE ---- */
.photos-galerie { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.photo-thumb {
  border-radius: 8px; overflow: hidden; aspect-ratio: 4/3; cursor: pointer;
}
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; }

/* ---- TOAST ---- */
.toast-success, .toast-error {
  position: fixed; top: calc(var(--header-h) + 8px); left: 50%; transform: translateX(-50%);
  z-index: 500; padding: 12px 20px; border-radius: var(--radius);
  font-size: 14px; font-weight: 600; white-space: nowrap;
  box-shadow: var(--shadow); transition: opacity .5s;
}
.toast-success { background: var(--vert); color: #fff; }
.toast-error { background: var(--rouge); color: #fff; }

/* ---- EMPTY STATE ---- */
.empty-state {
  text-align: center; padding: 48px 24px; color: var(--gris-txt);
}
.empty-state .empty-icon { font-size: 56px; margin-bottom: 12px; }
.empty-state p { font-size: 15px; margin-bottom: 16px; }

/* ---- LOGIN ---- */
.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: var(--noir); padding: 24px;
}
.login-box {
  background: rgba(255,255,255,.05); border: 1px solid rgba(201,169,110,.2);
  border-radius: 16px; padding: 32px 24px; width: 100%; max-width: 380px;
}
.login-logo { text-align: center; margin-bottom: 24px; }
.login-logo .logo-castle { font-size: 52px; }
.login-logo h1 { color: var(--or); font-size: 22px; font-weight: 700; margin-top: 8px; }
.login-logo p { color: #999; font-size: 13px; }
.login-box .form-label { color: #ccc; }
.login-box .form-control { background: rgba(255,255,255,.07); border-color: rgba(255,255,255,.15); color: #fff; }
.login-box .form-control:focus { border-color: var(--or); }
.login-error { background: rgba(230,57,70,.2); border: 1px solid var(--rouge); color: #ff8a8a; border-radius: 8px; padding: 10px 14px; margin-bottom: 16px; font-size: 13px; }

/* ---- ADMIN ---- */
.admin-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.admin-table th { background: var(--noir); color: var(--or); padding: 10px 12px; text-align: left; font-size: 12px; }
.admin-table td { padding: 10px 12px; border-bottom: 1px solid var(--gris-bd); vertical-align: middle; }
.admin-table tr:hover td { background: rgba(201,169,110,.05); }

/* ---- MAP ---- */
#map { width: 100%; height: 400px; border-radius: var(--radius); overflow: hidden; }

/* ---- GPS BUTTON ---- */
.gps-btn {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 16px; background: var(--gris-bg);
  border: 1.5px solid var(--gris-bd); border-radius: var(--radius);
  font-size: 14px; cursor: pointer; width: 100%;
  transition: all .2s;
}
.gps-btn.success { border-color: var(--vert); color: var(--vert); }

/* ---- DESKTOP ---- */
@media (min-width: 768px) {
  .mob-logo span { display: inline; }
  .main-content { padding-left: 280px; padding-top: var(--header-h); }
  .mob-drawer {
    left: 0 !important; top: var(--header-h); height: calc(100vh - var(--header-h));
    z-index: 90;
  }
  .mob-overlay { display: none !important; }
  .mob-menu-btn { display: none; }
  .mob-bottom-nav { display: none; }
  .main-content { padding-bottom: 24px; }
  .stats-grid { grid-template-columns: repeat(4, 1fr); }
  .photos-grid { grid-template-columns: repeat(4, 1fr); }
  .photos-galerie { grid-template-columns: repeat(4, 1fr); }
  .container { max-width: 900px; }
}
