@import url('https://fonts.googleapis.com/css2?family=Jost:wght@200;300;400;500&display=swap');

/* ─── RESET & VARIABLES ─────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --cream: #F5F1EA;
  --cream-dark: #EDE8DE;
  --navy: #1B3A6B;
  --navy-mid: #244d8a;
  --terra: #C4956A;
  --terra-light: rgba(196,149,106,0.12);
  --muted: #6B7A99;
  --border: rgba(27,58,107,0.1);
  --border-mid: rgba(27,58,107,0.2);
  --white: #ffffff;
  --font: 'Jost', sans-serif;
  --sidebar-w: 220px;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 2px 12px rgba(27,58,107,0.08);
  --shadow-lg: 0 8px 32px rgba(27,58,107,0.14);
}

html, body { height: 100%; overflow: hidden; font-family: var(--font); background: var(--cream); color: var(--navy); font-size: 14px; -webkit-font-smoothing: antialiased; }

a { color: inherit; text-decoration: none; }
button { font-family: var(--font); cursor: pointer; border: none; background: none; }
input, select, textarea { font-family: var(--font); }

/* ─── LAYOUT ────────────────────────────────────────────────────────────────── */
.app-layout { display: flex; height: 100vh; overflow: hidden; }

/* ─── SIDEBAR ───────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--navy);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
  transition: transform 0.25s ease;
}

.sidebar-brand {
  padding: 24px 20px 20px;
  border-bottom: 0.5px solid rgba(255,255,255,0.08);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
}

.sidebar-logo img {
  width: 36px;
  height: 36px;
  object-fit: contain;
  filter: brightness(0) invert(1);
}

.sidebar-logo-text {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.2em;
  color: white;
}

.sidebar-tagline {
  font-size: 9px;
  font-weight: 300;
  letter-spacing: 0.1em;
  color: rgba(255,255,255,0.4);
}

.sidebar-nav {
  flex: 1;
  padding: 16px 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 20px;
  font-size: 13px;
  font-weight: 300;
  color: rgba(255,255,255,0.65);
  letter-spacing: 0.04em;
  border-radius: 0;
  transition: background 0.15s, color 0.15s;
  cursor: pointer;
}

.nav-item:hover { background: rgba(255,255,255,0.06); color: rgba(255,255,255,0.9); }
.nav-item.active { background: rgba(255,255,255,0.1); color: white; border-left: 2px solid var(--terra); padding-left: 18px; font-weight: 400; }

.nav-icon { font-size: 16px; width: 20px; text-align: center; }

.sidebar-footer {
  padding: 16px 20px;
  border-top: 0.5px solid rgba(255,255,255,0.08);
  font-size: 9px;
  font-weight: 300;
  color: rgba(255,255,255,0.3);
  letter-spacing: 0.08em;
}

/* ─── MAIN ──────────────────────────────────────────────────────────────────── */
.main-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.topbar {
  background: var(--white);
  border-bottom: 0.5px solid var(--border);
  padding: 0 28px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

#sidebar-page-title { font-size: 15px; font-weight: 400; color: var(--navy); letter-spacing: 0.02em; }

.topbar-right { display: flex; align-items: center; gap: 12px; font-size: 11px; font-weight: 300; color: var(--muted); }
.topbar-date { font-size: 11px; }

#main-content {
  flex: 1;
  overflow-y: auto;
  padding: 28px;
  -webkit-overflow-scrolling: touch;
}

/* ─── PAGE HEADER ───────────────────────────────────────────────────────────── */
.page-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 24px; }
.page-header h1 { font-size: 22px; font-weight: 300; color: var(--navy); }
.page-sub { font-size: 12px; font-weight: 300; color: var(--muted); margin-top: 3px; }

