/* ============================================================
   Planning Bijouterie — design sobre, élégant
   Palette : ivoire / noir / or
   ============================================================ */

:root {
  --ivory:        #faf7f2;
  --paper:        #ffffff;
  --ink:          #1a1814;
  --ink-soft:     #4a463f;
  --muted:        #8a8479;
  --line:         #e6dfd2;
  --line-soft:    #f0ebe1;
  --gold:         #d28361;
  --gold-soft:    #f5e3d4;
  --gold-deep:    #a05a3c;
  --rest:         #ece8df;
  --school:       #d8e3e8;
  --leave:        #f0d8d8;

  --radius:       6px;
  --radius-lg:    10px;
  --shadow-sm:    0 1px 2px rgba(26, 24, 20, 0.04);
  --shadow:       0 4px 16px rgba(26, 24, 20, 0.08);
  --shadow-lg:    0 20px 50px rgba(26, 24, 20, 0.18);

  --font-serif:   'Cormorant Garamond', 'Garamond', Georgia, serif;
  --font-sans:    'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  background: var(--ivory);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; cursor: pointer; }
input, select { font-family: inherit; font-size: inherit; color: inherit; }

/* ===================== BACKUP BANNER ===================== */
.backup-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 24px;
  background: linear-gradient(90deg, var(--gold-soft), #fdf3e7);
  border-bottom: 1px solid var(--gold);
  font-size: 13px;
  color: var(--ink);
}
.backup-banner[hidden] { display: none; }
.backup-banner-text strong {
  color: var(--gold-deep);
  margin-right: 4px;
}
.backup-banner-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* ===================== TOPBAR ===================== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 40px;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 18px;
}

.brand-logo {
  height: 56px;
  width: auto;
  display: block;
}

.brand-divider {
  display: block;
  width: 1px;
  height: 36px;
  background: var(--line);
}

.brand-tagline {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.22em;
  font-weight: 500;
}

.topbar-actions {
  display: flex;
  gap: 8px;
}

/* ===================== BUTTONS ===================== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.01em;
  transition: all 0.15s ease;
}

.btn:hover { border-color: var(--ink); background: var(--paper); }
.btn:active { transform: translateY(1px); }

.btn-primary {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}
.btn-primary:hover { background: var(--gold-deep); border-color: var(--gold-deep); }

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--ink-soft);
}
.btn-ghost:hover { background: var(--line-soft); border-color: var(--line); color: var(--ink); }

.btn-sm { padding: 6px 12px; font-size: 12px; }

.icon-btn {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink-soft);
  border-radius: var(--radius);
  font-size: 18px;
  line-height: 1;
  transition: all 0.15s ease;
}
.icon-btn:hover { border-color: var(--ink); color: var(--ink); }

/* ===================== WEEKBAR ===================== */
.weekbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 40px;
  background: var(--ivory);
  border-bottom: 1px solid var(--line-soft);
}

.weekbar-left { display: flex; align-items: center; gap: 12px; }
.weekbar-right { display: flex; align-items: center; gap: 12px; }

.week-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 200px;
  padding: 0 8px;
}
.week-label strong {
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 600;
}
.week-label .muted { font-size: 12px; }

.badge {
  display: inline-flex;
  align-items: center;
  padding: 5px 11px;
  background: var(--gold-soft);
  color: var(--gold-deep);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.muted { color: var(--muted); }
.small { font-size: 12px; }

/* ===================== PLANNING GRID ===================== */
.planning {
  padding: 32px 40px;
  max-width: 1600px;
  margin: 0 auto;
}

.plan-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.plan-print-header {
  display: none;
  padding: 18px 24px;
  border-bottom: 1px solid var(--line);
}

.plan-grid {
  display: grid;
  grid-template-columns: 200px repeat(6, 1fr);
}

.plan-cell {
  border-right: 1px solid var(--line-soft);
  border-bottom: 1px solid var(--line-soft);
  position: relative;
}
.plan-cell:nth-child(7n) { border-right: 0; }

/* En-tête colonnes (jours) */
.plan-head {
  background: var(--ivory);
  padding: 14px 12px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 2;
}
.plan-head.corner { background: var(--paper); border-right: 1px solid var(--line); }

.day-name {
  font-family: var(--font-serif);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.01em;
}
.day-date {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-top: 3px;
}

/* Cellule employé (1ère colonne) */
.emp-cell {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--ivory);
  border-right: 1px solid var(--line);
  min-height: 92px;
}

