/* =========================================================
   components.css — composants réutilisables
   ========================================================= */

/* ---------- Boutons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 36px; padding: 0 14px; border-radius: var(--radius); font-weight: 600; font-size: 13.5px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  white-space: nowrap; transition: background .12s, border-color .12s, box-shadow .12s; text-decoration: none !important;
}
.btn:hover { background: var(--surface-2); border-color: #b3bdcb; }
.btn .ic { width: 16px; height: 16px; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: #b32929; border-color: #b32929; }
.btn-success { background: var(--success); border-color: var(--success); color: #fff; }
.btn-success:hover { background: #176b3b; }
.btn-warning { background: #e08a1e; border-color: #e08a1e; color: #fff; }
.btn-ghost-danger { border-color: transparent; background: transparent; color: var(--danger); }
.btn-ghost-danger:hover { background: var(--danger-bg); border-color: transparent; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-sm { height: 30px; padding: 0 10px; font-size: 12.5px; gap: 5px; }
.btn-lg { height: 46px; padding: 0 18px; font-size: 15px; }
.btn-block { width: 100%; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; pointer-events: none; }

.icon-btn {
  width: 36px; height: 36px; border-radius: var(--radius); border: 1px solid transparent; background: transparent;
  display: inline-grid; place-items: center; color: var(--muted); flex-shrink: 0;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.icon-btn.sm { width: 30px; height: 30px; }
.icon-btn.sm .ic { width: 16px; height: 16px; }
.icon-btn.danger:hover { color: var(--danger); background: var(--danger-bg); }

/* ---------- Cartes ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.card-head h2 { display: flex; align-items: center; gap: 8px; font-size: 15px; }
.card-head h2 .ic { color: var(--muted); }
.card-head p { font-size: 12.5px; color: var(--muted); }
.card-body { padding: 16px 18px; }
.card-body.flush { padding: 0; }
.card-foot { padding: 10px 18px; border-top: 1px solid var(--border); font-size: 12.5px; color: var(--muted); display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ---------- Indicateurs ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 14px 16px; display: flex; gap: 12px; align-items: flex-start; box-shadow: var(--shadow); color: inherit; min-width: 0; }
a.kpi:hover { border-color: var(--border-strong); text-decoration: none; box-shadow: var(--shadow-md); }
.kpi-ic { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; flex-shrink: 0; background: var(--primary-light); color: var(--primary); }
.kpi-ic.success { background: var(--success-bg); color: var(--success); }
.kpi-ic.warning { background: var(--warning-bg); color: var(--warning); }
.kpi-ic.danger { background: var(--danger-bg); color: var(--danger); }
.kpi-ic.info { background: var(--info-bg); color: var(--info); }
.kpi-ic.neutral { background: var(--neutral-bg); color: var(--neutral); }
.kpi-label { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.kpi-value { font-size: 24px; font-weight: 700; line-height: 1.15; letter-spacing: -.01em; margin-top: 2px; white-space: nowrap; }
.kpi-value .unit { font-size: 13px; font-weight: 600; color: var(--muted); margin-left: 3px; }
.kpi-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ---------- Badges & pastilles ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; line-height: 1.6; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .85; }
.b-gray { background: var(--neutral-bg); color: var(--neutral); }
.b-blue { background: var(--primary-light); color: var(--primary); }
.b-indigo { background: var(--info-bg); color: var(--info); }
.b-green { background: var(--success-bg); color: var(--success); }
.b-orange { background: var(--warning-bg); color: var(--warning); }
.b-red { background: var(--danger-bg); color: var(--danger); }
.b-strike { background: var(--neutral-bg); color: var(--subtle); text-decoration: line-through; }
.b-violet { background: #f3e8fd; color: #7c3aad; }
.badge.plain::before { display: none; }

.sdot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex-shrink: 0; background: var(--neutral); }
.sd-b-blue { background: var(--primary); } .sd-b-indigo { background: var(--info); } .sd-b-green { background: var(--success); }
.sd-b-orange { background: #e08a1e; } .sd-b-red { background: var(--danger); } .sd-b-strike { background: var(--subtle); } .sd-b-violet { background: #9b51d0; }

.chip { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 6px; font-size: 12px; font-weight: 600; background: var(--neutral-bg); color: var(--neutral); white-space: nowrap; }
.chip-warning { background: var(--warning-bg); color: var(--warning); }
.chip-danger { background: var(--danger-bg); color: var(--danger); }
.chip-success { background: var(--success-bg); color: var(--success); }
.chip-info { background: var(--info-bg); color: var(--info); }
.chip .ic { width: 13px; height: 13px; }

.type-chip { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; padding: 2px 8px 2px 6px; border-radius: 6px; white-space: nowrap; background: var(--neutral-bg); color: var(--neutral); }
.t-transfert_aeroport { background: #e6f0fc; color: #1f5ea8; }
.t-transfert_hotel { background: #eef0fb; color: #4a4fb0; }
.t-excursion { background: #e5f4ec; color: #1f7a48; }
.t-circuit { background: #fbeee2; color: #a3561a; }
.t-mise_a_dispo { background: #f6eaf6; color: #8a3f8a; }

.veh-tag { display: inline-block; font-family: var(--mono); font-size: 11.5px; font-weight: 700; background: #1c2430; color: #fff; padding: 1px 6px; border-radius: 4px; letter-spacing: .02em; white-space: nowrap; }
.assign { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.assign-driver { font-size: 13px; white-space: nowrap; }

/* ---------- Formulaires ---------- */
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; margin-bottom: 12px; }
.field label, .label { font-size: 12.5px; font-weight: 600; color: #3a4556; }
.req { color: var(--danger); font-weight: 700; }
.input, .field input, .field select, .field textarea, .toolbar input, .toolbar select {
  width: 100%; height: 38px; padding: 0 11px; border: 1px solid var(--border-strong); border-radius: var(--radius);
  background: var(--surface); transition: border-color .12s, box-shadow .12s; min-width: 0;
}
.field textarea { height: auto; padding: 9px 11px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus, .toolbar input:focus, .toolbar select:focus, .input:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-ring);
}
.is-invalid { border-color: var(--danger) !important; background: #fffafa !important; }
.is-invalid:focus { box-shadow: 0 0 0 3px rgba(207, 52, 52, .15) !important; }
.field-error { font-size: 12px; color: var(--danger); font-weight: 500; display: flex; align-items: center; gap: 4px; }
.field-error::before { content: "!"; width: 14px; height: 14px; border-radius: 50%; background: var(--danger); color: #fff; font-size: 10px; font-weight: 700; display: inline-grid; place-items: center; flex-shrink: 0; }
.field-hint { font-size: 12px; color: var(--muted); min-height: 0; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 14px; }
.form-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid .span-2 { grid-column: span 2; }
.form-legend { font-size: 12px; color: var(--muted); margin-bottom: 10px; }
.fs { border: 0; padding: 0; margin: 0 0 8px; min-width: 0; }
.fs legend { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 0; margin-bottom: 10px; width: 100%; border-bottom: 1px solid var(--border); padding-bottom: 6px; }
.check-row { display: flex; align-items: center; gap: 8px; font-size: 13.5px; margin-bottom: 8px; cursor: pointer; }
.check-row input { width: 16px; height: 16px; accent-color: var(--primary); }

.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 13.5px; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track { width: 36px; height: 20px; border-radius: 10px; background: var(--border-strong); position: relative; transition: background .15s; flex-shrink: 0; }
.switch .track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.2); transition: transform .15s; }
.switch input:checked + .track { background: var(--primary); }
.switch input:checked + .track::after { transform: translateX(16px); }
.switch input:focus-visible + .track { outline: 2px solid var(--primary); outline-offset: 2px; }

