/* ============================================================
   panell-mobil.css — shell mòbil del panell portfoli.
   ============================================================
   Estructura tipus Kefem/Stradeka: barra superior amb el nom
   "Panell" + selector de projecte, barra inferior amb 5 seccions
   (marca central "P" = Vitals). Reaprofita les mateixes renderXxx
   del layout desktop (panell.js) i el mateix ui.project.

   S'activa quan body té la classe .pm-actiu, que la posa
   js/panell-mobil.js (viewport <768px o ?mobil=1). En aquest mode,
   el layout desktop original (topbar/projects/tabs/content) queda
   amagat. */

/* ---- Amagar el layout desktop quan el shell mòbil és actiu ---- */
body.pm-actiu #topbar,
body.pm-actiu #projects,
body.pm-actiu #tabs,
body.pm-actiu #progress-bar,
body.pm-actiu #content { display: none !important; }

/* ---- Mostrar el shell mòbil només quan és actiu ---- */
#pmShell { display: none; }
body.pm-actiu #pmShell { display: block; }

:root {
  --pm-nav-h: 58px; /* mateixa alçada que la BottomNav de Kefem (decisió usuari) */
  /* Sostre de 34px: iOS nou pot inflar env() fins a ~78pt en PWA instal·lada
     i la barra quedaria penjada a mitja pantalla (lliçó Block Cursor 07-31). */
  --pm-safe-bottom: min(env(safe-area-inset-bottom, 0px), 34px);
}

/* ---- Barra superior ---- */
.pm-bar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  height: 54px;
  padding: 0 0.75rem;
  /* Amb viewport-fit=cover el contingut passa per sota de la barra d'estat
     d'iOS: la barra superior es fa càrrec del seu safe-area (content-box
     perquè els 54px continuïn sent l'alçada útil). */
  padding-top: env(safe-area-inset-top, 0px);
  box-sizing: content-box;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.pm-bar__brand {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--ink);
  text-decoration: none;
  flex-shrink: 0;
}
.pm-bar__brand b { color: var(--accent); }

.pm-bar__select {
  flex: 1;
  min-width: 0;
  height: 36px;
  padding: 0 2rem 0 0.7rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--ink);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2378716c' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 0.5rem center;
}
.pm-bar__select:focus { outline: none; box-shadow: var(--ring); }

.pm-bar__btn {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--ink);
  cursor: pointer;
}
.pm-bar__btn:hover { background: var(--surface-3); }
.pm-bar__btn[hidden] { display: none !important; }

/* El botó d'instal·lar la PWA es pinta amb l'accent (destacat) i només
   apareix quan el navegador ha llançat beforeinstallprompt (Android
   Chrome / Edge). A iOS Safari ni tan sols existeix; allà l'usuari ha
   d'afegir-la manualment des del menú "Compartir". */
.pm-bar__btn--install {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.pm-bar__btn--install:hover { background: var(--accent-strong); border-color: var(--accent-strong); }

/* ---- Contingut ---- */
.pm-main {
  max-width: 960px;
  margin: 0 auto;
  padding: 1rem 0.9rem calc(var(--pm-nav-h) + var(--pm-safe-bottom) + 1.25rem);
}

.pm-sec { display: none; }
.pm-sec--actiu { display: block; animation: pmFade 0.18s ease; }
@keyframes pmFade { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .pm-sec--actiu { animation: none; } }

/* Banner informatiu (p.ex. costs agregats amb filtre actiu) */
.pm-banner {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.7rem 0.85rem;
  margin: 0 0 1rem;
  background: var(--accent-soft);
  color: var(--ink);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  font-size: 0.85rem;
  line-height: 1.4;
}
.pm-banner__ic { flex-shrink: 0; color: var(--accent-strong); margin-top: 1px; }
.pm-banner__ic svg { width: 18px; height: 18px; display: block; }
[data-theme="dark"] .pm-banner { background: color-mix(in oklab, var(--accent-soft) 40%, var(--surface-2)); }

/* Buit / error / carregant dins d'una secció */
.pm-buit {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--muted);
  font-size: 0.9rem;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}

