/* =========================================================================
   LMF Planning Tournées — feuille de style
   Design sobre & professionnel, responsive (mobile / tablette / desktop)
   ========================================================================= */
:root {
    --navy: #1f3a5f;
    --navy-dark: #16293f;
    --navy-light: #2f527e;
    --accent: #2d9cdb;
    --accent-dark: #1d7fb8;
    --green: #27ae60;
    --green-bg: #e7f7ee;
    --red: #e0524d;
    --red-bg: #fdecec;
    --amber: #e6a23c;
    --amber-bg: #fdf4e6;
    --gray-50: #f7f9fb;
    --gray-100: #eef2f6;
    --gray-200: #e1e8ef;
    --gray-300: #cdd7e2;
    --gray-500: #7b8a9a;
    --gray-700: #45525f;
    --ink: #24303c;
    --radius: 10px;
    --radius-sm: 7px;
    --shadow: 0 1px 3px rgba(22,41,63,.08), 0 1px 2px rgba(22,41,63,.06);
    --shadow-md: 0 4px 16px rgba(22,41,63,.12);
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font-family: var(--font); color: var(--ink); background: var(--gray-50); font-size: 15px; line-height: 1.5; }
a { color: var(--accent-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0 0 .6rem; color: var(--navy); font-weight: 650; }
h2 { font-size: 1.05rem; }
h3 { font-size: .95rem; }
.muted { color: var(--gray-500); font-size: .85em; }
.hint { color: var(--gray-500); font-size: .8rem; margin: .4rem 0 0; }
.empty { color: var(--gray-500); text-align: center; padding: 2rem 1rem; }
.empty--sm { padding: 1rem .5rem; font-size: .85rem; }

/* ---------- Boutons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
    padding: .55rem 1rem; border-radius: var(--radius-sm); border: 1px solid transparent;
    font-size: .9rem; font-weight: 600; cursor: pointer; transition: all .15s; white-space: nowrap;
    font-family: inherit; text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn--primary { background: var(--accent); color: #fff; }
.btn--primary:hover { background: var(--accent-dark); color: #fff; }
.btn--secondary { background: var(--navy); color: #fff; }
.btn--secondary:hover { background: var(--navy-dark); color: #fff; }
.btn--ghost { background: #fff; color: var(--gray-700); border-color: var(--gray-300); }
.btn--ghost:hover { background: var(--gray-100); color: var(--ink); }
.btn--danger { background: var(--red); color: #fff; }
.btn--danger:hover { background: #c8403b; color: #fff; }
.btn--sm { padding: .3rem .6rem; font-size: .8rem; }
.btn--lg { padding: .8rem 1.2rem; font-size: 1rem; }
.btn--block { width: 100%; }
.inline-form { display: inline; margin: 0; }

/* ---------- Badges / chips ---------- */
.badge { display: inline-block; padding: .15rem .55rem; border-radius: 20px; font-size: .72rem; font-weight: 700; letter-spacing: .02em; }
.badge--gray { background: var(--gray-200); color: var(--gray-700); }
.badge--blue { background: #dcefff; color: var(--accent-dark); }
.badge--green { background: var(--green-bg); color: var(--green); }
.badge--red { background: var(--red-bg); color: var(--red); }
.chip { display: inline-block; background: var(--gray-100); border: 1px solid var(--gray-200); color: var(--gray-700); padding: .12rem .5rem; border-radius: 6px; font-size: .75rem; margin: .1rem .15rem .1rem 0; }
.chip--sm { font-size: .68rem; padding: .08rem .4rem; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; vertical-align: middle; }
.dot--warn { background: var(--amber); }
.dot--green { background: var(--green); }
.dot--red { background: var(--red); }
.dot--gray { background: var(--gray-300); }

.due { font-weight: 600; }
.due--overdue { color: var(--red); }
.due--soon { color: var(--amber); }
.due--ok { color: var(--gray-700); }

/* ---------- Alertes ---------- */
.alert { padding: .7rem 1rem; border-radius: var(--radius-sm); margin-bottom: 1rem; font-size: .9rem; border: 1px solid transparent; }
.alert--success { background: var(--green-bg); color: #1c7a44; border-color: #b7e6c9; }
.alert--error { background: var(--red-bg); color: #b53a35; border-color: #f3c4c2; }
.alert--info { background: #e8f4fd; color: var(--accent-dark); border-color: #bfe2f7; }

/* ============================ LAYOUT ADMIN ============================ */
.layout-admin { display: flex; min-height: 100vh; }
.sidebar {
    width: 240px; background: var(--navy); color: #cdd9e8; display: flex; flex-direction: column;
    position: fixed; inset: 0 auto 0 0; z-index: 40;
}
.sidebar__brand { display: flex; align-items: center; gap: .6rem; padding: 1.1rem 1.2rem; border-bottom: 1px solid rgba(255,255,255,.08); }
.brand-mark { background: var(--accent); color: #fff; font-weight: 800; padding: .25rem .5rem; border-radius: 6px; letter-spacing: .03em; }
.brand-mark--lg { font-size: 1.4rem; padding: .4rem .7rem; }
.brand-text { font-weight: 600; color: #fff; font-size: .95rem; }
.sidebar__nav { display: flex; flex-direction: column; padding: .8rem .6rem; gap: .15rem; flex: 1; }
.nav-link { display: flex; align-items: center; gap: .7rem; padding: .6rem .8rem; border-radius: var(--radius-sm); color: #b9c7d8; font-weight: 550; font-size: .9rem; }
.nav-link:hover { background: rgba(255,255,255,.07); color: #fff; text-decoration: none; }
.nav-link.is-active { background: var(--accent); color: #fff; }
.nav-link svg { width: 19px; height: 19px; flex-shrink: 0; }
.sidebar__footer { padding: 1rem 1.2rem; }
.env-badge { background: var(--amber); color: #fff; font-size: .68rem; font-weight: 700; padding: .2rem .5rem; border-radius: 5px; }

.main { flex: 1; margin-left: 240px; display: flex; flex-direction: column; min-width: 0; }
.topbar { display: flex; align-items: center; gap: 1rem; background: #fff; padding: .8rem 1.5rem; border-bottom: 1px solid var(--gray-200); position: sticky; top: 0; z-index: 30; }
.topbar__title { font-size: 1.15rem; margin: 0; flex: 1; }
.topbar__user { display: flex; align-items: center; gap: .8rem; }
.user-name { font-weight: 600; font-size: .88rem; color: var(--gray-700); }
.topbar__burger { display: none; background: none; border: none; cursor: pointer; color: var(--navy); }
.topbar__burger svg { width: 24px; height: 24px; }
.content { padding: 1.5rem; max-width: 1280px; width: 100%; }
.nav-overlay { display: none; }

/* ---------- Panels & grids ---------- */
.panel { background: #fff; border: 1px solid var(--gray-200); border-radius: var(--radius); padding: 1.2rem; box-shadow: var(--shadow); margin-bottom: 1.2rem; }
.panel__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: .8rem; }
.panel__head h2 { margin: 0; }
.panel--full { grid-column: 1 / -1; }

.cards-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 1.2rem; }
.cards-grid--3 { grid-template-columns: repeat(3, 1fr); }
.cards-grid--4 { grid-template-columns: repeat(4, 1fr); }
.stat-card { display: flex; flex-direction: column; gap: .2rem; padding: 1.1rem 1.2rem; border-radius: var(--radius); background: #fff; border: 1px solid var(--gray-200); border-left: 4px solid var(--gray-300); box-shadow: var(--shadow); }
.stat-card:hover { text-decoration: none; box-shadow: var(--shadow-md); }
.stat-card__value { font-size: 1.9rem; font-weight: 750; color: var(--navy); line-height: 1; }
.stat-card__label { font-size: .82rem; color: var(--gray-500); font-weight: 600; }
.stat-card--gray { border-left-color: var(--gray-400, #9aa7b4); }
.stat-card--blue { border-left-color: var(--accent); }
.stat-card--green { border-left-color: var(--green); }
.stat-card--red { border-left-color: var(--red); }

.dash-row { display: grid; grid-template-columns: 1.4fr 1fr; gap: 1.2rem; }
.show-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.2rem; }

/* ---------- Tables ---------- */
.table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.table th { text-align: left; padding: .6rem .7rem; color: var(--gray-500); font-size: .74rem; text-transform: uppercase; letter-spacing: .03em; border-bottom: 2px solid var(--gray-200); white-space: nowrap; }
.table td { padding: .65rem .7rem; border-bottom: 1px solid var(--gray-100); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table--clickable tbody tr { cursor: pointer; }
.table--clickable tbody tr:hover { background: var(--gray-50); }
.table--compact th, .table--compact td { padding: .4rem .55rem; font-size: .82rem; }
.row-actions { text-align: right; white-space: nowrap; }
.row--muted { opacity: .55; }
.table-count { color: var(--gray-500); font-size: .8rem; margin: .8rem 0 0; }
.table-scroll { overflow: auto; }

.deflist { display: grid; grid-template-columns: minmax(120px, 38%) 1fr; gap: .4rem .8rem; margin: 0; }
.deflist dt { color: var(--gray-500); font-size: .82rem; font-weight: 600; }
.deflist dd { margin: 0; }

/* ---------- Toolbar / filtres ---------- */
.toolbar { display: flex; gap: .6rem; margin-bottom: 1.2rem; }
.toolbar--between { justify-content: space-between; align-items: center; }
.toolbar__group { display: flex; gap: .5rem; }
.filters { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: 1.2rem; }
.filters--compact { margin-bottom: .8rem; }
.filters input, .filters select, .filters__date input { padding: .45rem .6rem; border: 1px solid var(--gray-300); border-radius: var(--radius-sm); font-size: .85rem; font-family: inherit; background: #fff; }
.filters__date { font-size: .82rem; color: var(--gray-500); display: flex; align-items: center; gap: .35rem; }
.filters input[type=search] { min-width: 200px; }

/* ---------- Formulaires ---------- */
.form-page { max-width: 1100px; }
.form-page--narrow { max-width: 680px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.2rem; }
.form-grid .panel { margin-bottom: 0; }
.field { display: flex; flex-direction: column; gap: .3rem; margin-bottom: .9rem; }
.field > span { font-size: .8rem; font-weight: 600; color: var(--gray-700); }
.field input, .field select, .field textarea { padding: .55rem .7rem; border: 1px solid var(--gray-300); border-radius: var(--radius-sm); font-size: .9rem; font-family: inherit; background: #fff; width: 100%; }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(45,156,219,.15); }
.field input[readonly] { background: var(--gray-50); color: var(--gray-500); }
.field--inline { flex-direction: row; align-items: center; gap: .8rem; margin-bottom: .5rem; }
.field--inline > span { flex: 0 0 180px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: .9rem; }
.form-actions { display: flex; justify-content: flex-end; gap: .6rem; margin-top: 1.2rem; }
.form-actions--left { justify-content: flex-start; margin-top: .5rem; }
.checkgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: .5rem; }
.checkbox { display: flex; align-items: center; gap: .5rem; font-size: .88rem; cursor: pointer; }
.checkbox input { width: auto; }
.mapping-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .3rem 1.5rem; }

/* ---------- Carte ---------- */
.map { height: 320px; border-radius: var(--radius-sm); border: 1px solid var(--gray-200); margin-top: .5rem; z-index: 1; }
.map--show { height: 360px; }
.map-tools { display: flex; align-items: center; gap: .8rem; margin: .3rem 0; flex-wrap: wrap; }
.map-status { font-size: .8rem; color: var(--gray-500); }

/* ---------- Bar list / charts ---------- */
.bar-list { list-style: none; margin: .5rem 0 0; padding: 0; display: flex; flex-direction: column; gap: .55rem; }
.bar-list li { display: grid; grid-template-columns: 130px 1fr 32px; align-items: center; gap: .6rem; font-size: .85rem; }
.bar-list__name { color: var(--gray-700); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-list__track { background: var(--gray-100); border-radius: 5px; height: 12px; overflow: hidden; }
.bar-list__fill { display: block; height: 100%; background: var(--accent); border-radius: 5px; }
.bar-list__fill--red { background: var(--red); }
.bar-list__num { text-align: right; font-weight: 700; color: var(--navy); }
.stackbar { display: flex; height: 22px; border-radius: 6px; overflow: hidden; background: var(--gray-100); margin: .5rem 0; }
.stackbar__seg { height: 100%; }
.stackbar__seg--green { background: var(--green); }
.stackbar__seg--red { background: var(--red); }
.stackbar__seg--gray { background: var(--gray-300); }
.legend { list-style: none; display: flex; gap: 1.2rem; padding: 0; margin: .6rem 0 0; font-size: .82rem; color: var(--gray-700); flex-wrap: wrap; }
.legend .dot { margin-right: .35rem; }
.taglist { list-style: none; padding: 0; margin: .5rem 0 0; display: flex; flex-wrap: wrap; gap: .3rem; }

/* ---------- Auth ---------- */
.layout-auth { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: linear-gradient(135deg, var(--navy) 0%, var(--navy-light) 100%); padding: 1rem; }
.auth-card { background: #fff; border-radius: 14px; box-shadow: var(--shadow-md); padding: 2.2rem; width: 100%; max-width: 400px; }
.auth-brand { text-align: center; margin-bottom: 1.5rem; }
.auth-brand h1 { margin: .8rem 0 .2rem; font-size: 1.3rem; }
.auth-brand p { color: var(--gray-500); font-size: .85rem; margin: 0; }
.auth-form .field { margin-bottom: 1.1rem; }
.auth-hint { text-align: center; color: var(--gray-500); font-size: .78rem; margin: 1.2rem 0 0; }
.error-box { text-align: center; padding: 1rem; }
.error-box h2 { font-size: 3rem; margin: 0; }

/* ============================ PLANNING BOARD ============================ */
.planning__toolbar { margin-bottom: 1rem; }
.datenav { display: inline-flex; align-items: center; gap: .4rem; background: #fff; padding: .35rem .5rem; border-radius: var(--radius-sm); border: 1px solid var(--gray-200); }
.datenav input[type=date] { border: none; font-size: .9rem; font-family: inherit; }
.planning__board { display: grid; grid-template-columns: 290px 1fr; gap: 1rem; align-items: start; }
.planning__cols { display: flex; gap: .8rem; overflow-x: auto; padding-bottom: .5rem; }
.pcol { background: var(--gray-100); border-radius: var(--radius); padding: .6rem; min-width: 235px; flex: 1; }
.pcol--pool { background: #fff; border: 1px solid var(--gray-200); position: sticky; top: 70px; }
.pcol__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: .6rem; padding: 0 .2rem; }
.pcol__head h3 { margin: 0; font-size: .9rem; }
.count { background: var(--gray-300); color: var(--navy); border-radius: 20px; padding: .05rem .5rem; font-size: .75rem; font-weight: 700; }
.count--tour { background: var(--accent); color: #fff; }
.pcol__drop { min-height: 80px; display: flex; flex-direction: column; gap: .5rem; padding: .2rem; border-radius: var(--radius-sm); transition: background .15s; }
.pcol__drop.is-over { background: rgba(45,156,219,.12); outline: 2px dashed var(--accent); }
.pcard { background: #fff; border: 1px solid var(--gray-200); border-radius: var(--radius-sm); padding: .55rem .65rem; box-shadow: var(--shadow); cursor: grab; font-size: .82rem; }
.pcard:active { cursor: grabbing; }
.pcard.is-dragging { opacity: .4; }
.pcard__head { display: flex; align-items: center; gap: .35rem; margin-bottom: .3rem; }
.pcard__order { background: var(--navy); color: #fff; font-size: .68rem; font-weight: 700; padding: .05rem .35rem; border-radius: 4px; }
.pcard__head strong { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pcard__time { font-size: .72rem; color: var(--amber); font-weight: 700; }
.pcard__body { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.pcard__foot { display: flex; justify-content: space-between; align-items: center; margin-top: .35rem; }
.pcard__link { font-size: .72rem; color: var(--gray-500); }
.pcard__remove { background: none; border: none; color: var(--red); cursor: pointer; font-size: .9rem; line-height: 1; }

/* ============================ LAYOUT MOBILE ============================ */
.layout-mobile { background: var(--gray-100); }
.mtop { background: var(--navy); color: #fff; position: sticky; top: 0; z-index: 20; }
.mtop__row { display: flex; align-items: center; gap: .8rem; padding: .8rem 1rem; max-width: 640px; margin: 0 auto; }
.mtop__brand { background: var(--accent); padding: .2rem .5rem; border-radius: 5px; font-weight: 800; }
.mtop__user { flex: 1; font-size: .9rem; font-weight: 600; }
.iconbtn { background: rgba(255,255,255,.12); border: none; color: #fff; width: 38px; height: 38px; border-radius: 9px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; font-size: 1rem; text-decoration: none; }
.iconbtn svg { width: 20px; height: 20px; }
.mcontent { max-width: 640px; margin: 0 auto; padding: 1rem; }
.tour-head { margin-bottom: 1rem; }
.datenav--mobile { display: flex; width: 100%; justify-content: space-between; align-items: center; margin-bottom: .8rem; background: #fff; }
.tour-date { text-align: center; }
.tour-date strong { display: block; color: var(--navy); }
.tour-date small { color: var(--gray-500); }
.tour-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .6rem; counter-reset: stop; }
.tcard { display: flex; align-items: center; gap: .8rem; background: #fff; border-radius: var(--radius); padding: .8rem; box-shadow: var(--shadow); border-left: 4px solid var(--accent); }
.tcard:hover { text-decoration: none; }
.tcard--done { border-left-color: var(--green); }
.tcard--ko { border-left-color: var(--red); }
.tcard__num { flex: 0 0 32px; height: 32px; background: var(--navy); color: #fff; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: .9rem; }
.tcard__main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .1rem; }
.tcard__main strong { color: var(--ink); }
.tcard__sub { font-size: .78rem; color: var(--gray-700); }
.tcard__addr { font-size: .76rem; color: var(--gray-500); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tcard__meta { display: flex; flex-direction: column; align-items: flex-end; gap: .2rem; }
.tcard__time { background: var(--amber-bg); color: var(--amber); font-weight: 700; font-size: .75rem; padding: .1rem .4rem; border-radius: 5px; }
.tick { font-weight: 800; }
.tick--ok { color: var(--green); }
.tick--ko { color: var(--red); }
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--gray-500); }

.back-link { display: inline-block; margin-bottom: .8rem; font-size: .9rem; }
.mdetail__head { background: #fff; border-radius: var(--radius); padding: 1rem; box-shadow: var(--shadow); margin-bottom: 1rem; }
.mdetail__head h2 { margin: 0 0 .2rem; }
.navbtns { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; margin-bottom: 1rem; }
.mblock { background: #fff; border-radius: var(--radius); padding: 1rem; box-shadow: var(--shadow); margin-bottom: .8rem; }
.mblock h3 { color: var(--gray-500); text-transform: uppercase; font-size: .72rem; letter-spacing: .04em; }
.mblock p { margin: .2rem 0 0; }
.mblock--info { display: flex; gap: 2rem; }
.kv { display: flex; flex-direction: column; }
.kv span { font-size: .72rem; color: var(--gray-500); text-transform: uppercase; }
.phone-link { font-weight: 600; font-size: 1.05rem; }
.segmented { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: .4rem; margin-bottom: 1rem; }
.seg { position: relative; }
.seg input { position: absolute; opacity: 0; }
.seg span { display: block; text-align: center; padding: .7rem .3rem; border: 2px solid var(--gray-200); border-radius: var(--radius-sm); font-weight: 600; font-size: .88rem; cursor: pointer; background: #fff; }
.seg input:checked + span { border-color: var(--accent); background: #eaf6fd; }
.seg--ok input:checked + span { border-color: var(--green); background: var(--green-bg); color: var(--green); }
.seg--ko input:checked + span { border-color: var(--red); background: var(--red-bg); color: var(--red); }
.mblock--action { padding-bottom: 1.2rem; }

/* ============================ RESPONSIVE ============================ */
@media (max-width: 980px) {
    .dash-row, .show-grid, .form-grid, .mapping-grid { grid-template-columns: 1fr; }
    .cards-grid, .cards-grid--3, .cards-grid--4 { grid-template-columns: repeat(2, 1fr); }
    .planning__board { grid-template-columns: 1fr; }
    .pcol--pool { position: static; }
}
@media (max-width: 760px) {
    .sidebar { transform: translateX(-100%); transition: transform .25s; }
    body.nav-open .sidebar { transform: translateX(0); }
    body.nav-open .nav-overlay { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 35; }
    .main { margin-left: 0; }
    .topbar__burger { display: inline-flex; }
    .content { padding: 1rem; }
    .cards-grid, .cards-grid--3, .cards-grid--4 { grid-template-columns: 1fr 1fr; }
    .grid-2 { grid-template-columns: 1fr; }
    .filters input[type=search] { min-width: 0; flex: 1; }
    .topbar__user .user-name { display: none; }
}