/* Contrôles d'affectation */
.checks { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; }
.check { display: flex; gap: 8px; align-items: flex-start; font-size: 12.5px; padding: 8px 10px; border-radius: var(--radius); line-height: 1.4; }
.check .ic { width: 16px; height: 16px; margin-top: 1px; }
.check.ok { background: var(--success-bg); color: #17663a; }
.check.err { background: var(--danger-bg); color: #a32424; font-weight: 500; }
.check.warn { background: var(--warning-bg); color: #8f4d07; }
.shake { animation: shake .35s; }
@keyframes shake { 20%, 60% { transform: translateX(-5px); } 40%, 80% { transform: translateX(5px); } }

/* ---------- Barre de filtres ---------- */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 12px 18px; border-bottom: 1px solid var(--border); }
.toolbar .search { position: relative; flex: 1 1 240px; max-width: 340px; }
.toolbar .search .ic { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--subtle); width: 16px; height: 16px; pointer-events: none; }
.toolbar .search input { padding-left: 34px; }
.toolbar select { width: auto; min-width: 150px; height: 36px; }
.toolbar input[type=date] { width: auto; height: 36px; }
.toolbar .count { margin-left: auto; font-size: 12.5px; color: var(--muted); white-space: nowrap; }

/* ---------- Tableaux ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; padding: 10px 14px; background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 11px 14px; border-bottom: 1px solid #edf0f4; vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: #fafbfd; }
.table th.text-right, .table td.text-right { text-align: right; }
.table tfoot td { font-weight: 700; background: var(--surface-2); border-top: 1px solid var(--border); }
.table.compact td { padding: 9px 12px; }
.table.compact th { padding: 8px 12px; }
.sortable th[data-sort] { cursor: pointer; user-select: none; }
.sortable th[data-sort]:hover { color: var(--text); }
.sortable th[data-sort]::after { content: "↕"; margin-left: 5px; opacity: .35; font-size: 11px; }
.sortable th[aria-sort="ascending"]::after { content: "↑"; opacity: 1; color: var(--primary); }
.sortable th[aria-sort="descending"]::after { content: "↓"; opacity: 1; color: var(--primary); }
.row-muted td { opacity: .6; }
.row-alert td:first-child { box-shadow: inset 3px 0 0 var(--danger); }
.row-flash td { animation: flash 1.6s ease; }
@keyframes flash { 0%, 30% { background: #fff6d6; } 100% { background: transparent; } }
.ref-link { font-family: var(--mono); font-weight: 700; font-size: 12.5px; white-space: nowrap; }
.route { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 13px; }
.route .ic { color: var(--subtle); }
.route-cell { min-width: 200px; max-width: 300px; }
.muted-ic { color: var(--subtle); display: inline-block; vertical-align: -2px; }
.actions { width: 1%; white-space: nowrap; }
.row-actions { display: flex; align-items: center; gap: 2px; justify-content: flex-end; }

.empty { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 32px 16px; color: var(--muted); text-align: center; }
.empty .ic { width: 28px; height: 28px; color: var(--subtle); }

/* ---------- Menus déroulants ---------- */
.dropdown { position: relative; display: inline-flex; }
.dropdown-menu {
  display: none; position: absolute; right: 0; top: calc(100% + 6px); z-index: 1000;
  min-width: 210px; max-height: 70vh; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-lg); padding: 6px;
}
.dropdown-menu.open { display: block; }
.dropdown-menu.menu-wide { width: 340px; }
.dropdown-menu > a, .dropdown-menu > button {
  display: flex; align-items: center; gap: 9px; width: 100%; padding: 8px 10px; border: 0; background: none;
  border-radius: 6px; color: var(--text); font-size: 13.5px; text-align: left; white-space: nowrap; text-decoration: none;
}
.dropdown-menu > a:hover, .dropdown-menu > button:hover { background: var(--surface-2); text-decoration: none; }
.dropdown-menu > a .ic, .dropdown-menu > button .ic { width: 16px; height: 16px; color: var(--muted); }
.dropdown-menu .danger { color: var(--danger); }
.dropdown-menu .danger .ic { color: var(--danger); }
.dropdown-menu .current { background: var(--primary-light); font-weight: 600; }
.dropdown-menu .current::after { content: "✓"; margin-left: auto; color: var(--primary); }
.menu-title { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 6px 10px 4px; }