/* ─── BOUTONS ───────────────────────────────────────────────────────────────── */
.btn-primary { background: var(--navy); color: white; padding: 9px 18px; border-radius: 6px; font-size: 12px; font-weight: 400; letter-spacing: 0.06em; display: inline-flex; align-items: center; gap: 6px; transition: background 0.15s; }
.btn-primary:hover { background: var(--navy-mid); }
.btn-secondary { background: var(--cream-dark); color: var(--navy); padding: 9px 18px; border-radius: 6px; font-size: 12px; font-weight: 400; }
.btn-secondary:hover { background: #ddd; }
.btn-outline { border: 0.5px solid var(--border-mid); color: var(--navy); padding: 7px 14px; border-radius: 6px; font-size: 11px; font-weight: 400; background: transparent; }
.btn-outline:hover { background: var(--cream); }
.btn-danger { background: #c0392b; color: white; padding: 9px 18px; border-radius: 6px; font-size: 12px; }
.btn-success { background: #27ae60; color: white; padding: 7px 12px; border-radius: 6px; font-size: 11px; }
.btn-link { background: none; color: var(--navy); font-size: 12px; font-weight: 400; text-decoration: underline; cursor: pointer; padding: 0; }
.btn-icon { background: none; border: none; font-size: 16px; cursor: pointer; padding: 4px 6px; border-radius: 4px; transition: background 0.1s; }
.btn-icon:hover { background: var(--cream); }
.btn-icon.danger:hover { background: #fef2f2; }
.btn-danger-ghost { background: none; border: 0.5px solid #e74c3c; color: #c0392b; padding: 5px 10px; border-radius: 5px; font-size: 11px; cursor: pointer; opacity: 0.5; transition: opacity 0.15s; }
.btn-danger-ghost:hover { opacity: 1; background: #fef2f2; }
.btn-sm { padding: 5px 12px; font-size: 11px; border-radius: 5px; display: inline-flex; align-items: center; gap: 4px; }

/* ─── TABLES ────────────────────────────────────────────────────────────────── */
.table-wrap { background: var(--white); border: 0.5px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.data-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.data-table thead { background: var(--cream); }
.data-table th { padding: 10px 14px; text-align: left; font-size: 10px; font-weight: 400; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); border-bottom: 0.5px solid var(--border); }
.data-table td { padding: 12px 14px; border-bottom: 0.5px solid var(--border); vertical-align: middle; }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: var(--cream); }

/* ─── BADGES & TAGS ─────────────────────────────────────────────────────────── */
.badge-compta { background: var(--cream-dark); color: var(--navy); font-size: 10px; font-weight: 500; padding: 2px 8px; border-radius: 20px; letter-spacing: 0.06em; }
.tag { display: inline-block; font-size: 10px; font-weight: 400; padding: 2px 9px; border-radius: 20px; letter-spacing: 0.06em; }
.tag-particulier { background: #E8F4F8; color: #1B5E7B; }
.tag-pro { background: #EDE8FC; color: #4527A0; }
.tag-nautique { background: #E3F2FD; color: #0D47A1; }
.tag-concierge { background: #FFF3E0; color: #E65100; }
.tag-terrain  { background: #E8F5E9; color: #2E7D32; }
.tag-admin    { background: #FFF8E1; color: #F57F17; }
.tag-realisee { background: #E8F5E9; color: #2E7D32; font-weight: 500; }

.statut-badge { display: inline-block; font-size: 10px; font-weight: 400; padding: 3px 10px; border-radius: 20px; letter-spacing: 0.06em; }
.statut-demande    { background: #EDE9FE; color: #5B21B6; }
.statut-encours    { background: #FEF3C7; color: #92400E; }
.statut-afacturer  { background: #DBEAFE; color: #1E40AF; }
.statut-facture    { background: #D1FAE5; color: #065F46; }
.statut-annule     { background: #F3F4F6; color: #6B7280; }

/* ─── SUGGESTIONS DE CRÉNEAUX ───────────────────────────────────────────────── */
.suggestions-header { display:flex; justify-content:space-between; align-items:center; margin-bottom:0.5rem; font-size:.9rem; }
.suggestions-list   { display:flex; flex-direction:column; gap:0.4rem; max-height:240px; overflow-y:auto; }
.suggestion-item    { display:flex; align-items:center; gap:1rem; padding:0.6rem 0.75rem; border-radius:6px; background:var(--bg); border:1px solid var(--border); cursor:pointer; transition:background .15s; }
.suggestion-item:hover { background:#EDE9FE; border-color:#7C3AED; }
.suggestion-date    { font-weight:500; font-size:.85rem; min-width:100px; }
.suggestion-heure   { font-size:.85rem; color:var(--navy); font-weight:500; }

/* ─── SEARCH ────────────────────────────────────────────────────────────────── */
.search-bar { display: flex; align-items: center; gap: 10px; background: var(--white); border: 0.5px solid var(--border); border-radius: var(--radius); padding: 8px 14px; margin-bottom: 16px; }
.search-bar svg { width: 16px; height: 16px; color: var(--muted); flex-shrink: 0; }
.search-bar input { border: none; outline: none; font-family: var(--font); font-size: 13px; font-weight: 300; color: var(--navy); background: transparent; width: 100%; }

/* ─── FILTER TABS ───────────────────────────────────────────────────────────── */
.filter-tabs { display: flex; gap: 0; background: var(--white); border: 0.5px solid var(--border); border-radius: var(--radius); overflow: hidden; margin-bottom: 20px; }
.filter-chip { padding: 6px 14px; font-size: 11px; font-weight: 400; color: var(--muted); border-radius: 20px; border: 1px solid var(--border); background: var(--white); cursor: pointer; transition: all .15s; }
.filter-chip:hover { background: var(--cream); }
.filter-chip.active { background: var(--navy); color: white; border-color: var(--navy); }
.filter-select { padding: 6px 10px; font-size: 12px; border: 1px solid var(--border); border-radius: 6px; background: var(--white); color: var(--text); }
.filter-tab { flex: 1; padding: 9px 12px; font-size: 11px; font-weight: 400; color: var(--muted); text-align: center; border-right: 0.5px solid var(--border); transition: background 0.1s; cursor: pointer; }
.filter-tab:last-child { border-right: none; }
.filter-tab:hover { background: var(--cream); }
.filter-tab.active { background: var(--navy); color: white; }

/* ─── CARDS INTERVENTIONS ───────────────────────────────────────────────────── */
.cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.int-card { background: var(--white); border: 0.5px solid var(--border); border-radius: var(--radius-lg); padding: 16px; transition: box-shadow 0.15s; }
.int-card:hover { box-shadow: var(--shadow); }
.int-card-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 10px; gap: 10px; }
.int-card-header strong { font-size: 14px; font-weight: 400; }
.int-type-icon { margin-right: 6px; }
.int-card-meta { display: flex; flex-wrap: wrap; gap: 8px; font-size: 11px; font-weight: 300; color: var(--muted); margin-bottom: 10px; }
.int-desc { font-size: 12px; font-weight: 300; color: var(--muted); line-height: 1.6; margin-bottom: 10px; }
.int-card-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; padding-top: 10px; border-top: 0.5px solid var(--border); }

/* ─── PROGRESS BAR ──────────────────────────────────────────────────────────── */
.progress-bar-wrap { background: var(--cream-dark); border-radius: 20px; height: 5px; margin: 8px 0 4px; overflow: hidden; }
.progress-bar { background: var(--navy); height: 100%; border-radius: 20px; transition: width 0.3s; }
.progress-bar.over { background: #c0392b; }

/* ─── KPI DASHBOARD ─────────────────────────────────────────────────────────── */
.kpi-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 24px; }
.kpi-card { background: var(--white); border: 0.5px solid var(--border); border-radius: var(--radius-lg); padding: 16px; text-align: center; }
.kpi-icon { font-size: 20px; margin-bottom: 8px; }
.kpi-val { font-size: 24px; font-weight: 300; color: var(--navy); }
.kpi-label { font-size: 10px; font-weight: 300; color: var(--muted); margin-top: 4px; letter-spacing: 0.06em; text-transform: uppercase; }
.kpi-warning { border-top: 3px solid #F59E0B; }
.kpi-alert { border-top: 3px solid #3B82F6; }
.kpi-success { border-top: 3px solid #10B981; }
.kpi-terra { border-top: 3px solid var(--terra); }

.dash-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 20px; }
.dash-section { background: var(--white); border: 0.5px solid var(--border); border-radius: var(--radius-lg); padding: 18px; }
.dash-section.full-width { grid-column: 1 / -1; }
.dash-section h3 { font-size: 13px; font-weight: 500; margin-bottom: 14px; display: flex; align-items: center; gap: 8px; }
.badge-count { background: var(--terra); color: white; font-size: 10px; font-weight: 400; padding: 1px 7px; border-radius: 20px; }
.dash-item { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 0.5px solid var(--border); gap: 10px; }
.dash-item:last-child { border-bottom: none; }
.dash-item strong { font-size: 13px; font-weight: 400; display: block; }
.dash-meta { font-size: 11px; font-weight: 300; color: var(--muted); }
.see-all { font-size: 11px; color: var(--terra); cursor: pointer; text-align: center; margin-top: 10px; }

/* ─── PLANNING ──────────────────────────────────────────────────────────────── */
.planning-layout { display: grid; grid-template-columns: 1fr 340px; gap: 20px; }
.cal-wrap { background: var(--white); border: 0.5px solid var(--border); border-radius: var(--radius-lg); padding: 20px; }
.cal-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; font-size: 14px; font-weight: 400; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px; }
.cal-header-cell { text-align: center; font-size: 9px; font-weight: 400; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); padding: 6px 0; }
.cal-cell { min-height: 60px; padding: 6px; border-radius: 6px; cursor: pointer; transition: background 0.1s; position: relative; }
.cal-cell:hover { background: var(--cream); }
.cal-cell.empty { cursor: default; }
.cal-cell.today { background: var(--cream-dark); }
.cal-cell.today .cal-day-num { color: var(--terra); font-weight: 500; }
.cal-day-num { font-size: 12px; font-weight: 300; display: block; margin-bottom: 4px; }
.cal-dots { display: flex; gap: 2px; flex-wrap: wrap; }
.cal-dot { width: 6px; height: 6px; border-radius: 50%; display: inline-block; }
.dot-terrain  { background: var(--navy); }
.dot-admin    { background: var(--terra); }
.dot-realisee { background: #2E7D32; }
.dot-perso    { background: #9CA3AF; }
.cal-legend { display: flex; gap: 16px; margin-top: 12px; font-size: 11px; font-weight: 300; color: var(--muted); }
.cal-legend span { display: flex; align-items: center; gap: 5px; }

.upcoming-wrap { background: var(--white); border: 0.5px solid var(--border); border-radius: var(--radius-lg); padding: 18px; overflow-y: auto; max-height: 500px; }
.upcoming-wrap h3 { font-size: 13px; font-weight: 500; margin-bottom: 14px; }
.upcoming-item { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 0.5px solid var(--border); }
.upcoming-item:last-child { border-bottom: none; }
.upcoming-date strong { font-size: 12px; font-weight: 400; display: block; }
.upcoming-date span { font-size: 10px; color: var(--muted); }
.upcoming-info strong { font-size: 12px; display: block; }
.upcoming-info span { font-size: 10px; color: var(--muted); display: block; margin-top: 2px; }
.upcoming-info { flex: 1; }

/* ─── SITES ─────────────────────────────────────────────────────────────────── */
.site-item { display: flex; justify-content: space-between; align-items: flex-start; padding: 14px 0; border-bottom: 0.5px solid var(--border); }
.site-item:last-child { border-bottom: none; }
.site-item strong { font-size: 13px; }
.site-item p { font-size: 11px; color: var(--muted); margin-top: 3px; }
.site-item small { font-size: 10px; color: var(--terra); }

/* ─── FORMS ─────────────────────────────────────────────────────────────────── */
.modal-form { display: flex; flex-direction: column; gap: 14px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 11px; font-weight: 400; color: var(--navy); letter-spacing: 0.04em; }
.field input, .field select, .field textarea { width: 100%; padding: 9px 12px; border: 0.5px solid var(--border-mid); border-radius: 6px; font-family: var(--font); font-size: 13px; font-weight: 300; color: var(--navy); background: var(--cream); outline: none; transition: border-color 0.15s; -webkit-appearance: none; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--navy); background: white; }
.field textarea { resize: vertical; min-height: 80px; line-height: 1.6; }
.field select { cursor: pointer; }

.timer-block { background: var(--cream-dark); border-radius: var(--radius); padding: 14px; }
.timer-block label { font-size: 10px; font-weight: 400; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); display: block; margin-bottom: 8px; }
.timer-display { font-size: 28px; font-weight: 200; color: var(--navy); text-align: center; letter-spacing: 0.08em; margin-bottom: 10px; font-variant-numeric: tabular-nums; }
.timer-btns { display: flex; gap: 6px; justify-content: center; }

/* ─── MODAL ─────────────────────────────────────────────────────────────────── */
.modal-bg { position: fixed; inset: 0; background: rgba(27,58,107,0.35); display: none; align-items: center; justify-content: center; z-index: 100; padding: 20px; backdrop-filter: blur(2px); }
.modal-bg.open { display: flex; }
.modal-content { background: white; border-radius: 16px; max-width: 680px; width: 100%; max-height: 88vh; overflow-y: auto; padding: 28px; box-shadow: var(--shadow-lg); -webkit-overflow-scrolling: touch; }
.modal-content h2 { font-size: 18px; font-weight: 400; margin-bottom: 20px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; padding-top: 16px; border-top: 0.5px solid var(--border); }
.modal-header-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.modal-header-row h2 { margin-bottom: 0; }
.modal-cards { max-height: none; }

/* ─── DETAIL ────────────────────────────────────────────────────────────────── */
.detail-grid { display: flex; flex-direction: column; gap: 0; border: 0.5px solid var(--border); border-radius: var(--radius); overflow: hidden; margin-bottom: 16px; }
.detail-row { display: grid; grid-template-columns: 140px 1fr; gap: 12px; padding: 10px 14px; border-bottom: 0.5px solid var(--border); font-size: 12px; }
.detail-row:last-child { border-bottom: none; }
.detail-row span { font-weight: 300; color: var(--muted); align-self: start; padding-top: 1px; }
.detail-row strong, .detail-row p { font-weight: 400; }
.detail-row.full { grid-template-columns: 1fr; gap: 6px; }
.photos-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.photo-thumb { width: 120px; height: 90px; object-fit: cover; border-radius: 6px; border: 0.5px solid var(--border); }
.signature-img { max-width: 280px; border: 0.5px solid var(--border); border-radius: 6px; }

/* ─── TOAST ─────────────────────────────────────────────────────────────────── */
#toast-container { position: fixed; bottom: 24px; right: 24px; display: flex; flex-direction: column; gap: 8px; z-index: 200; }
.toast { background: var(--navy); color: white; padding: 10px 18px; border-radius: 8px; font-size: 12px; font-weight: 300; box-shadow: var(--shadow-lg); opacity: 0; transform: translateY(8px); transition: all 0.25s; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.toast-error { background: #c0392b; }

/* ─── EMPTY & ERROR ─────────────────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 32px; color: var(--muted); font-size: 13px; font-weight: 300; line-height: 1.7; }
.error-state { text-align: center; padding: 40px; color: #c0392b; font-size: 13px; }

/* ─── SCROLLBAR ─────────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(27,58,107,0.2); border-radius: 2px; }

/* ─── BURGER MOBILE ─────────────────────────────────────────────────────────── */
.burger-btn { display: none; background: none; border: none; padding: 6px; cursor: pointer; }
.burger-btn svg { width: 22px; height: 22px; color: var(--navy); }

@media (max-width: 900px) {
  .burger-btn { display: block; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; z-index: 50; transform: translateX(-100%); }
  .sidebar.mobile-open { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .kpi-grid { grid-template-columns: repeat(3, 1fr); }
  .planning-layout { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .dash-layout { grid-template-columns: 1fr; }
}

/* ─── FORFAITS ──────────────────────────────────────────────────────────────── */
.forfaits-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px,1fr)); gap: 14px; }
.forfait-card { background: var(--white); border: 0.5px solid var(--border); border-radius: var(--radius-lg); padding: 18px; transition: box-shadow 0.15s; }
.forfait-card:hover { box-shadow: var(--shadow); }
.forfait-card.forfait-warn { border-left: 3px solid #F59E0B; }
.forfait-card.forfait-alert { border-left: 3px solid #EF4444; }
.forfait-card.forfait-archived { opacity: 0.6; }
.forfait-card-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 10px; }

/* Dot devis calendrier */
.dot-devis { background: var(--terra); }

/* Tag devis planning */
.tag-devis { background: #FFF3E0; color: #E65100; }

/* ─── SYNC INDICATOR ─────────────────────────────────────────────────────────── */
.sync-indicator {
  width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0;
  transition: background-color 0.4s;
}
.sync-indicator.online   { background: #22C55E; }
.sync-indicator.offline  { background: #94A3B8; }
.sync-indicator.syncing  { background: #F59E0B; animation: pulse-sync 1s ease-in-out infinite; }
.sync-indicator.error    { background: #EF4444; }
@keyframes pulse-sync {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}
.topbar-right { display: flex; align-items: center; gap: 10px; }
