/* ==========================================================================
   Portal Prohabits — sistema de disseny
   Manual d'identitat: Pantone 353C #7EDFA6 · Process Black #1E1E1E
   Tipografia digital corporativa: Montserrat (fallback Arial)
   ========================================================================== */

@font-face {
  font-family: "Montserrat";
  src: url("/static/fonts/montserrat-latin-400-normal.woff2") format("woff2");
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Montserrat";
  src: url("/static/fonts/montserrat-latin-500-normal.woff2") format("woff2");
  font-weight: 500; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Montserrat";
  src: url("/static/fonts/montserrat-latin-600-normal.woff2") format("woff2");
  font-weight: 600; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Montserrat";
  src: url("/static/fonts/montserrat-latin-700-normal.woff2") format("woff2");
  font-weight: 700; font-style: normal; font-display: swap;
}

:root {
  /* Colors corporatius */
  --green: #7EDFA6;          /* Pantone 353 C */
  --green-80: #98E5B8;
  --green-60: #B2ECCA;
  --green-40: #CBF2DB;
  --green-20: #E5F9ED;
  --green-dark: #56C489;     /* estat hover/actiu del verd */
  --green-deep: #2E7D53;     /* text sobre fons verd clar */
  --ink: #1E1E1E;            /* Pantone Process Black */
  --ink-80: #4B4B4B;
  --ink-60: #787878;
  --ink-40: #A5A5A5;
  --ink-20: #D2D2D2;
  --ink-10: #E9E9E9;
  --paper: #FFFFFF;
  --bg: #FAFBFA;
  --danger: #C4443C;
  --danger-bg: #FBEBEA;
  --warn-bg: #FFF6E0;
  --warn: #8A6D1A;

  --radius: 14px;
  --radius-sm: 9px;
  --shadow-card: 0 1px 2px rgba(30, 30, 30, .04), 0 6px 18px -8px rgba(30, 30, 30, .08);
  --shadow-pop: 0 4px 10px rgba(30, 30, 30, .06), 0 16px 34px -12px rgba(30, 30, 30, .16);
  --font: "Montserrat", Arial, "Helvetica Neue", sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
}

h1, h2, h3 { line-height: 1.25; margin: 0 0 .35em; letter-spacing: -.01em; }
h1 { font-size: 24px; font-weight: 700; }
h2 { font-size: 17px; font-weight: 600; }
h3 { font-size: 15px; font-weight: 600; }
p { margin: 0 0 .8em; }
a { color: inherit; }
img { max-width: 100%; display: block; }

.eyebrow {
  font-size: 11px; font-weight: 600; letter-spacing: .12em;
  text-transform: uppercase; color: var(--green-deep); margin-bottom: 6px;
}
.muted { color: var(--ink-60); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }

/* --------------------------------------------------------------------------
   Estructura
   -------------------------------------------------------------------------- */
.container { max-width: 1180px; margin: 0 auto; padding: 0 22px; }

.site-header {
  position: sticky; top: 0; z-index: 40;
  background: rgba(255, 255, 255, .94);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--ink-10);
}
.site-header .bar {
  display: flex; align-items: center; gap: 26px; height: 62px;
}
.brand { display: flex; align-items: center; flex-shrink: 0; }
.brand img { height: 30px; width: auto; }