.emp-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--paper);
  font-family: var(--font-serif);
  font-size: 17px;
  font-weight: 600;
  flex-shrink: 0;
}

.emp-info { display: flex; flex-direction: column; min-width: 0; }
.emp-name {
  font-weight: 600;
  font-size: 14px;
  letter-spacing: 0.01em;
}
.emp-role {
  font-size: 10.5px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin-top: 2px;
}
.emp-hours {
  font-size: 11px;
  color: var(--gold-deep);
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}

/* Cellule créneau journalier */
.day-cell {
  padding: 10px 8px;
  min-height: 92px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
}

.slot {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 9px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent, var(--gold));
  border-radius: 4px;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
}

.slot-time { color: var(--ink); font-weight: 500; }
.slot-dur { color: var(--muted); font-size: 10.5px; margin-left: auto; }

.tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  text-align: center;
  align-self: stretch;
}
.tag-rest    { background: var(--rest);   color: var(--muted); }
.tag-school  { background: var(--school); color: #4d6571; }
.tag-leave   { background: var(--leave);  color: #8b3a3a; }

/* Total horaire en bas du tableau */
.plan-foot {
  display: grid;
  grid-template-columns: 200px repeat(6, 1fr);
  background: var(--ivory);
  border-top: 1px solid var(--line);
}
.foot-label {
  padding: 12px 16px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--muted);
  border-right: 1px solid var(--line);
  font-weight: 600;
}
.foot-cell {
  padding: 12px 8px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  border-right: 1px solid var(--line-soft);
  font-size: 12px;
}
.foot-cell:last-child { border-right: 0; }
.foot-cell strong { font-weight: 600; color: var(--ink); }
.foot-cell .foot-detail { display: block; font-size: 10px; color: var(--muted); margin-top: 2px; }

/* ===================== FOOTER ===================== */
.footer {
  padding: 16px 40px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--line-soft);
  margin-top: 24px;
}

.legend {
  display: flex;
  gap: 20px;
}
.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}
.legend-swatch {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 3px;
}
.swatch-work   { background: var(--gold); }
.swatch-rest   { background: var(--rest); }
.swatch-school { background: var(--school); }
.swatch-leave  { background: var(--leave); }

/* ===================== MODALES ===================== */
.modal {
  border: none;
  padding: 0;
  background: transparent;
  max-width: 90vw;
  max-height: 90vh;
  margin: auto;
  inset: 0;
}
.modal::backdrop {
  background: rgba(26, 24, 20, 0.4);
  backdrop-filter: blur(4px);
}

.modal-card {
  background: var(--paper);
  border-radius: var(--radius-lg);
  width: min(640px, 90vw);
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--line);
}
.modal-header h2 {
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 600;
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.field-row {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 12px;
}
.field-row label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  font-weight: 600;
}
.field-row input,
.field-row select,
.modulation-grid select {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: var(--ink);
}
.field-row input:focus,
.field-row select:focus,
.modulation-grid select:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-soft);
}

.leaves-list h3 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 8px;
}
.leaves-list ul { list-style: none; }
.leaves-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line-soft);
}
.leaves-list li:last-child { border-bottom: 0; }

.leave-item-info { display: flex; align-items: center; gap: 10px; }
.leave-item-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.leave-item-rm {
  background: transparent;
  border: 0;
  color: var(--muted);
  font-size: 16px;
  padding: 4px 8px;
  border-radius: 3px;
}
.leave-item-rm:hover { color: #8b3a3a; background: var(--leave); }

.modulation-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.mod-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: var(--ivory);
  border-radius: var(--radius);
}
.mod-row .mod-name { display: flex; align-items: center; gap: 10px; font-weight: 500; }