/* ---------- Onglets & segments ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.tabs button { border: 0; background: none; padding: 10px 14px; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; display: inline-flex; gap: 6px; align-items: center; }
.tabs button:hover { color: var(--text); }
.tabs button.active { color: var(--primary); border-bottom-color: var(--primary); }
.tabs .count { font-size: 11px; background: var(--neutral-bg); color: var(--neutral); padding: 0 6px; border-radius: 9px; }
.tabs button.active .count { background: var(--primary-light); color: var(--primary); }
.seg { display: inline-flex; background: var(--neutral-bg); border-radius: var(--radius); padding: 3px; gap: 2px; }
.seg button { border: 0; background: none; padding: 5px 12px; border-radius: 6px; font-size: 13px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.seg button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

/* ---------- Modales ---------- */
.modal { position: fixed; inset: 0; z-index: 400; background: rgba(15, 23, 36, .5); display: flex; align-items: flex-start; justify-content: center; padding: 5vh 16px; overflow-y: auto; opacity: 0; transition: opacity .15s; }
.modal.is-open { opacity: 1; }
.modal-dialog { background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); width: 100%; max-width: 560px; transform: translateY(10px); transition: transform .18s ease; display: flex; flex-direction: column; margin: auto 0; }
.modal.is-open .modal-dialog { transform: none; }
.modal-sm { max-width: 440px; }
.modal-lg { max-width: 800px; }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-head h2 { font-size: 17px; }
.modal-head p { margin-top: 2px; }
.modal-body { padding: 18px 20px; }
.modal-foot { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius-lg) var(--radius-lg); flex-wrap: wrap; }
.confirm-box { display: flex; gap: 14px; align-items: flex-start; }
.confirm-ic { width: 40px; height: 40px; border-radius: 50%; background: var(--danger-bg); color: var(--danger); display: grid; place-items: center; flex-shrink: 0; }
.confirm-box.neutral .confirm-ic { background: var(--primary-light); color: var(--primary); }
.confirm-box p { padding-top: 2px; line-height: 1.55; }

