/* repartiment.css — Estils de la pàgina "Repartiment de continguts".
 * Migrat des de m-main/repartiment.html. Depèn de tokens.css per a les
 * variables compartides (--navy, --blue, --line, etc.); aquí només
 * s'afegeix la paleta de sentits i els estils propis de la pàgina. */

:root {
  /* sentit palette */
  --s-comprensio:   #506080; --s-comprensio-bg: #ecf0f7; --s-comprensio-bd: #b0bfcf;
  --s-numeric:      #1a6fa8; --s-numeric-bg:    #e8f2fb; --s-numeric-bd:    #8bbfe0;
  --s-espacial:     #1a8a5c; --s-espacial-bg:   #e5f5ed; --s-espacial-bd:   #80ccaa;
  --s-mesura:       #b56010; --s-mesura-bg:     #fdf3e5; --s-mesura-bd:     #e0aa60;
  --s-algebraic:    #6b3fa0; --s-algebraic-bg:  #f2ecfb; --s-algebraic-bd:  #b090d8;
  --s-estocastic:   #a02848; --s-estocastic-bg: #fde8ef; --s-estocastic-bd: #d888a8;
}

/* ── Shell ─────────────────────────────────────────────────────────── */
.app { min-height: 100dvh; display: flex; flex-direction: column; }

