/* ════════════════════════════════════════════════════════════════
   ESPACE CONTREMAÎTRE — calendrier + détail du jour
   Identité navy / lime, cohérente avec le reste de l'app.
   ════════════════════════════════════════════════════════════════ */

/* ── Bande de KPIs ─────────────────────────────────────────────── */
.cm-stats-band{
  display:grid;
  grid-template-columns:repeat(4,1fr);
  gap:14px;
  margin-bottom:1.5rem;
}
.cm-stats-band .stat-num{white-space:nowrap;}
@media(max-width:768px){
  .cm-stats-band{grid-template-columns:1fr 1fr;gap:10px;}
}

/* ── Disposition calendrier + panneau ──────────────────────────── */
.cm-layout{
  display:grid;
  grid-template-columns:minmax(0,1fr) 320px;
  gap:18px;
  align-items:start;
  margin-bottom:2rem;
}
@media(max-width:1024px){
  .cm-layout{grid-template-columns:1fr;}
  .cm-panel{order:-1;}            /* sur écran étroit : « Aujourd'hui » en premier */
}

/* ── Cadre calendrier ──────────────────────────────────────────── */
.cm-cal-wrap{
  background:var(--white,#fff);
  border:1px solid var(--border);
  border-radius:var(--radius-lg,16px);
  box-shadow:0 1px 2px rgba(13,23,33,.05),0 8px 24px rgba(13,23,33,.06);
  overflow:hidden;
}

/* ── Panneau latéral ───────────────────────────────────────────── */
.cm-panel{display:flex;flex-direction:column;gap:14px;}
.cm-panel-card{
  background:#fff;border:1px solid var(--border);
  border-radius:var(--radius-md,12px);
  box-shadow:0 1px 2px rgba(13,23,33,.04),0 6px 18px rgba(13,23,33,.05);
  padding:14px 15px;
}
.cm-panel-today{background:linear-gradient(160deg,#fff,#f3f9ff);border-color:#d7e6f5;}
.cm-panel-head{display:flex;justify-content:space-between;align-items:baseline;gap:8px;}
.cm-panel-kicker{
  font-size:11px;font-weight:800;text-transform:uppercase;
  letter-spacing:.7px;color:var(--lime-600,#3aaa35);
}
.cm-panel-date{font-size:12px;font-weight:600;color:var(--ink-500,#5a6b7e);text-transform:capitalize;}
.cm-panel-open{
  display:inline-block;margin:6px 0 12px;padding:0;
  background:none;border:none;font-family:inherit;
  color:var(--navy-600,#0a4a85);font-weight:700;font-size:12px;cursor:pointer;
}
.cm-panel-open:hover{text-decoration:underline;}
.cm-panel-title{
  font-size:12.5px;font-weight:800;color:var(--navy);
  text-transform:uppercase;letter-spacing:.4px;margin-bottom:10px;
}
.cm-panel-hours{font-size:12.5px;font-weight:700;color:var(--ink-500,#5a6b7e);margin-bottom:8px;}
.cm-panel-hours.has{color:#247a20;}
.cm-panel-conge{
  display:inline-block;font-size:13px;font-weight:800;color:#5b3fd6;
  background:rgba(124,92,255,.12);border:1px solid rgba(124,92,255,.28);
  padding:5px 11px;border-radius:8px;margin-bottom:8px;
}
.cm-panel-list{display:flex;flex-direction:column;gap:6px;}
.cm-panel-row{
  display:flex;align-items:center;gap:8px;font-size:13px;
  padding:7px 9px;background:#f7f9fc;border:1px solid #e7eef6;border-radius:8px;
}
.cm-panel-time{
  font-weight:800;color:var(--navy);font-size:12px;
  min-width:40px;flex-shrink:0;font-variant-numeric:tabular-nums;
}
.cm-panel-txt{flex:1;min-width:0;color:var(--text,#1d2a36);word-break:break-word;text-align:left;}
.cm-panel-up{cursor:pointer;transition:background .14s;}
.cm-panel-up:hover{background:#eef4fb;}
.cm-panel-update{
  font-weight:800;color:var(--navy-600,#0a4a85);font-size:11px;
  min-width:46px;flex-shrink:0;text-transform:capitalize;
}
.cm-panel-sub{
  font-size:10.5px;font-weight:800;text-transform:uppercase;letter-spacing:.5px;
  color:var(--ink-500,#5a6b7e);margin:10px 0 5px;
}
.cm-panel-sub:first-child{margin-top:0;}
.cm-panel-sub-late{color:#cc2200;}
.cm-panel-task .cm-panel-txt.late{color:#a8331f;}
.cm-late-date{
  font-size:11px;color:#cc2200;font-weight:700;
  background:rgba(204,34,0,.1);padding:0 5px;border-radius:4px;margin-left:4px;
  white-space:nowrap;
}
.cm-panel-task .cm-check{width:20px;height:20px;flex-shrink:0;}
.cm-cal-head{
  display:flex;align-items:center;gap:10px;
  padding:14px 18px;
  background:linear-gradient(180deg,#f4f7fb,#eef2f7);
  border-bottom:1px solid var(--border);
}
.cm-cal-title{
  font-size:17px;font-weight:800;color:var(--navy);
  min-width:170px;text-align:center;
}
.cm-cal-nav{
  width:34px;height:34px;flex-shrink:0;
  border:1px solid var(--border);background:#fff;border-radius:9px;
  font-size:20px;line-height:1;color:var(--navy);cursor:pointer;
  display:flex;align-items:center;justify-content:center;
  transition:all .15s;
}
.cm-cal-nav:hover{background:var(--navy);color:#fff;border-color:var(--navy);}
.cm-cal-today{margin-left:auto;font-size:12px;padding:7px 14px;}

/* Jours de la semaine (7 jours + colonne total) */
.cm-cal-dow{
  display:grid;grid-template-columns:repeat(7,1fr) 56px;
  background:#fafbfd;border-bottom:1px solid var(--border);
}
.cm-cal-dow > div{
  padding:8px 6px;text-align:center;
  font-size:11px;font-weight:700;letter-spacing:.6px;
  text-transform:uppercase;color:var(--ink-500,#5a6b7e);
}
.cm-dow-tot{background:#f1f5fa;color:var(--navy) !important;}

/* Grille des jours (7 jours + total hebdomadaire) */
.cm-cal-grid{
  display:grid;grid-template-columns:repeat(7,1fr) 56px;
}

/* Cellule total de la semaine */
.cm-week-tot{
  border-bottom:1px solid #eef2f7;
  background:#fafbfd;
  display:flex;flex-direction:column;align-items:center;justify-content:center;
  gap:3px;padding:4px;
}
.cm-week-tot.has{background:rgba(58,170,53,.06);}
.cm-week-tot strong{
  font-size:13px;font-weight:800;color:var(--navy);
  font-variant-numeric:tabular-nums;
}
.cm-week-tot.over{background:rgba(230,126,0,.08);}
.cm-week-tot.over strong{color:#c2410c;}
.cm-week-sup{
  font-size:9.5px;font-weight:800;color:#c2410c;
  background:rgba(230,126,0,.16);padding:0 5px;border-radius:5px;
}
.cm-cell{
  min-height:104px;
  border-right:1px solid #eef2f7;
  border-bottom:1px solid #eef2f7;
  padding:6px 7px;
  cursor:pointer;
  position:relative;
  transition:background .14s;
  display:flex;flex-direction:column;gap:4px;
}
.cm-cell:hover{background:#eef4fb;}
.cm-cell-empty{background:#fafbfd;cursor:default;}
.cm-cell-empty:hover{background:#fafbfd;}
.cm-cell-we{background:#f9fafc;}
.cm-cell-worked{box-shadow:inset 3px 0 0 var(--lime-600,#3aaa35);}
.cm-cell-today{background:#eaf3ff;}
.cm-cell-conge{background:#f3f0ff;box-shadow:inset 3px 0 0 #7c5cff;}
.cm-cell-conge.cm-cell-today{background:#ece6ff;}
.cm-cell-today .cm-cell-num{
  background:var(--navy);color:#fff;
  width:26px;height:26px;border-radius:50%;
  display:flex;align-items:center;justify-content:center;
}
.cm-cell-num{
  font-size:13.5px;font-weight:700;color:var(--navy);
  width:26px;height:26px;
}
.cm-cell-tags{display:flex;flex-direction:column;gap:3px;overflow:hidden;}
.cm-dot{
  display:inline-flex;align-items:center;
  font-size:10.5px;font-weight:700;line-height:1.3;
  padding:1px 6px;border-radius:5px;width:fit-content;max-width:100%;
  white-space:nowrap;overflow:hidden;text-overflow:ellipsis;
}
.cm-dot-h  {background:rgba(58,170,53,.14);color:#247a20;}
.cm-dot-ev {background:rgba(230,126,0,.14);color:#a85e00;}
.cm-dot-tk {background:rgba(26,107,176,.14);color:#0a4a85;}
.cm-dot-doc{background:rgba(0,168,156,.14);color:#00756c;}
.cm-dot-note{background:rgba(90,107,126,.14);color:#41506180;color:#415061;}
.cm-dot-conge{background:rgba(124,92,255,.16);color:#5b3fd6;font-weight:800;}

/* ── Modal détail du jour ──────────────────────────────────────── */
.cm-day-card{max-height:90vh;display:flex;flex-direction:column;}
.cm-day-body{
  overflow-y:auto;
  flex:1;
  padding-right:4px;
  margin-right:-4px;
}
.cm-sec{
  padding:14px 0;
  border-bottom:1px solid #eef2f7;
}
.cm-sec:last-child{border-bottom:none;}
.cm-sec-title{
  display:flex;align-items:center;gap:8px;
  font-size:13px;font-weight:800;color:var(--navy);
  text-transform:uppercase;letter-spacing:.5px;
  margin-bottom:10px;
}
.cm-sec-title span{font-size:15px;}

/* Heures */
.cm-hours-grid{
  display:grid;grid-template-columns:1fr 1fr 1fr 1.1fr;gap:10px;align-items:end;
}
.cm-hours-grid .field span{
  font-size:11px;font-weight:600;color:var(--muted);
  display:block;margin-bottom:4px;
}
.cm-hours-grid input{
  width:100%;box-sizing:border-box;
  padding:9px 10px;font-size:14px;
  border:1px solid var(--border);border-radius:9px;
  font-family:inherit;
}
.cm-hours-grid input:focus{
  outline:none;border-color:var(--navy-500);
  box-shadow:0 0 0 3px rgba(26,107,176,.14);
}
.cm-hours-total{
  background:rgba(58,170,53,.10);
  border:1px solid rgba(58,170,53,.25);
  border-radius:9px;padding:7px 12px;text-align:center;
}
.cm-hours-total span{
  display:block;font-size:10px;font-weight:700;
  text-transform:uppercase;letter-spacing:.6px;color:#247a20;
}
.cm-hours-total strong{font-size:18px;color:#1c6618;}

/* ── Jour de congé (day off) ── */
.cm-conge-sec{padding-top:4px !important;padding-bottom:14px;}
.cm-conge-toggle{
  display:inline-flex;align-items:center;gap:11px;cursor:pointer;user-select:none;
}
.cm-conge-toggle input{position:absolute;opacity:0;width:0;height:0;}
.cm-conge-switch{
  position:relative;width:44px;height:25px;flex-shrink:0;
  background:#d3dce6;border-radius:13px;transition:background .2s;
}
.cm-conge-switch::after{
  content:'';position:absolute;top:3px;left:3px;
  width:19px;height:19px;border-radius:50%;background:#fff;
  box-shadow:0 1px 3px rgba(0,0,0,.25);transition:transform .2s;
}
.cm-conge-toggle input:checked + .cm-conge-switch{background:#7c5cff;}
.cm-conge-toggle input:checked + .cm-conge-switch::after{transform:translateX(19px);}
.cm-conge-toggle input:focus-visible + .cm-conge-switch{outline:2px solid var(--lime-500);outline-offset:2px;}
.cm-conge-text{font-size:14px;font-weight:700;color:var(--navy);display:inline-flex;align-items:center;gap:6px;}
.cm-conge-text span{font-size:16px;}
.cm-conge-sec.on .cm-conge-text{color:#6a45e6;}
.cm-conge-detail{margin-top:11px;}
.cm-conge-detail input{
  width:100%;box-sizing:border-box;
  padding:9px 11px;font-size:14px;
  border:1px solid var(--border);border-radius:9px;font-family:inherit;
}
.cm-conge-detail input:focus{
  outline:none;border-color:#7c5cff;
  box-shadow:0 0 0 3px rgba(124,92,255,.16);
}
/* Heures grisées un jour de congé (toujours modifiables si demi-journée) */
.cm-dim{opacity:.5;transition:opacity .2s;}
.cm-dim:hover,.cm-dim:focus-within{opacity:1;}

/* Listes (events / tâches / docs) */
.cm-list{display:flex;flex-direction:column;gap:6px;margin-bottom:8px;}
.cm-item{
  display:flex;align-items:center;gap:9px;
  background:#f7f9fc;border:1px solid #e7eef6;border-radius:9px;
  padding:8px 10px;font-size:13.5px;
}
.cm-item-time{
  font-weight:800;color:var(--navy);font-size:12.5px;
  min-width:46px;flex-shrink:0;font-variant-numeric:tabular-nums;
}
.cm-item-txt{flex:1;color:var(--text,#1d2a36);text-align:left;word-break:break-word;}
.cm-item-del{
  flex-shrink:0;border:none;background:none;cursor:pointer;
  width:24px;height:24px;border-radius:6px;
  font-size:18px;line-height:1;color:var(--muted);
  display:flex;align-items:center;justify-content:center;transition:all .14s;
}
.cm-item-del:hover{background:#fdecea;color:var(--danger,#cc2200);}

/* Tâches */
.cm-check{
  flex-shrink:0;width:22px;height:22px;border-radius:6px;
  border:2px solid var(--border);background:#fff;cursor:pointer;
  display:flex;align-items:center;justify-content:center;
  font-size:13px;font-weight:800;color:#fff;transition:all .14s;
}
.cm-check.on{background:var(--lime-600,#3aaa35);border-color:var(--lime-600,#3aaa35);}
.cm-task.done .cm-item-txt{text-decoration:line-through;color:var(--muted);}

/* Documents */
.cm-doc-ico{flex-shrink:0;font-size:16px;}
.cm-doc-link{
  border:none;background:none;cursor:pointer;font-family:inherit;
  font-size:13.5px;color:var(--navy);font-weight:600;text-decoration:underline;
  text-decoration-color:rgba(0,51,102,.3);
}
.cm-doc-link:hover{text-decoration-color:var(--navy);}
.cm-doc-size{flex-shrink:0;font-size:11px;color:var(--muted);font-variant-numeric:tabular-nums;}

/* Ligne d'ajout */
.cm-add-row{display:flex;gap:8px;align-items:center;}
.cm-add-row input[type="text"],.cm-add-row input[type="time"]{
  flex:1;min-width:0;box-sizing:border-box;
  padding:9px 11px;font-size:14px;
  border:1px solid var(--border);border-radius:9px;font-family:inherit;
}
.cm-add-row input:focus{
  outline:none;border-color:var(--navy-500);
  box-shadow:0 0 0 3px rgba(26,107,176,.14);
}
.cm-add-btn{flex-shrink:0;padding:9px 16px;font-size:13px;white-space:nowrap;}

/* Notes */
.cm-notes{
  width:100%;box-sizing:border-box;
  padding:11px 12px;font-size:14px;line-height:1.5;
  border:1px solid var(--border);border-radius:10px;
  font-family:inherit;resize:vertical;min-height:80px;
}
.cm-notes:focus{
  outline:none;border-color:var(--navy-500);
  box-shadow:0 0 0 3px rgba(26,107,176,.14);
}
.cm-notes-status{
  font-size:11.5px;color:var(--lime-600,#3aaa35);font-weight:600;
  margin-top:5px;min-height:16px;
}

.cm-empty{
  font-size:12.5px;color:var(--muted);font-style:italic;
  padding:6px 2px;
}

/* Pied du modal */
.cm-day-foot{
  display:flex;gap:10px;justify-content:space-between;align-items:center;
  padding-top:14px;margin-top:4px;border-top:1px solid var(--border);
}
.cm-day-foot .btn-primary{min-width:110px;}

/* ── Mobile ────────────────────────────────────────────────────── */
@media(max-width:768px){
  .cm-cal-dow,.cm-cal-grid{grid-template-columns:repeat(7,1fr) 38px;}
  .cm-week-tot{padding:2px;}
  .cm-week-tot strong{font-size:10px;}
  .cm-week-sup{display:none;}
  .cm-dow-tot{font-size:9px;}
  .cm-cell{min-height:74px;padding:4px 4px;}
  .cm-cell-num{font-size:12px;width:22px;height:22px;}
  .cm-cell-today .cm-cell-num{width:22px;height:22px;}
  .cm-dot{font-size:9px;padding:1px 4px;}
  /* sur très petit écran, on masque le texte des pastilles pour ne garder qu'un point */
  .cm-cal-title{min-width:0;font-size:15px;}
  .cm-cal-today{font-size:11px;padding:6px 10px;}

  #cmDayModal .modal-card{max-height:94vh !important;}
  .cm-day-body{padding-right:0;margin-right:0;}
  .cm-hours-grid{grid-template-columns:1fr 1fr;gap:9px;}
  .cm-hours-total{grid-column:1 / -1;}
  .cm-hours-grid input,.cm-add-row input,.cm-notes{font-size:16px !important;}
  .cm-add-row{flex-wrap:wrap;}
  .cm-add-row input[type="time"]{max-width:none !important;flex:1 1 100%;}
  .cm-add-btn{flex:1 1 100%;min-height:44px;}
  .cm-day-foot .btn-outline,.cm-day-foot .btn-primary{flex:1;min-height:44px;}
}

/* Très petit écran : pastilles compactes (juste les compteurs courts) */
@media(max-width:480px){
  .cm-dot-h::after,.cm-dot-ev::after,.cm-dot-tk::after{content:'';}
  .cm-cell-tags{gap:2px;}
}
