:root {
  /* paleta My Garage Box: dourado do logo + preto + branco */
  --bg: #0c0c0c;
  --bg-card: #1a1a1a;
  --line: #333333;
  --text: #f5f5f2;
  --text-dim: #9c9c98;
  --accent: #ca9d71;
  --accent-2: #e0bd93;
  --danger: #d9645a;
  --ok: #8fbf8a;
  font-family: "Oswald", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

h1, h2, h3, .display-font {
  font-family: "Poppins", system-ui, sans-serif;
  font-weight: 700;
}

a { color: var(--accent-2); }

/* ---------- landing ---------- */
.landing {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  text-align: center;
  padding: 2rem;
}
.landing h1 { font-size: 3rem; margin: 0; }
.landing p { color: var(--text-dim); max-width: 32rem; }
.landing .links { display: flex; gap: 1rem; flex-wrap: wrap; justify-content: center; }
.btn {
  display: inline-block;
  padding: 0.9rem 1.6rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 0.5rem;
  font-family: "Oswald", sans-serif;
  font-weight: 600;
  font-size: 1rem;
  text-decoration: none;
  cursor: pointer;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}
.btn.secondary { background: var(--bg-card); border: 1px solid var(--line); color: var(--text); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------- backoffice ---------- */
.wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: 2rem 1.25rem 4rem;
}
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}
.topbar h1 { font-size: 1.6rem; margin: 0; }

.tabs { display: flex; gap: 0.5rem; margin-bottom: 1.5rem; }
.tab-btn {
  background: none;
  border: 1px solid var(--line);
  color: var(--text-dim);
  padding: 0.65rem 1.2rem;
  border-radius: 0.5rem;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.tab-btn.active { background: var(--bg-card); color: var(--text); border-color: var(--accent); }

.day-filter {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding-bottom: 0.75rem;
  margin-bottom: 0.5rem;
  border-bottom: 1px solid var(--line);
}
.day-pill {
  flex-shrink: 0;
  background: none;
  border: 1px solid var(--line);
  color: var(--text-dim);
  padding: 0.5rem 0.9rem;
  border-radius: 999px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.85rem;
  white-space: nowrap;
}
.day-pill.active { background: var(--accent); color: #1a1207; border-color: var(--accent); font-weight: 600; }

.card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-dim);
  margin: 1rem 0 0.35rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
label:first-child { margin-top: 0; }

input[type="text"], input[type="email"], input[type="password"], input[type="date"], input[type="file"], select, textarea {
  width: 100%;
  background: #0f0f12;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  color: var(--text);
  padding: 0.7rem 0.8rem;
  font-family: inherit;
  font-size: 1rem;
}
textarea { min-height: 5rem; resize: vertical; }

.trainer-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border-bottom: 1px solid var(--line);
  padding: 0.7rem 0;
}
.trainer-row:last-child { border-bottom: none; }
.trainer-row .avatar {
  width: 2.6rem;
  height: 2.6rem;
  border-radius: 50%;
  object-fit: cover;
  background: var(--bg-card);
  border: 1px solid var(--line);
  flex-shrink: 0;
}
.trainer-row .name { flex: 1; font-weight: 600; }

.section-row {
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  padding: 0.85rem;
  margin-bottom: 0.75rem;
}
.section-row .section-row-top {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.5rem;
}
.section-row input[type="text"] { flex: 1; }
.section-row textarea { min-height: 4rem; }
.section-row .remove-section-btn {
  flex-shrink: 0;
  background: none;
  border: 1px solid var(--line);
  color: var(--text-dim);
  border-radius: 0.4rem;
  width: 2.2rem;
  height: 2.2rem;
  cursor: pointer;
  font-size: 1rem;
}
.section-row .remove-section-btn:hover { color: var(--danger); border-color: var(--danger); }

.checks { display: flex; gap: 1.25rem; margin-top: 0.5rem; }
.checks label {
  display: flex; align-items: center; gap: 0.4rem;
  text-transform: none; font-size: 0.95rem; color: var(--text); margin: 0;
}

