/* ─── RESET & BASE ─────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: #f0f2f5; color: #1a1a2e; display: flex; min-height: 100vh; font-size: 14px; }
a { text-decoration: none; color: inherit; }
button { cursor: pointer; border: none; background: none; font: inherit; }

/* ─── SIDEBAR ──────────────────────────────────────────────────────────── */
.sidebar { width: 220px; min-height: 100vh; background: #1a1a2e; color: #e0e0f0; display: flex; flex-direction: column; position: fixed; top: 0; left: 0; z-index: 100; }
.sidebar-logo { padding: 24px 20px 20px; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid #2d2d4e; }
.logo-icon { font-size: 20px; color: #6c63ff; }
.logo-text { font-size: 18px; font-weight: 700; color: #fff; }
.nav-links { list-style: none; padding: 12px 0; }
.nav-links li a { display: flex; align-items: center; gap: 10px; padding: 11px 20px; color: #a0a0c0; transition: all .2s; border-left: 3px solid transparent; }
.nav-links li a:hover { background: #252540; color: #fff; }
.nav-links li a.active { background: #252540; color: #fff; border-left-color: #6c63ff; }
.nav-icon { font-size: 16px; width: 20px; text-align: center; }

/* ─── MAIN ──────────────────────────────────────────────────────────────── */
.main-content { margin-left: 220px; flex: 1; min-height: 100vh; }
.page-container { padding: 32px 36px; max-width: 1200px; }

/* ─── PAGE HEADER ───────────────────────────────────────────────────────── */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 28px; flex-wrap: wrap; gap: 12px; }
.page-header h1 { font-size: 26px; font-weight: 700; color: #1a1a2e; display: flex; align-items: center; gap: 12px; }
.date-badge { background: #e8e8ff; color: #6c63ff; padding: 4px 12px; border-radius: 20px; font-size: 13px; font-weight: 500; }
.breadcrumb { display: block; font-size: 13px; color: #888; margin-bottom: 6px; }
.breadcrumb:hover { color: #6c63ff; }
.header-actions { display: flex; gap: 10px; }

/* ─── STATS GRID ────────────────────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 28px; }
.stats-grid.small .stat-card { padding: 16px 20px; }
.stat-card { border-radius: 12px; padding: 20px 24px; color: #fff; }
.stat-card.blue { background: linear-gradient(135deg, #4facfe, #00f2fe); }
.stat-card.green { background: linear-gradient(135deg, #43e97b, #38f9d7); }
.stat-card.purple { background: linear-gradient(135deg, #a18cd1, #fbc2eb); }
.stat-card.orange { background: linear-gradient(135deg, #f093fb, #f5576c); }
.stat-card.red { background: linear-gradient(135deg, #fc4a1a, #f7b733); }
.stat-number { font-size: 28px; font-weight: 700; }
.stat-label { font-size: 13px; opacity: .85; margin-top: 2px; }

/* ─── CARDS ─────────────────────────────────────────────────────────────── */
.card { background: #fff; border-radius: 14px; padding: 22px; box-shadow: 0 2px 12px rgba(0,0,0,.06); }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.card-header h2 { font-size: 16px; font-weight: 600; }
.dashboard-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.table-card { background: #fff; border-radius: 14px; box-shadow: 0 2px 12px rgba(0,0,0,.06); overflow: hidden; }

/* ─── BUTTONS ───────────────────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 9px 18px; border-radius: 8px; font-size: 14px; font-weight: 500; transition: all .2s; }
.btn-primary { background: #6c63ff; color: #fff; }
.btn-primary:hover { background: #5a52d5; }
.btn-secondary { background: #f0f0f8; color: #4a4a6a; }
.btn-secondary:hover { background: #e4e4f5; }
.btn-success { background: #22c55e; color: #fff; }
.btn-success:hover { background: #16a34a; }
.btn-danger { background: #fee2e2; color: #dc2626; }
.btn-danger:hover { background: #fecaca; }
.btn-ghost { background: transparent; color: #666; border: 1px solid #ddd; }
.btn-ghost:hover { background: #f5f5f5; }
.btn-link { font-size: 13px; color: #6c63ff; font-weight: 500; }
.btn-link:hover { text-decoration: underline; }
.btn-small { padding: 4px 10px; font-size: 12px; background: #f0f0f8; color: #4a4a6a; border-radius: 6px; }
.btn-small:hover { background: #e4e4f5; }
.btn-small.btn-success { background: #dcfce7; color: #16a34a; }
.btn-small-full { width: 100%; justify-content: center; margin-top: 8px; }
.btn-block { display: block; text-align: center; margin-top: 12px; }
.btn-icon { width: 28px; height: 28px; display: inline-flex; align-items: center; justify-content: center; border-radius: 6px; font-size: 13px; color: #999; }
.btn-icon:hover { background: #f5f5f5; color: #333; }
.btn-icon.danger:hover { background: #fee2e2; color: #dc2626; }

/* ─── TABLE ─────────────────────────────────────────────────────────────── */
.table { width: 100%; border-collapse: collapse; }
.table th { padding: 12px 16px; text-align: left; font-size: 12px; font-weight: 600; color: #888; text-transform: uppercase; letter-spacing: .5px; border-bottom: 1px solid #f0f0f5; background: #fafafa; }
.table td { padding: 12px 16px; border-bottom: 1px solid #f5f5fa; vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: #fafafe; }

/* ─── BADGES ────────────────────────────────────────────────────────────── */
.badge { display: inline-block; padding: 3px 9px; border-radius: 20px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .3px; }
.badge-prospect { background: #dbeafe; color: #1d4ed8; }
.badge-en_cours { background: #fef3c7; color: #d97706; }
.badge-gagne { background: #dcfce7; color: #16a34a; }
.badge-perdu { background: #fee2e2; color: #dc2626; }
.badge-a_faire { background: #f3f4f6; color: #6b7280; }
.badge-en_cours { background: #fef3c7; color: #d97706; }
.badge-termine { background: #dcfce7; color: #16a34a; }
.tag { display: inline-block; background: #f3f4f6; color: #6b7280; padding: 2px 8px; border-radius: 12px; font-size: 12px; }
.tag-danger { background: #fee2e2; color: #dc2626; }

/* ─── AVATAR ────────────────────────────────────────────────────────────── */
.avatar { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 50%; background: linear-gradient(135deg, #6c63ff, #a78bfa); color: #fff; font-weight: 700; font-size: 14px; flex-shrink: 0; }
.avatar.small { width: 26px; height: 26px; font-size: 12px; }
.avatar.large { width: 42px; height: 42px; font-size: 18px; }

/* ─── PRIORITY DOT ──────────────────────────────────────────────────────── */
.priority-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; flex-shrink: 0; }
.priority-dot.large { width: 12px; height: 12px; }
.priority-basse { background: #93c5fd; }
.priority-normale { background: #fbbf24; }
.priority-haute { background: #f97316; }
.priority-urgente { background: #dc2626; }

/* ─── LISTS ─────────────────────────────────────────────────────────────── */
.simple-list { list-style: none; }
.simple-list li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid #f5f5fa; }
.simple-list li:last-child { border-bottom: none; }
.simple-list li a { display: flex; align-items: center; gap: 10px; flex: 1; }
.simple-list li a:hover strong { color: #6c63ff; }

.task-list { list-style: none; }
.task-item { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 0; border-bottom: 1px solid #f5f5fa; font-size: 13px; }
.task-item:last-child { border-bottom: none; }
.task-item.overdue { color: #dc2626; }
.task-item.done { opacity: .5; text-decoration: line-through; }
.task-meta { display: flex; align-items: center; gap: 8px; font-size: 12px; color: #888; white-space: nowrap; }

.tasks-container { display: flex; flex-direction: column; gap: 10px; }
.task-card { background: #fff; border-radius: 12px; padding: 16px 20px; display: flex; align-items: center; justify-content: space-between; gap: 16px; box-shadow: 0 2px 8px rgba(0,0,0,.05); border-left: 4px solid transparent; }
.task-card.overdue { border-left-color: #dc2626; background: #fff8f8; }
.task-card.done { opacity: .6; border-left-color: #22c55e; }
.task-card-left { display: flex; align-items: flex-start; gap: 12px; flex: 1; }
.task-card-title { font-weight: 600; margin-bottom: 4px; }
.task-card-desc { font-size: 13px; color: #888; margin-bottom: 6px; }
.task-card-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.task-card-actions { display: flex; align-items: center; gap: 8px; }

/* ─── NOTES ─────────────────────────────────────────────────────────────── */
.note-form { margin-bottom: 16px; }
.notes-list { list-style: none; }
.note-item { padding: 10px 0; border-bottom: 1px solid #f5f5fa; }
.note-item:last-child { border-bottom: none; }
.note-content { margin-bottom: 6px; font-size: 14px; white-space: pre-wrap; }
.note-footer { display: flex; align-items: center; justify-content: space-between; }
.note-date { color: #aaa; font-size: 12px; }

/* ─── FORMS ─────────────────────────────────────────────────────────────── */
.form-card { background: #fff; border-radius: 14px; padding: 28px; box-shadow: 0 2px 12px rgba(0,0,0,.06); max-width: 700px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.form-group.full-width { grid-column: 1 / -1; }
.form-group label { font-size: 13px; font-weight: 600; color: #555; }
.form-input, .form-textarea { padding: 9px 13px; border: 1px solid #ddd; border-radius: 8px; font: inherit; font-size: 14px; color: #1a1a2e; transition: border-color .2s; width: 100%; }
.form-input:focus, .form-textarea:focus { outline: none; border-color: #6c63ff; box-shadow: 0 0 0 3px rgba(108,99,255,.1); }
.form-textarea { resize: vertical; min-height: 80px; }
.form-actions { display: flex; gap: 12px; margin-top: 24px; }
.select-inline { border: none; background: transparent; font: inherit; font-size: 12px; padding: 0; cursor: pointer; }
.badge-select { font-weight: 600; padding: 3px 9px; border-radius: 20px; }

/* ─── SEARCH ────────────────────────────────────────────────────────────── */
.search-bar { margin-bottom: 20px; }
.search-bar form { display: flex; gap: 10px; }
.search-input { flex: 1; max-width: 400px; padding: 9px 14px; border: 1px solid #ddd; border-radius: 8px; font: inherit; }
.search-input:focus { outline: none; border-color: #6c63ff; }

/* ─── FILTERS ───────────────────────────────────────────────────────────── */
.filter-bar { display: flex; gap: 8px; margin-bottom: 20px; flex-wrap: wrap; }
.filter-btn { padding: 7px 16px; border-radius: 20px; font-size: 13px; font-weight: 500; color: #666; background: #fff; border: 1px solid #ddd; transition: all .2s; }
.filter-btn:hover { border-color: #6c63ff; color: #6c63ff; }
.filter-btn.active { background: #6c63ff; color: #fff; border-color: #6c63ff; }

/* ─── DETAIL GRID ───────────────────────────────────────────────────────── */
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.info-list dt { font-size: 12px; font-weight: 600; color: #999; text-transform: uppercase; margin-top: 12px; }
.info-list dd { margin-top: 2px; }
.info-list dd a { color: #6c63ff; }
.info-list dd a:hover { text-decoration: underline; }

/* ─── MODAL ─────────────────────────────────────────────────────────────── */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal-box { background: #fff; border-radius: 16px; padding: 28px; width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,.2); }
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.modal-header h2 { font-size: 18px; font-weight: 700; }

/* ─── EMPTY STATE ───────────────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 60px 20px; background: #fff; border-radius: 14px; box-shadow: 0 2px 12px rgba(0,0,0,.06); }
.empty-icon { font-size: 48px; margin-bottom: 16px; }
.empty-state p { color: #888; margin-bottom: 20px; font-size: 16px; }
.empty { text-align: center; color: #aaa; padding: 16px 0; font-size: 13px; }

/* ─── CLIENT NAME ───────────────────────────────────────────────────────── */
.client-name { display: flex; align-items: center; gap: 8px; }
.client-name:hover strong, .client-name:hover { color: #6c63ff; }

@media (max-width: 900px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
}

/* ─── ALERT ─────────────────────────────────────────────────────────────── */
.alert-card { background: #fff8e1; border: 1px solid #f59e0b; border-radius: 12px; padding: 18px 22px; margin-bottom: 24px; }
.alert-title { font-weight: 700; color: #92400e; margin-bottom: 10px; }
.alert-list { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.alert-list li { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; font-size: 13px; }

/* ─── BAR CHARTS ────────────────────────────────────────────────────────── */
.bar-item { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.bar-label { font-size: 12px; color: #555; min-width: 130px; }
.bar-track { flex: 1; height: 10px; background: #f0f0f5; border-radius: 10px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 10px; transition: width .4s; }
.bar-fill.blue { background: linear-gradient(90deg, #4facfe, #00f2fe); }
.bar-fill.green { background: linear-gradient(90deg, #43e97b, #38f9d7); }
.bar-value { font-size: 12px; font-weight: 700; color: #555; min-width: 24px; text-align: right; }

/* ─── GARANTIE BOX ──────────────────────────────────────────────────────── */
.garantie-box { display: flex; align-items: flex-start; gap: 14px; padding: 16px; border-radius: 10px; margin-top: 12px; }
.garantie-icon { font-size: 28px; }
.garantie-box.ok { background: #dcfce7; }
.garantie-box.warning { background: #fef3c7; }
.garantie-box.expired { background: #fee2e2; }

/* ─── FORM SECTIONS ─────────────────────────────────────────────────────── */
.form-section-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; color: #888; margin: 20px 0 12px; padding-bottom: 6px; border-bottom: 1px solid #eee; }
.info-box { background: #e8f4fd; border-left: 4px solid #3b82f6; padding: 12px 16px; border-radius: 6px; margin: 12px 0; font-size: 13px; }

/* ─── DEVIS LINES TABLE ─────────────────────────────────────────────────── */
.devis-table-wrap { overflow-x: auto; }
.devis-lines-table { width: 100%; border-collapse: collapse; }
.devis-lines-table th { padding: 8px 10px; text-align: left; font-size: 12px; font-weight: 600; color: #888; background: #f8f8ff; border-bottom: 2px solid #eee; }
.devis-lines-table td { padding: 6px 4px; border-bottom: 1px solid #f0f0f5; }
.line-input { width: 100%; padding: 7px 8px; border: 1px solid #ddd; border-radius: 6px; font: inherit; font-size: 13px; }
.line-input:focus { outline: none; border-color: #6c63ff; }
.line-num { text-align: right; }
.line-total { text-align: right; font-weight: 600; padding-right: 8px; font-size: 13px; white-space: nowrap; }
.line-desc { resize: vertical; min-height: 60px; font-size: 12px; }
.devis-totaux { display: flex; justify-content: flex-end; margin-top: 16px; }
.devis-total-row { display: flex; justify-content: space-between; padding: 8px 16px; gap: 60px; font-size: 14px; background: #f8f8ff; border-bottom: 1px solid #eee; }
.devis-total-row.total-ttc { background: #1a1a2e; color: #fff; font-size: 16px; font-weight: 700; border-radius: 0 0 8px 8px; }

/* ─── CATALOGUE PANEL ───────────────────────────────────────────────────── */
.catalogue-panel { display: none; background: #f8f8ff; border: 1px solid #e0e0f0; border-radius: 12px; padding: 16px; margin-bottom: 16px; }
.catalogue-panel-header { display: flex; align-items: center; justify-content: space-between; font-weight: 600; margin-bottom: 12px; font-size: 14px; }
.catalogue-search-wrap { margin-bottom: 12px; }
.catalogue-items { max-height: 320px; overflow-y: auto; }
.cat-group { margin-bottom: 12px; }
.cat-group-title { font-size: 11px; font-weight: 700; text-transform: uppercase; color: #888; letter-spacing: .5px; margin-bottom: 6px; padding: 4px 8px; background: #ededfa; border-radius: 4px; }
.cat-item { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; background: #fff; border-radius: 8px; margin-bottom: 4px; cursor: pointer; border: 1px solid transparent; transition: all .15s; width: 100%; text-align: left; font-family: inherit; font-size: inherit; color: inherit; outline: none; }
.cat-item:hover { border-color: #6c63ff; background: #f0efff; }
.cat-item-desc { font-size: 13px; flex: 1; }
.cat-item-meta { display: flex; align-items: center; gap: 8px; white-space: nowrap; margin-left: 12px; }
.cat-item-prix { font-weight: 600; color: #6c63ff; font-size: 13px; }

/* ─── BADGES DEVIS ──────────────────────────────────────────────────────── */
.badge-brouillon { background: #f3f4f6; color: #6b7280; }
.badge-envoye { background: #dbeafe; color: #1d4ed8; }
.badge-accepte { background: #dcfce7; color: #16a34a; }
.badge-refuse { background: #fee2e2; color: #dc2626; }
.badge-en_attente { background: #f3f4f6; color: #6b7280; }
.badge-en_cours { background: #fef3c7; color: #d97706; }
.badge-termine { background: #dcfce7; color: #16a34a; }
.badge-annule { background: #fee2e2; color: #dc2626; }

/* ─── SIDEBAR LOGO UPDATE ───────────────────────────────────────────────── */
.logo-sub { font-size: 10px; color: #6060a0; margin-top: 1px; }

/* ─── MOBILE OPTIMISATIONS ──────────────────────────────────────────────── */
@media (max-width: 768px) {
  /* Container principal */
  .page-container { padding: 12px !important; }

  /* Tableaux : scroll horizontal dans leur conteneur uniquement */
  .table-card { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .table { min-width: 480px; }
  .table th, .table td { padding: 8px 10px; font-size: 12px; }

  /* Cards */
  .card { padding: 14px; border-radius: 10px; }
  .dashboard-grid { grid-template-columns: 1fr !important; gap: 12px; }

  /* Formulaires en colonne unique */
  .form-grid { grid-template-columns: 1fr !important; }
  .form-card { padding: 16px; border-radius: 10px; }
  .form-actions { flex-wrap: wrap; }

  /* Stats */
  .stats-grid { grid-template-columns: repeat(2, 1fr) !important; gap: 10px; }
  .stat-number { font-size: 22px; }

  /* Boutons */
  .header-actions { flex-wrap: wrap; gap: 6px; }
  .btn { padding: 10px 14px; font-size: 13px; }

  /* Titres */
  .page-header h1 { font-size: 20px; }

  /* Filtre bar scrollable */
  .filter-bar { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 6px; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .filter-bar::-webkit-scrollbar { display: none; }
  .filter-btn { white-space: nowrap; flex-shrink: 0; }

  /* Detail grid */
  .detail-grid { grid-template-columns: 1fr !important; }

  /* Devis lines table */
  .devis-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .devis-lines-table { min-width: 480px; }

  /* Modal plein écran */
  .modal { padding: 0; align-items: flex-end; }
  .modal-box { border-radius: 16px 16px 0 0; max-height: 85vh; }

  /* Search bar */
  .search-bar form { flex-direction: column; }
  .search-input { max-width: 100%; }

  /* Charts scrollables */
  canvas { max-width: 100%; }
  .chart-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
}