/* Fiche détail */
.detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 24px; }
.dsec h3 { display: flex; align-items: center; gap: 7px; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: 8px; }
.kv { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 8px; padding: 5px 0; font-size: 13.5px; border-bottom: 1px dashed #edf0f4; }
.kv > span:first-child { color: var(--muted); }
.note-box { display: flex; gap: 8px; background: #fffbea; border: 1px solid #f4e2a6; color: #6f5a12; padding: 8px 10px; border-radius: var(--radius); font-size: 13px; margin-top: 10px; }
.note-box .ic { width: 16px; height: 16px; margin-top: 1px; }
.route-list { list-style: none; margin: 0; padding: 0; position: relative; }
.route-list li { display: flex; gap: 10px; padding: 0 0 12px; position: relative; }
.route-list li:not(:last-child)::before { content: ""; position: absolute; left: 5px; top: 14px; bottom: 0; width: 2px; background: var(--border); }
.route-list div { display: flex; flex-direction: column; font-size: 13.5px; }
.rt-dot { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--border-strong); background: #fff; margin-top: 3px; flex-shrink: 0; position: relative; z-index: 1; }
.rt-dot.start { border-color: var(--success); background: var(--success); }
.rt-dot.end { border-color: var(--danger); background: var(--danger); }
.hist { list-style: none; margin: 0; padding: 0; font-size: 13px; max-height: 180px; overflow-y: auto; }
.hist li { display: flex; gap: 12px; padding: 6px 0; border-bottom: 1px solid #f0f2f5; }
.hist-t { font-family: var(--mono); font-size: 12px; color: var(--muted); white-space: nowrap; min-width: 82px; }

/* ---------- Toasts ---------- */
.toasts { position: fixed; right: 18px; bottom: 18px; z-index: 2000; display: flex; flex-direction: column; gap: 8px; max-width: min(420px, calc(100vw - 32px)); }
.toast { display: flex; gap: 10px; align-items: flex-start; background: #1c2430; color: #fff; padding: 11px 12px 11px 14px; border-radius: 10px; box-shadow: var(--shadow-lg); font-size: 13.5px; animation: toastIn .2s ease; border-left: 4px solid var(--success); }
.toast > .ic { width: 18px; height: 18px; margin-top: 1px; }
.toast > span { flex: 1; }
.toast-success { border-left-color: #3ac27a; } .toast-success > .ic { color: #5fd897; }
.toast-error { border-left-color: #f05252; } .toast-error > .ic { color: #ff8080; }
.toast-warning { border-left-color: #f0a030; } .toast-warning > .ic { color: #ffc266; }
.toast-info { border-left-color: #7d8cff; } .toast-info > .ic { color: #a8b3ff; }
.toast-x { border: 0; background: none; color: #9aa6b8; padding: 2px; border-radius: 4px; }
.toast-x:hover { color: #fff; }
.toast.out { opacity: 0; transform: translateX(20px); transition: all .2s; }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } }

/* ---------- Divers ---------- */
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 10px 14px; border-radius: var(--radius); font-size: 13.5px; border: 1px solid; }
.alert .ic { width: 18px; height: 18px; margin-top: 1px; }
.alert-info { background: var(--info-bg); border-color: #d7d4f6; color: #3c35a0; }
.alert-warning { background: var(--warning-bg); border-color: #f3d3a4; color: #7c4306; }
.alert-danger { background: var(--danger-bg); border-color: #f5c2c2; color: #9c2020; }
.sim-tag { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--warning); background: var(--warning-bg); padding: 2px 7px; border-radius: 5px; }
.progress { height: 8px; border-radius: 4px; background: var(--neutral-bg); overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: 4px; background: var(--primary); }
.progress.success > span { background: var(--success); } .progress.warning > span { background: #e08a1e; } .progress.danger > span { background: var(--danger); }
.list { list-style: none; margin: 0; padding: 0; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 11px 18px; border-bottom: 1px solid #edf0f4; }
.list-item:last-child { border-bottom: 0; }
.dot-ic { width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; flex-shrink: 0; background: var(--neutral-bg); color: var(--neutral); }
.dot-ic .ic { width: 16px; height: 16px; }
.dot-ic.danger { background: var(--danger-bg); color: var(--danger); }
.dot-ic.warning { background: var(--warning-bg); color: var(--warning); }
.dot-ic.success { background: var(--success-bg); color: var(--success); }
.dot-ic.info { background: var(--info-bg); color: var(--info); }

/* Aperçu du message envoyé au chauffeur (simulation) */
.msg-preview { margin: 4px 0 0; padding: 12px 14px; background: #f6f8fb; border: 1px solid var(--border, #e3e8ef); border-radius: 10px; font: 13px/1.55 inherit; font-family: inherit; white-space: pre-wrap; word-break: break-word; max-height: 260px; overflow: auto; }