.main-nav { display: flex; gap: 4px; align-items: center; }
.main-nav a {
  text-decoration: none; font-weight: 500; font-size: 13.5px;
  color: var(--ink-80); padding: 7px 13px; border-radius: 999px;
}
.main-nav a:hover { background: var(--green-20); color: var(--ink); }
.main-nav a.active { background: var(--ink); color: #fff; font-weight: 600; }

.header-right { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.user-chip { display: flex; align-items: center; gap: 9px; }
.user-chip .avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--green); color: var(--ink);
  display: grid; place-items: center; font-weight: 700; font-size: 12.5px;
}
.user-chip .name { font-size: 13px; font-weight: 600; max-width: 150px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.lang-switch { display: flex; gap: 2px; border: 1px solid var(--ink-10);
  border-radius: 999px; padding: 2px; background: #fff; }
.lang-switch button {
  border: 0; background: transparent; font: inherit; font-size: 11.5px;
  font-weight: 600; padding: 3px 9px; border-radius: 999px;
  color: var(--ink-60); cursor: pointer;
}
.lang-switch button.active { background: var(--ink); color: #fff; }

.logout-form button {
  background: none; border: 0; font: inherit; font-size: 13px; font-weight: 500;
  color: var(--ink-60); cursor: pointer; padding: 6px 4px;
}
.logout-form button:hover { color: var(--ink); }

main.page { padding: 30px 0 56px; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between;
  gap: 18px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head .lead { color: var(--ink-60); max-width: 640px; }

.site-footer {
  border-top: 1px solid var(--ink-10); background: #fff;
  padding: 22px 0; margin-top: auto;
}
.site-footer .row { display: flex; align-items: center; gap: 12px;
  justify-content: space-between; flex-wrap: wrap; }
.site-footer img { height: 16px; opacity: .55; }
.site-footer span { font-size: 11.5px; color: var(--ink-40); letter-spacing: .06em; }

body { min-height: 100vh; display: flex; flex-direction: column; }

/* --------------------------------------------------------------------------
   Botons i formularis
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-size: 13.5px; font-weight: 600;
  border-radius: 999px; padding: 10px 20px; cursor: pointer;
  border: 1.5px solid transparent; text-decoration: none;
  transition: background .15s, transform .05s, border-color .15s;
  color: var(--ink);
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--green); }
.btn-primary:hover { background: var(--green-dark); }
.btn-dark { background: var(--ink); color: #fff; }
.btn-dark:hover { background: #000; }
.btn-outline { background: #fff; border-color: var(--ink-20); }
.btn-outline:hover { border-color: var(--ink); }
.btn-ghost { background: transparent; color: var(--ink-60); padding: 8px 12px; }
.btn-ghost:hover { color: var(--ink); background: var(--ink-10); }
.btn-danger-ghost { background: transparent; color: var(--danger); padding: 8px 12px; }
.btn-danger-ghost:hover { background: var(--danger-bg); }
.btn-sm { padding: 7px 14px; font-size: 12.5px; }
.btn[disabled] { opacity: .5; pointer-events: none; }

label.field { display: block; margin-bottom: 14px; }
label.field > span {
  display: block; font-size: 12px; font-weight: 600; margin-bottom: 5px;
  color: var(--ink-80);
}
.input, select.input, textarea.input {
  width: 100%; font: inherit; font-size: 14px;
  border: 1.5px solid var(--ink-20); border-radius: var(--radius-sm);
  padding: 9px 12px; background: #fff; color: var(--ink);
}
.input:focus, select.input:focus, textarea.input:focus {
  outline: none; border-color: var(--green-dark);
  box-shadow: 0 0 0 3px var(--green-20);
}
.input-row { display: flex; gap: 8px; }
.input-row .input { flex: 1; }
.hint { font-size: 11.5px; color: var(--ink-40); margin-top: 4px; }

/* --------------------------------------------------------------------------
   Targetes i seccions
   -------------------------------------------------------------------------- */
.card {
  background: var(--paper); border: 1px solid var(--ink-10);
  border-radius: var(--radius); box-shadow: var(--shadow-card);
}
.card .card-head {
  padding: 16px 20px 0; display: flex; align-items: center;
  justify-content: space-between; gap: 14px; flex-wrap: wrap;
}
.card .card-body { padding: 16px 20px 20px; }

.section { margin-bottom: 26px; }

/* Stat tiles (dashboard) */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px; margin-bottom: 26px; }
.stat {
  background: #fff; border: 1px solid var(--ink-10); border-radius: var(--radius);
  padding: 16px 18px 14px; box-shadow: var(--shadow-card);
}
.stat .label { font-size: 12px; color: var(--ink-60); font-weight: 500; }
.stat .value { font-size: 30px; font-weight: 600; letter-spacing: -.01em; margin-top: 2px; }
.stat .value small { font-size: 15px; font-weight: 500; color: var(--ink-60); }

/* Chips de tags */
.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600; border-radius: 999px;
  padding: 5px 12px; background: #fff; color: var(--ink-80);
  border: 1.5px solid var(--ink-20); cursor: pointer; text-decoration: none;
  transition: all .12s;
}
.chip:hover { border-color: var(--green-dark); background: var(--green-20); }
.chip.active { background: var(--ink); color: #fff; border-color: var(--ink); }
.chip .count { font-weight: 500; color: inherit; opacity: .55; font-size: 11px; }

.tag-pill {
  display: inline-block; font-size: 10.5px; font-weight: 600;
  letter-spacing: .05em; padding: 2.5px 9px; border-radius: 999px;
  background: var(--green-20); color: var(--green-deep);
}

/* Badges d'estat */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 600; border-radius: 999px; padding: 3px 10px;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: currentColor; }
.badge-active { background: var(--green-20); color: var(--green-deep); }
.badge-upcoming { background: var(--ink-10); color: var(--ink-60); }
.badge-expired { background: var(--danger-bg); color: var(--danger); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }

/* Alertes */
.alert { border-radius: var(--radius-sm); padding: 11px 15px; font-size: 13.5px;
  margin-bottom: 16px; font-weight: 500; }
.alert-ok { background: var(--green-20); color: var(--green-deep); }
.alert-err { background: var(--danger-bg); color: var(--danger); }

/* Credencials (mostra única) */
.credentials {
  border: 1.5px dashed var(--green-dark); background: var(--green-20);
  border-radius: var(--radius); padding: 16px 20px; margin-bottom: 20px;
}
.credentials .row { display: flex; gap: 26px; flex-wrap: wrap; margin-top: 8px; }
.credentials .kv .k { font-size: 11px; font-weight: 600; color: var(--green-deep);
  text-transform: uppercase; letter-spacing: .08em; }
.credentials .kv .v { font-size: 16px; font-weight: 600; font-family: ui-monospace,
  SFMono-Regular, Menlo, monospace; display: flex; align-items: center; gap: 8px; }
.copy-btn { border: 0; background: #fff; border-radius: 6px; cursor: pointer;
  font-size: 11px; font-weight: 600; padding: 3px 8px; color: var(--ink-60);
  border: 1px solid var(--ink-20); }
.copy-btn:hover { color: var(--ink); border-color: var(--ink-40); }

/* --------------------------------------------------------------------------
   Graella de vídeos
   -------------------------------------------------------------------------- */
.video-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(235px, 1fr));
  gap: 18px;
}
.video-card {
  background: #fff; border: 1px solid var(--ink-10); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow-card); text-decoration: none;
  display: flex; flex-direction: column;
  transition: transform .14s ease, box-shadow .14s ease;
}
a.video-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-pop); }
.thumb { position: relative; aspect-ratio: 16 / 9; background: var(--ink-10); }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb .placeholder { width: 100%; height: 100%; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--green-20), var(--green-40)); }
.thumb .placeholder img { width: 44%; height: auto; opacity: .8; }
.thumb .duration {
  position: absolute; right: 8px; bottom: 8px;
  background: rgba(30, 30, 30, .82); color: #fff; font-size: 11px;
  font-weight: 600; border-radius: 6px; padding: 2px 7px;
  font-variant-numeric: tabular-nums;
}
.thumb .play-ind {
  position: absolute; inset: 0; display: grid; place-items: center;
  opacity: 0; transition: opacity .15s; background: rgba(30, 30, 30, .28);
}
a.video-card:hover .play-ind { opacity: 1; }
.play-ind span {
  width: 52px; height: 52px; border-radius: 50%; background: var(--green);
  display: grid; place-items: center; box-shadow: var(--shadow-pop);
}
.play-ind svg { margin-left: 3px; }
.video-card .body { padding: 12px 14px 14px; display: flex; flex-direction: column;
  gap: 8px; flex: 1; }