.modal-actions { display: flex; justify-content: flex-end; gap: 10px; padding-top: 8px; }

/* ===================== DAY EDIT MODAL ===================== */
.day-cell {
  cursor: pointer;
  transition: background 0.12s ease;
}
.day-cell:hover {
  background: var(--line-soft);
}
.day-cell.is-edited {
  background: linear-gradient(135deg, var(--gold-soft) 0%, transparent 60%);
}
.day-cell.is-edited::before {
  content: '';
  position: absolute;
  top: 6px;
  right: 6px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--gold);
}

.day-edit-mode {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}
.day-edit-mode.no-school { grid-template-columns: 1fr 1fr; }
#day-edit-school-wrap.hidden { display: none; }

.radio-card {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 12px;
  border: 1px solid var(--line);
  background: var(--paper);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.15s ease;
}
.radio-card input { display: none; }
.radio-card:hover { border-color: var(--ink-soft); }
.radio-card:has(input:checked) {
  border-color: var(--gold);
  background: var(--gold-soft);
  color: var(--gold-deep);
  font-weight: 600;
}
.radio-label {
  font-size: 13px;
  letter-spacing: 0.01em;
}

.day-slots h3 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 8px;
}
#slots-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 8px;
}
.slot-row {
  display: grid;
  grid-template-columns: auto 1fr auto 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--ivory);
  border-radius: var(--radius);
}
.slot-row label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 600;
}
.slot-row input {
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  font-variant-numeric: tabular-nums;
  width: 100%;
}
.slot-row input:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-soft);
}
.slot-rm {
  background: transparent;
  border: 0;
  color: var(--muted);
  font-size: 18px;
  padding: 4px 8px;
  border-radius: 3px;
}
.slot-rm:hover { color: #8b3a3a; background: var(--leave); }

.day-slots.hidden { display: none; }

/* ===================== SEG TOGGLE ===================== */
.seg-toggle {
  display: inline-flex;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 2px;
}
.seg-btn {
  padding: 6px 14px;
  border: 0;
  background: transparent;
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.02em;
  border-radius: 4px;
  transition: all 0.15s ease;
}
.seg-btn:hover { color: var(--ink); }
.seg-btn.is-active {
  background: var(--ink);
  color: var(--paper);
}

/* ===================== MENU POP ===================== */
.menu-wrap {
  position: relative;
}
.menu-trigger {
  list-style: none;
  cursor: pointer;
  padding: 9px 14px !important;
  font-size: 18px;
  line-height: 1;
}
.menu-trigger::-webkit-details-marker { display: none; }
.menu-pop {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  min-width: 240px;
  padding: 6px;
  z-index: 100;
  display: flex;
  flex-direction: column;
}
.menu-pop hr {
  border: 0;
  border-top: 1px solid var(--line-soft);
  margin: 4px 0;
}
.menu-item {
  text-align: left;
  padding: 8px 10px;
  background: transparent;
  border: 0;
  border-radius: 4px;
  font-size: 13px;
  color: var(--ink);
  transition: background 0.12s ease;
}
.menu-item:hover { background: var(--line-soft); }

/* ===================== NOTES & ACTUALS ===================== */
.day-edit-section {
  border-top: 1px solid var(--line-soft);
  padding-top: 14px;
}
.day-edit-section h3 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 8px;
}
#day-note {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  font-family: inherit;
  font-size: 13px;
  resize: vertical;
}
#day-note:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-soft);
}

.actuals-block summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
}
.actuals-block summary::-webkit-details-marker { display: none; }
.actuals-block summary::before {
  content: '▸';
  color: var(--muted);
  font-size: 11px;
  transition: transform 0.15s ease;
}
.actuals-block[open] summary::before { transform: rotate(90deg); }