/* Llista de documents */
.pm-docs { display: flex; flex-direction: column; gap: 0.6rem; }
.pm-doc {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  text-decoration: none;
  color: var(--ink);
  transition: border-color 0.15s, transform 0.15s;
}
.pm-doc:hover { border-color: var(--accent); transform: translateY(-1px); text-decoration: none; }
.pm-doc__ic {
  flex-shrink: 0;
  display: inline-flex;
  color: var(--accent);
}
.pm-doc__ic svg { width: 22px; height: 22px; display: block; }
.pm-doc__txt { display: flex; flex-direction: column; gap: 0.15rem; min-width: 0; flex: 1; }
.pm-doc__tit { font-weight: 700; font-size: 0.95rem; color: var(--ink); }
.pm-doc__desc { font-size: 0.78rem; color: var(--muted); line-height: 1.4; }
.pm-doc__proj {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.72rem;
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
}
.pm-doc__dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
}

/* ---- Barra inferior (fixa) ---- */
.pm-nav {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 100;
  display: flex;
  align-items: stretch;
  justify-content: space-around;
  height: calc(var(--pm-nav-h) + var(--pm-safe-bottom));
  padding-bottom: var(--pm-safe-bottom);
  background: var(--surface);
  border-top: 1px solid var(--line);
  box-shadow: 0 -4px 12px rgba(28, 25, 23, 0.05);
}
[data-theme="dark"] .pm-nav { box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.35); }

.pm-nav__ind {
  position: absolute;
  left: 0; top: 0;
  height: 2.5px;
  width: 20%;
  background: var(--accent);
  border-radius: 0 0 4px 4px;
  transition: translate 0.2s ease;
}
@media (prefers-reduced-motion: reduce) { .pm-nav__ind { transition: none; } }

.pm-nav__item {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding-top: 5px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  background: none;
  border: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: scale 0.12s ease;
}
.pm-nav__item:active { scale: 0.92; }
.pm-nav__item.pm-nav__actiu { color: var(--accent); }
/* Icones a 29px com la BottomNav de Kefem (abans 22px: la barra es veia
   més buida tot i tenir la mateixa alçada de caixa, 58px). */
.pm-nav__item svg { width: 29px; height: 29px; display: block; }
.pm-nav__brand {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 32px;
  font-size: 2.3rem; /* com la «P» de la BottomNav de Kefem */
  font-weight: 800;
  font-style: italic;
  line-height: 1;
  color: var(--accent);
}

/* ---- Visor de documents (overlay) ---- */
#pmDocViewer {
  position: fixed;
  inset: 0;
  z-index: 300; /* per damunt de pm-bar/pm-nav (100) i del banner pwa (200) */
  display: flex;
  flex-direction: column;
  background: var(--bg);
}
.pm-visor__bar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  height: 52px;
  padding: 0 0.75rem;
  padding-top: env(safe-area-inset-top, 0px);
  box-sizing: content-box;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.pm-visor__back {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  height: 36px;
  padding: 0 0.8rem 0 0.55rem;
  border: 0;
  border-radius: var(--radius-full);
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
}
.pm-visor__back:hover { background: var(--accent-strong); }
.pm-visor__tit {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--ink);
}
.pm-visor__frame {
  flex: 1;
  width: 100%;
  border: 0;
  background: #fff;
}

/* ---- Ajustos de les seccions reaprofitades ---- */
/* Les renderXxx del panell.js estan pensades per l'ample desktop; a
   mòbil hem d'assegurar que graelles/taules no forcin scroll horitzontal
   del document. Contenidor amb overflow-x propi per taules amples. */
.pm-sec .au-table,
.pm-sec .campaigns-head,
.pm-sec .alerts-list,
.pm-sec .vitals-controls { max-width: 100%; }

.pm-sec .au-table {
  display: block;
  overflow-x: auto;
  white-space: nowrap;
  -webkit-overflow-scrolling: touch;
}
.pm-sec .au-table thead,
.pm-sec .au-table tbody,
.pm-sec .au-table tr { display: table; width: 100%; table-layout: fixed; }
.pm-sec .au-table th,
.pm-sec .au-table td {
  white-space: normal;
  word-break: break-word;
  font-size: 0.8rem;
}

.pm-sec .vitals-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.pm-sec .vitals-segmented { flex-wrap: wrap; }

/* Títol i lead de cada secció (per si les render internes no en tenen) */
.pm-sec__head { margin: 0 0 1rem; }
.pm-sec__title {
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  margin: 0 0 0.2rem;
  color: var(--ink);
}
.pm-sec__lead {
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.5;
  margin: 0;
  max-width: 40rem;
}