.video-card .title {
  font-size: 14px; font-weight: 600; line-height: 1.35; color: var(--ink);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; min-height: 2.7em;
}
.video-card .meta { margin-top: auto; font-size: 11.5px; color: var(--ink-60); }

/* --------------------------------------------------------------------------
   Taules
   -------------------------------------------------------------------------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data th {
  text-align: left; font-size: 11px; font-weight: 600; letter-spacing: .08em;
  text-transform: uppercase; color: var(--ink-60);
  padding: 10px 12px; border-bottom: 1.5px solid var(--ink-10);
}
table.data td { padding: 12px; border-bottom: 1px solid var(--ink-10);
  vertical-align: middle; }
table.data tr:last-child td { border-bottom: 0; }
table.data tr.row-link { cursor: pointer; }
table.data tr.row-link:hover { background: var(--green-20); }
table.data .num { font-variant-numeric: tabular-nums; }

/* Barra de progrés (meter: track = pas més clar del mateix ramp) */
.progress { display: flex; align-items: center; gap: 9px; min-width: 120px; }
.progress .track { flex: 1; height: 7px; border-radius: 999px; background: var(--green-20);
  overflow: hidden; }
.progress .fill { height: 100%; border-radius: 999px; background: var(--green-dark); }
.progress .pct { font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums;
  color: var(--ink-80); min-width: 38px; text-align: right; }

/* --------------------------------------------------------------------------
   Login
   -------------------------------------------------------------------------- */