.actions { display: flex; gap: 0.75rem; margin-top: 1.5rem; }

.msg { font-size: 0.9rem; margin-top: 0.75rem; }
.msg.ok { color: var(--ok); }
.msg.err { color: var(--danger); }

.history-item {
  border-bottom: 1px solid var(--line);
  padding: 0.9rem 0;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
}
.history-item:last-child { border-bottom: none; }
.history-item .meta { color: var(--text-dim); font-size: 0.8rem; }
.history-item .tags { display: flex; gap: 0.35rem; margin-top: 0.3rem; }
.tag {
  font-size: 0.7rem; padding: 0.15rem 0.5rem; border-radius: 999px;
  background: #241d14; color: var(--accent-2); border: 1px solid var(--line);
  text-transform: uppercase;
}
.history-item .row-actions { display: flex; gap: 0.5rem; flex-shrink: 0; }
.icon-btn {
  background: none; border: 1px solid var(--line); color: var(--text-dim);
  border-radius: 0.4rem; padding: 0.35rem 0.6rem; cursor: pointer; font-size: 0.8rem;
}
.icon-btn:hover { color: var(--text); border-color: var(--text-dim); }

.date-heading {
  font-size: 0.8rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 1.25rem 0 0.5rem;
}
.date-heading:first-child { margin-top: 0; }

.live-status-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--line);
}
.live-status-row:last-child { border-bottom: none; }
.live-status-row .dot {
  width: 0.6rem; height: 0.6rem; border-radius: 50%;
  background: var(--line); flex-shrink: 0;
}
.live-status-row .dot.on { background: var(--ok); }
.live-status-row .screen-name { font-weight: 600; min-width: 4.5rem; }
.live-status-row .info { color: var(--text-dim); font-size: 0.9rem; }

.publish-item {
  border: 1px solid var(--line);
  border-radius: 0.6rem;
  padding: 1rem;
  margin-bottom: 0.75rem;
}
.publish-item .publish-item-title { font-weight: 600; font-size: 1.05rem; }
.publish-item .publish-item-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 0.75rem;
  flex-wrap: wrap;
}
.publish-item .trainer-selects {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-top: 0.75rem;
}
.publish-item .trainer-selects select { width: auto; min-width: 11rem; }

.login-box {
  max-width: 360px;
  margin: 15vh auto 0;
  padding: 2rem;
}

/* ---------- display (TV) ---------- */
:root { --s: 1; }

body.tv-page { height: 100%; overflow: hidden; }

.tv {
  height: 100vh;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  padding: 2rem 3rem;
  position: relative;
}
.tv-bg-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 30%;
  filter: grayscale(1);
  opacity: 0.32;
  z-index: 0;
}
.tv-header, #content, .tv-footer {
  position: relative;
  z-index: 1;
}

.tv-footer {
  flex-shrink: 0;
  margin-top: 1.25rem;
  padding-top: 0.85rem;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  font-family: "Poppins", system-ui, sans-serif;
  font-weight: 600;
  font-size: 1.15rem;
  color: var(--accent-2);
  text-align: center;
}
.tv-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 4px solid var(--accent);
  padding-bottom: 1rem;
  margin-bottom: 1.5rem;
  flex-shrink: 0;
}
.tv-header .brand { display: flex; align-items: center; gap: 0.85rem; font-size: 1.6rem; }
.tv-header .brand-logo {
  height: 2.1rem;
  width: auto;
  display: block;
  /* força a ficar branco não importa como esta TV decodifique as cores do PNG */
  filter: brightness(0) invert(1);
}

.clock-box {
  background: rgba(26, 26, 26, 0.38);
  -webkit-backdrop-filter: blur(8px) saturate(130%);
  backdrop-filter: blur(8px) saturate(130%);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 0.6rem;
  padding: 0.4rem 1.1rem;
  text-align: right;
}
.clock-date {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: capitalize;
}
.clock-time {
  font-size: 2.1rem;
  font-weight: 800;
  color: var(--accent-2);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
  line-height: 1.15;
}