/* ── Topbar ────────────────────────────────────────────────────────── */
.topbar {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 10px;
  padding: 0 16px; height: 52px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  z-index: 30;
}
.pill-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 13px; border-radius: 20px;
  border: 1px solid var(--line); font-size: 14.3px; font-weight: 600;
  color: var(--muted); background: var(--card); transition: .12s;
  white-space: nowrap; text-decoration: none;
}
.pill-btn:hover { border-color: var(--navy); color: var(--navy); text-decoration: none; }
.pill-btn svg { width: 13px; height: 13px; flex-shrink: 0; }
.pill-btn.accent { border-color: var(--blue); color: var(--blue); }
.pill-btn.accent:hover { background: var(--blue); color: #fff; }
.brand { font-size: 16.5px; font-weight: 800; color: var(--navy); flex: 1;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand small { font-weight: 400; color: var(--muted); font-size: 13.2px; margin-left: 6px; }
/* ── Tabs bar ──────────────────────────────────────────────────────── */
.tabs-bar {
  flex: 0 0 auto;
  display: flex; gap: 0;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  padding: 0 12px;
  overflow-x: auto;
}
.tabs-bar::-webkit-scrollbar { height: 0; }
.ctab {
  padding: 11px 18px;
  font-size: 14.85px; font-weight: 600;
  color: var(--muted);
  border-bottom: 2.5px solid transparent;
  cursor: pointer; transition: .12s; white-space: nowrap;
  user-select: none;
}
.ctab:hover { color: var(--navy); }
.ctab.active { color: var(--navy); border-bottom-color: var(--navy); }
.ctab .h-badge {
  font-size: 12.1px; font-weight: 400; color: var(--hint);
  margin-left: 4px;
}

/* ── Main ──────────────────────────────────────────────────────────── */
.main { flex: 1 1 auto; overflow-y: auto; }
.cview { display: none; max-width: 860px; margin: 0 auto; padding: 22px 20px 60px; }
.cview.active { display: block; }

.cview-header {
  display: flex; align-items: baseline; gap: 12px;
  margin-bottom: 20px; padding-bottom: 14px;
  border-bottom: 2px solid var(--line);
}
.cview-header h2 { font-size: 23.1px; color: var(--navy); }
.cview-header .meta { font-size: 13.75px; color: var(--muted); }

/* ── Sentit section ────────────────────────────────────────────────── */
.s-section {
  margin-bottom: 10px;
  border-radius: 10px; overflow: hidden;
  border: 1px solid var(--line);
}
.s-header {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; cursor: pointer; user-select: none;
  transition: filter .1s;
}
.s-header:hover { filter: brightness(.97); }
.s-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.s-label { font-size: 12.65px; text-transform: uppercase; letter-spacing: .07em; font-weight: 800; flex: 1; }
.s-hores { font-size: 13.2px; font-weight: 700; opacity: .7; }
.s-chevron { font-size: 11px; color: rgba(0,0,0,.35); transition: transform .15s; margin-left: 4px; }
.s-section.open .s-chevron { transform: rotate(90deg); }

.s-body { background: var(--card); display: none; }
.s-section.open .s-body { display: block; }

/* ── Tema table ─────────────────────────────────────────────────────── */
.tema-table { width: 100%; border-collapse: collapse; }
.tema-table colgroup col:first-child { width: auto; }
.tema-table colgroup col:last-child  { width: 56px; }

.tema-table thead th {
  text-align: left; font-size: 12.1px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .05em; color: var(--hint);
  padding: 7px 14px 5px; border-bottom: 1px solid var(--line);
}
.tema-table thead th:last-child { text-align: right; }
.tema-row td {
  padding: 9px 14px; border-bottom: 1px solid #eef1f4;
  vertical-align: top;
}
.tema-row:last-child td { border-bottom: none; }
.tema-row:hover td { background: #f6f8fb; }

.tema-toggle {
  display: flex; align-items: flex-start; gap: 8px;
  cursor: pointer; user-select: none;
}
.tema-caret {
  font-size: 9px; color: var(--hint); margin-top: 4px;
  flex-shrink: 0; transition: transform .12s;
}
.tema-toggle.open .tema-caret { transform: rotate(90deg); }
.tema-name { font-size: 15.4px; font-weight: 600; color: var(--ink); line-height: 1.35; }

.hores-td { font-size: 14.3px; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; padding-top: 10px; }

/* ── Continguts list ───────────────────────────────────────────────── */
.cont-list { display: none; margin-top: 8px; padding-left: 4px; }
.cont-list.open { display: block; }
.cont-list li {
  position: relative;
  font-size: 13.75px; color: var(--muted);
  padding: 2px 0 2px 22px; /* left gutter for bullet / icon */
  line-height: 1.4;
  list-style: none; display: flex; gap: 7px;
}
.cont-list li::before {
  content: '';
  position: absolute; left: 8px; top: 6px;
  width: 4px; height: 4px; border-radius: 50%;
  background: var(--hint);
}
.cont-list li.has-mat::before { display: none; }
.cont-num { color: var(--hint); font-size: 12.1px; flex-shrink: 0; margin-top: 1px; }

/* Icona "veure material al catàleg" a l'esquerra d'un contingut (injectada per JS) */
.cont-mat {
  position: absolute; left: 1px; top: 2px;
  display: inline-flex; align-items: center;
  flex-shrink: 0;
  color: var(--blue); text-decoration: none;
  border-radius: 5px; padding: 1px 2px;
  transition: background .12s, color .12s;
}
.cont-mat svg { width: 13px; height: 13px; display: block; }
.cont-mat:hover { background: var(--blue-bg); }

/* ── Sentit themes (header BG + dot color + border) ────────────────── */
.s-header.comprensio { background: var(--s-comprensio-bg); }
.s-header.comprensio .s-dot   { background: var(--s-comprensio); }
.s-header.comprensio .s-label { color: var(--s-comprensio); }
.s-section.comprensio { border-color: var(--s-comprensio-bd); }

.s-header.numeric    { background: var(--s-numeric-bg); }
.s-header.numeric    .s-dot   { background: var(--s-numeric); }
.s-header.numeric    .s-label { color: var(--s-numeric); }
.s-section.numeric   { border-color: var(--s-numeric-bd); }

.s-header.espacial   { background: var(--s-espacial-bg); }
.s-header.espacial   .s-dot   { background: var(--s-espacial); }
.s-header.espacial   .s-label { color: var(--s-espacial); }
.s-section.espacial  { border-color: var(--s-espacial-bd); }

.s-header.mesura     { background: var(--s-mesura-bg); }
.s-header.mesura     .s-dot   { background: var(--s-mesura); }
.s-header.mesura     .s-label { color: var(--s-mesura); }
.s-section.mesura    { border-color: var(--s-mesura-bd); }

.s-header.algebraic  { background: var(--s-algebraic-bg); }
.s-header.algebraic  .s-dot   { background: var(--s-algebraic); }
.s-header.algebraic  .s-label { color: var(--s-algebraic); }
.s-section.algebraic { border-color: var(--s-algebraic-bd); }

.s-header.estocastic { background: var(--s-estocastic-bg); }
.s-header.estocastic .s-dot   { background: var(--s-estocastic); }
.s-header.estocastic .s-label { color: var(--s-estocastic); }
.s-section.estocastic{ border-color: var(--s-estocastic-bd); }

/* ── Print ───────────────────────────────────────────────────────────── */
@media print {
  .topbar, .tabs-bar, .pill-btn { display: none !important; }
  .cview { padding: 0; }
  .s-body { display: block !important; }
  .cont-list { display: block !important; }
  .s-section { break-inside: avoid; margin-bottom: 16px; }
}

/* ── Responsive ─────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .brand small { display: none; }
  .cview { padding: 14px 12px 50px; }
}

/* ── MODE EDICIÓ ─────────────────────────────────────────────────────── */
.edit-banner {
  flex: 0 0 auto;
  display: none; align-items: center; gap: 10px;
  padding: 8px 16px; font-size: 14px; font-weight: 600; color: #7a6010;
  background: #fff8e0; border-bottom: 2px solid #e8c840;
}
body.is-editing .edit-banner { display: flex; }
.edit-banner-note { font-weight: 400; font-size: 13px; color: #a07820; }
/* show/hide topbar buttons by mode */
.pill-btn.edit-stop,
.pill-btn.edit-dl { display: none; }
body.is-editing .pill-btn.edit-start { display: none; }
body.is-editing .pill-btn.edit-stop  { display: inline-flex; border-color: #c0392b; color: #c0392b; }
body.is-editing .pill-btn.edit-stop:hover { background: #c0392b; color: #fff; border-color: #c0392b; }
body.is-editing .pill-btn.edit-dl    { display: inline-flex; background: var(--blue-bg); border-color: var(--blue); color: var(--blue); }
body.is-editing .pill-btn.edit-dl:hover { background: var(--blue); color: #fff; }
/* edit text inputs */
.edit-tema-head {
  display: flex; align-items: center; gap: 8px; width: 100%; cursor: default;
}
.tema-label-inp {
  flex: 1; min-width: 60px; padding: 2px 4px; font-family: inherit;
  font-size: 15.4px; font-weight: 600; color: var(--ink);
  border: none; border-bottom: 1.5px solid var(--blue); background: transparent;
}
.tema-label-inp:focus { outline: none; border-bottom-color: var(--navy); }
.cont-inp {
  flex: 1; min-width: 0; padding: 3px 7px; font-family: inherit;
  font-size: 13.75px; color: var(--ink);
  border: 1px solid var(--line); border-radius: 4px; background: #fff;
}
.cont-inp:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 2px rgba(46,117,182,.15); }
.hores-inp {
  width: 46px; padding: 2px 5px; text-align: right; font-family: inherit;
  font-size: 13.5px; color: var(--muted);
  border: 1px solid var(--line); border-radius: 4px; background: #fff;
}
.hores-inp:focus { outline: none; border-color: var(--blue); }
/* action buttons */
.edit-mini-btns { display: flex; gap: 3px; flex-shrink: 0; }
.edit-mini-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; padding: 0; border-radius: 5px; flex-shrink: 0;
  font-size: 11px; color: var(--muted); border: 1px solid var(--line); background: var(--card);
  cursor: pointer; transition: .1s; font-family: inherit;
}
.edit-mini-btn:hover:not([disabled]) { border-color: var(--blue); color: var(--blue); background: var(--blue-bg); }
.edit-mini-btn.del:hover:not([disabled]) { border-color: #c0392b; color: #c0392b; background: #fde8ef; }
.edit-mini-btn.move:hover:not([disabled]) { border-color: #b56010; color: #b56010; background: #fdf3e5; }
.edit-mini-btn[disabled] { opacity: .3; cursor: default; }
.edit-add-btn {
  display: inline-flex; align-items: center; gap: 5px; margin-top: 7px;
  padding: 4px 12px; border-radius: 6px; font-size: 13px; font-weight: 600;
  color: var(--blue); border: 1.5px dashed #8bbfe0;
  background: transparent; cursor: pointer; transition: .12s; font-family: inherit;
}
.edit-add-btn:hover { background: var(--blue-bg); }
.edit-cont-row {
  display: flex; align-items: center; gap: 6px; width: 100%; padding: 2px 0;
}
/* move modal */
.move-modal-bg {
  position: fixed; inset: 0; background: rgba(0,0,0,.35);
  display: flex; align-items: center; justify-content: center; z-index: 200;
}
.move-modal-bg[hidden] { display: none; }
.move-modal {
  background: #fff; border-radius: 14px; padding: 22px 26px;
  min-width: 300px; max-width: 90vw; box-shadow: 0 12px 40px rgba(0,0,0,.18);
}
.move-modal h3 { font-size: 16px; color: var(--navy); margin-bottom: 4px; }
.move-modal .move-sub { font-size: 13px; color: var(--muted); margin-bottom: 16px; }
.move-modal label { display: block; font-size: 13px; color: var(--muted); font-weight: 600; margin: 12px 0 5px; }
.move-modal select {
  width: 100%; padding: 7px 10px; border: 1px solid var(--line);
  border-radius: 7px; font: inherit; font-size: 14.5px; background: #fff; color: var(--ink);
}
.move-modal select:focus { outline: none; border-color: var(--blue); }
.move-modal-btns { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; }
@media print {
  .edit-banner, .pill-btn.edit-start, .pill-btn.edit-stop, .pill-btn.edit-dl { display: none !important; }
}