body.login-page { background: #fff; }
.login-wrap {
  min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}
.login-form-side {
  display: flex; flex-direction: column; justify-content: center;
  padding: 48px clamp(24px, 7vw, 96px); position: relative; z-index: 2;
}
.login-form-side .logo { width: min(240px, 60%); margin: 0 auto 40px; }
.login-card { max-width: 380px; width: 100%; margin: 0 auto; }
.login-card h1 { font-size: 21px; text-align: center; }
.login-card .intro { text-align: center; color: var(--ink-60); font-size: 13.5px;
  margin-bottom: 26px; }
.login-lang { position: absolute; top: 22px; right: 26px; }

.login-brand-side {
  position: relative; background: var(--green); overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
.login-brand-side::before {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(160deg, rgba(255,255,255,.14), rgba(30,30,30,.05));
}
.login-brand-side .symbol { width: 62%; max-width: 460px; opacity: .95;
  position: relative; }
.login-brand-side .tagline {
  position: absolute; bottom: 42px; left: 0; right: 0; text-align: center;
  font-size: 12.5px; font-weight: 600; letter-spacing: .28em; color: var(--ink);
  opacity: .75; text-transform: uppercase;
}

@media (max-width: 860px) {
  .login-wrap { grid-template-columns: 1fr; }
  .login-brand-side { display: none; }
  .login-form-side { padding-bottom: 30vh; }
  .login-form-side::after {
    content: ""; position: fixed; left: 0; right: 0; bottom: 0; height: 26vh;
    background: var(--green); clip-path: polygon(0 38%, 100% 0, 100% 100%, 0 100%);
    z-index: -1;
  }
}

/* --------------------------------------------------------------------------
   Panell: assignació de vídeos
   -------------------------------------------------------------------------- */
.picker { border: 1px solid var(--ink-10); border-radius: var(--radius-sm);
  background: #fff; }
.picker-tools { padding: 12px 14px; border-bottom: 1px solid var(--ink-10);
  display: flex; flex-direction: column; gap: 10px; }
.picker-list { max-height: 380px; overflow-y: auto; }
.pick-row {
  display: flex; align-items: center; gap: 12px; padding: 9px 14px;
  border-bottom: 1px solid var(--ink-10); cursor: pointer;
}
.pick-row:last-child { border-bottom: 0; }
.pick-row:hover { background: var(--green-20); }
.pick-row input[type="checkbox"] { width: 17px; height: 17px; accent-color: var(--green-dark);
  flex-shrink: 0; }
.pick-row .mini-thumb { width: 74px; aspect-ratio: 16/9; border-radius: 6px;
  object-fit: cover; background: var(--ink-10); flex-shrink: 0; }
.pick-row .info { min-width: 0; flex: 1; }
.pick-row .info .n { font-size: 13px; font-weight: 600; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; }
.pick-row .info .m { font-size: 11px; color: var(--ink-60); display: flex; gap: 8px;
  align-items: center; margin-top: 2px; }
.picker-foot {
  padding: 13px 14px; border-top: 1.5px solid var(--ink-10); background: var(--bg);
  display: flex; gap: 14px; align-items: flex-end; flex-wrap: wrap;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
}
.picker-foot label.field { margin: 0; }
.picker-foot .input { width: 150px; }
.sel-count { font-size: 12.5px; font-weight: 600; color: var(--green-deep); }

/* Detalls / expandibles */
details.exp { border: 1px solid var(--ink-10); border-radius: var(--radius-sm);
  background: #fff; margin-bottom: 8px; }
details.exp summary {
  list-style: none; cursor: pointer; padding: 12px 14px;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
details.exp summary::-webkit-details-marker { display: none; }
details.exp summary .chev { margin-left: auto; transition: transform .15s;
  color: var(--ink-40); flex-shrink: 0; }
details.exp[open] summary .chev { transform: rotate(180deg); }
details.exp .exp-body { padding: 0 14px 14px; }

/* Player */
.player-shell { max-width: 940px; margin: 0 auto; }
.player-frame {
  position: relative; aspect-ratio: 16 / 9; background: var(--ink);
  border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-pop);
}
.player-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%;
  border: 0; }
.back-link { display: inline-flex; align-items: center; gap: 7px;
  font-size: 13px; font-weight: 600; color: var(--ink-60); text-decoration: none;
  margin-bottom: 16px; }
.back-link:hover { color: var(--ink); }

/* Empty states */
.empty {
  text-align: center; padding: 56px 20px; color: var(--ink-60);
}
.empty img { width: 120px; margin: 0 auto 18px; opacity: .5; }
.empty .big { font-size: 16px; font-weight: 600; color: var(--ink-80); }

/* Utilitats */
.flex { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
.mt-0 { margin-top: 0; } .mb-0 { margin-bottom: 0; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }

@media (max-width: 720px) {
  .site-header .bar { gap: 10px; height: 56px; }
  .brand img { height: 24px; }
  .main-nav a { padding: 6px 9px; font-size: 12.5px; }
  .user-chip .name { display: none; }
  main.page { padding: 20px 0 40px; }
  h1 { font-size: 20px; }
}