.actuals-modes {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 12px 0 10px;
}

/* Note dans cellule */
.cell-note {
  display: flex;
  align-items: flex-start;
  gap: 5px;
  margin-top: 4px;
  padding: 4px 6px;
  background: var(--ivory);
  border-left: 2px solid var(--gold);
  border-radius: 2px;
  font-size: 10.5px;
  color: var(--ink-soft);
  line-height: 1.35;
  font-style: italic;
}
.cell-note-icon {
  flex-shrink: 0;
  color: var(--gold-deep);
  font-size: 9px;
  margin-top: 2px;
}

/* ===================== ALERTS SOLO ===================== */
.day-cell.is-solo::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, transparent, #e09f5a, transparent);
}
.foot-cell.is-solo strong { color: #c87b3a; }
.foot-cell.is-solo::after {
  content: ' ⚠';
  color: #c87b3a;
}

/* ===================== ACTUAL DISPLAY ===================== */
.cell-actual {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 9px;
  background: #fff8ee;
  border: 1px solid var(--gold-soft);
  border-left: 3px solid var(--gold-deep);
  border-radius: 4px;
  font-size: 12px;
}
.cell-actual-flag {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--gold-deep);
  font-weight: 600;
}
.tag-absent { background: #f0d8d8; color: #8b3a3a; }

.actual-not-set {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border: 1px dashed var(--line);
  border-radius: 4px;
  color: var(--muted);
  font-size: 11px;
  text-align: center;
  font-style: italic;
}

/* ===================== MONTHLY MODAL ===================== */
.modal-card-lg { width: min(960px, 95vw); }

.month-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-bottom: 16px;
}
.month-nav strong {
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 600;
  min-width: 220px;
  text-align: center;
  text-transform: capitalize;
}

.month-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.month-table th, .month-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--line-soft);
}
.month-table thead th {
  background: var(--ivory);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  font-weight: 600;
}
.month-table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.month-table .delta-pos { color: #2d7a4e; font-weight: 600; }
.month-table .delta-neg { color: #b54a4a; font-weight: 600; }
.month-table .row-total {
  border-top: 2px solid var(--ink);
  font-weight: 600;
  background: var(--ivory);
}
.month-emp-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 8px;
  vertical-align: middle;
}

/* ===================== ALERTS ===================== */
.alert {
  padding: 12px 16px;
  background: var(--leave);
  color: #8b3a3a;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
}

/* ===================== PRINT ===================== */
@media print {
  @page { size: A4 landscape; margin: 12mm; }

  html, body { background: var(--paper); }
  .no-print { display: none !important; }
  .planning { padding: 0; max-width: none; }
  .plan-card { border: 1px solid var(--ink); box-shadow: none; }

  .plan-print-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--paper);
  }
  .plan-print-header h2 {
    font-family: var(--font-serif);
    font-size: 20px;
    font-weight: 600;
  }
  .plan-print-header .print-week {
    font-size: 12px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.16em;
  }

  .plan-grid, .plan-foot { grid-template-columns: 140px repeat(6, 1fr); }
  .emp-cell { min-height: 70px; padding: 8px 10px; }
  .emp-avatar { width: 28px; height: 28px; font-size: 14px; }
  .day-cell { min-height: 70px; padding: 6px 4px; }
  .slot { padding: 3px 6px; font-size: 10.5px; }
  .day-name { font-size: 14px; }
}

/* ===================== RESPONSIVE ===================== */
@media (max-width: 980px) {
  .topbar { padding: 16px 20px; flex-wrap: wrap; gap: 12px; }
  .weekbar { padding: 12px 20px; flex-wrap: wrap; gap: 10px; }
  .planning { padding: 16px; }
  .plan-grid, .plan-foot { grid-template-columns: 130px repeat(6, minmax(110px, 1fr)); }
  .plan-card { overflow-x: auto; }
  .footer { padding: 12px 20px 24px; flex-direction: column; gap: 12px; align-items: flex-start; }
}