#content {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  position: relative;
}

/* wrapper com altura natural, para medir o conteúdo real (o #content
   à volta está esticado a preencher o ecrã, por isso não serve para medir) */
#content-inner {
  display: flex;
  flex-direction: column;
}

/* ecrã "sem aula a decorrer" (Open Box / Bem-vindo) */
.tv-idle {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 1.5rem 2rem;
}
.tv-idle-text, .tv-intro-title {
  font-family: "Poppins", system-ui, sans-serif;
  font-weight: 800;
  text-transform: uppercase;
  line-height: 1.5;
  padding-top: 0.2em;
  color: #ffffff;
  animation: tv-idle-glow 2.5s ease-in-out infinite;
}
.tv-idle-text {
  font-size: clamp(2.75rem, 7vw, 6.5rem);
}
.tv-intro-title {
  font-size: clamp(5rem, 17vw, 14rem);
}
@keyframes tv-idle-glow {
  0%, 100% { text-shadow: 0 0 25px rgba(255, 255, 255, 0.15); }
  50% { text-shadow: 0 0 45px rgba(255, 255, 255, 0.55), 0 0 20px var(--accent-2); }
}

/* intro de 5s ao publicar um treino novo */
.tv-intro .tv-intro-title {
  opacity: 0;
  transition: opacity 0.6s ease;
}
.tv-intro.show .tv-intro-title {
  opacity: 1;
}

.tv-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: calc(1rem * var(--s));
  flex-wrap: wrap;
  margin: 0 0 calc(1.5rem * var(--s));
  flex-shrink: 0;
}
.tv-title {
  font-size: calc(3.4rem * var(--s));
  font-weight: 800;
  color: var(--accent-2);
  margin: 0;
}

.tv-trainers {
  display: flex;
  gap: calc(1.25rem * var(--s));
  flex-wrap: wrap;
}
.trainer-chip {
  display: flex;
  align-items: center;
  gap: calc(0.6rem * var(--s));
  font-family: "Poppins", system-ui, sans-serif;
  font-size: calc(1.1rem * var(--s));
  font-weight: 600;
  color: var(--text);
}
.trainer-avatar {
  width: calc(3rem * var(--s));
  height: calc(3rem * var(--s));
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--accent);
  flex-shrink: 0;
}
.trainer-avatar-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-card);
  color: var(--accent-2);
  font-weight: 800;
  font-size: calc(1.2rem * var(--s));
}

.tv-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
  align-content: start;
}
/* colunas fixas (não dependem da largura do ecrã reportada pela TV -
   nalgumas isso estava a colapsar tudo numa só coluna) */
.tv-grid.cols-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.tv-section {
  background: rgba(26, 26, 26, 0.38);
  -webkit-backdrop-filter: blur(8px) saturate(130%);
  backdrop-filter: blur(8px) saturate(130%);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-top: 3px solid var(--accent);
  border-radius: 1rem;
  padding: 1.25rem 1.5rem;
}
.tv-section h2 {
  font-size: calc(1.4rem * var(--s));
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--accent-2);
  margin: 0 0 calc(0.6rem * var(--s));
}
.tv-section .body {
  font-size: calc(1.9rem * var(--s));
  font-weight: 600;
  line-height: 1.4;
  white-space: pre-wrap;
  font-family: "Poppins", system-ui, sans-serif;
}

.tv-empty {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  color: var(--text-dim);
  text-align: center;
}

@media (max-width: 1100px) {
  .tv { padding: 1.5rem; }
  .tv-grid { grid-template-columns: 1fr; }
}

/* ---------- backoffice em telemóvel: só a aba Publicar ---------- */
@media (max-width: 768px) {
  .tabs { display: none; }
  #tab-plan, #tab-trainers { display: none !important; }
  #tab-publish { display: block !important; }
}
