/*
 * Training module inside the shared workspace frame.
 *
 * The training planner stays its own classic page, but a coach should not
 * notice: it carries the same fixed navigation as the React workspaces (a
 * sidebar on wide screens, a bottom bar on phones and tablets), the same
 * compact page bar and the same calm cards.
 *
 * Presentation only. Loaded after trainingsvideos.css; every rule is scoped to
 * `body.fc-has-nav`, so removing that class (or this file) gives the previous
 * look back. IDs, classes and handlers used by the scripts are unchanged.
 *
 * The navigation rules mirror match-planer-src/src/workspaceNav.css - keep the
 * two in step.
 */
:root {
  --fc-nav-width: 216px;
  --fc-nav-bar-height: 58px;
}

/* ---------- Navigation ---------- */

.fc-nav {
  position: fixed;
  /* Above the sticky category titles (100), below every dialog (9999+). */
  z-index: 200;
  box-sizing: border-box;
  background: var(--fc-surface);
  color: var(--fc-ink-soft);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.fc-nav-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.fc-nav-item {
  display: flex;
  align-items: center;
  color: inherit;
  font-weight: 550;
  letter-spacing: 0;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}

.fc-nav-item svg {
  flex: 0 0 auto;
}

.fc-nav-item[aria-current='page'] {
  color: var(--fc-green-strong);
}

.fc-nav-item:focus-visible {
  outline: 3px solid rgba(47, 102, 179, 0.28);
  outline-offset: -3px;
}

/* Phones and tablets: bottom bar */
@media (max-width: 1199px) {
  body.fc-has-nav {
    padding-bottom: calc(var(--fc-nav-bar-height) + env(safe-area-inset-bottom, 0px));
  }

  .fc-nav {
    right: 0;
    bottom: 0;
    left: 0;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    border-top: 1px solid var(--fc-border);
  }

  .fc-nav-brand,
  .fc-nav-label {
    display: none;
  }

  .fc-nav-list {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    height: var(--fc-nav-bar-height);
  }

  .fc-nav-list li {
    min-width: 0;
  }

  .fc-nav-item {
    height: 100%;
    flex-direction: column;
    justify-content: center;
    gap: 3px;
    padding: 0 2px;
    font-size: 10.5px;
    line-height: 1.2;
  }

  .fc-nav-item[aria-current='page'] {
    font-weight: 650;
  }

  .fc-nav-label-short {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* One compact row instead of a second row for the dashboard button. */
  body.fc-has-nav .fc-app-header.fc-module-header,
  body.fc-has-nav .fc-app-header .fc-module-header-inner {
    min-height: 52px;
  }

  body.fc-has-nav .fc-app-header .fc-module-header-inner {
    display: flex;
    padding: 8px 14px;
    gap: 10px;
  }

  body.fc-has-nav .fc-app-header .fc-module-header-context,
  body.fc-has-nav .fc-app-header .fc-module-header-actions {
    margin: 0;
  }

  body.fc-has-nav .fc-app-header .fc-module-brand-name {
    display: none;
  }

  body.fc-has-nav .fc-app-header .fc-module-header-actions {
    width: auto;
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    gap: 6px;
  }

  body.fc-has-nav .fc-app-header .fc-module-header-button,
  body.fc-has-nav .fc-app-header .fc-module-header-button.lang-switch {
    width: auto !important;
    min-width: 40px;
    min-height: 40px !important;
  }
}

/* Wide screens: sidebar */
@media (min-width: 1200px) {
  body.fc-has-nav {
    padding-left: var(--fc-nav-width);
  }

  .fc-nav {
    top: 0;
    bottom: 0;
    left: 0;
    width: var(--fc-nav-width);
    display: flex;
    flex-direction: column;
    padding: 14px 12px;
    overflow-y: auto;
    border-right: 1px solid var(--fc-border);
  }

  .fc-nav-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 8px 18px;
    color: var(--fc-ink);
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0;
  }

  .fc-nav-brand img {
    width: 30px;
    height: 30px;
    object-fit: contain;
  }

  .fc-nav-list {
    display: grid;
    gap: 2px;
  }

  .fc-nav-item {
    height: 38px;
    gap: 10px;
    padding: 0 10px;
    border-radius: 6px;
    font-size: 14px;
  }

  .fc-nav-item:hover {
    background: var(--fc-surface-muted);
  }

  .fc-nav-item[aria-current='page'] {
    background: #e8f3ee;
    font-weight: 650;
  }

  .fc-nav-label-short {
    display: none;
  }

  /* The sidebar carries the brand; the page bar only names the module. */
  body.fc-has-nav .fc-app-header .fc-module-brand,
  body.fc-has-nav .fc-app-header .fc-module-header-divider {
    display: none;
  }

  body.fc-has-nav .fc-app-header.fc-module-header,
  body.fc-has-nav .fc-app-header .fc-module-header-inner {
    min-height: 56px;
  }

  body.fc-has-nav .fc-app-header .fc-module-header-inner {
    padding-top: 8px;
    padding-bottom: 8px;
  }
}

/* With the navigation on screen a home icon is enough; the button keeps its
   name for screen readers. */
body.fc-has-nav .fc-app-header .fc-module-dashboard-button {
  width: 40px !important;
  min-width: 40px;
  padding: 0 !important;
}

body.fc-has-nav .fc-app-header .fc-module-dashboard-button span {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ---------- Page ---------- */

body.fc-has-nav .container {
  width: min(100%, 1180px);
  padding: 28px 20px 44px;
}

.training-page-head {
  margin: 0 0 20px;
}

.training-page-title {
  margin: 0;
  color: var(--fc-ink);
  font-size: 26px;
  font-weight: 750;
  line-height: 1.2;
  letter-spacing: 0;
}

.training-page-sub {
  margin: 6px 0 0;
  color: var(--fc-muted);
  font-size: 14px;
  line-height: 1.45;
}

/* Calm cards: one hairline border, no coloured edge, no shadow. */
body.fc-has-nav .ki-generator-card {
  margin-bottom: 20px;
  border: 1px solid var(--fc-border);
  box-shadow: none;
}

body.fc-has-nav .ki-generator-card:hover {
  box-shadow: none;
}

body.fc-has-nav .ki-generator-card #openKiModal {
  min-height: 44px;
  padding: 0 18px;
  font-size: 14px;
  font-weight: 600;
}

body.fc-has-nav .category {
  margin-bottom: 10px;
}

body.fc-has-nav .category > h3 {
  box-sizing: border-box;
  min-height: 50px;
  margin-bottom: 0;
  padding: 13px 16px;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--fc-border);
  border-radius: var(--fc-radius);
  box-shadow: none;
  color: var(--fc-ink);
  font-size: 15px;
  font-weight: 650;
  letter-spacing: 0;
  text-align: left;
  transform: none;
}

/* The script puts a decorative ball in front of each title; without it the
   title sits on the left like every other card title. */
body.fc-has-nav .category > h3 > span:first-child {
  display: none;
}

body.fc-has-nav .category > h3:hover {
  border-color: #aabbb5;
  box-shadow: none;
  transform: none;
}

body.fc-has-nav .category > h3[aria-expanded='true'] {
  border-color: #aabbb5;
  box-shadow: 0 6px 16px rgba(16, 35, 63, 0.08);
}

body.fc-has-nav .category > h3[aria-expanded='true']::after {
  transform: rotate(180deg);
}

body.fc-has-nav .videos {
  margin-top: 6px;
  padding: 10px 0 14px;
}

/* Filter tabs of an open category: a quiet segmented row. */
body.fc-has-nav .category-filters {
  gap: 6px;
  padding: 4px 0 12px;
}

body.fc-has-nav .category-filter-btn {
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid var(--fc-border);
  border-radius: var(--fc-radius);
  background: var(--fc-surface);
  color: var(--fc-ink-soft);
  font-size: 13px;
  letter-spacing: 0;
}

body.fc-has-nav .category-filter-btn:hover {
  background: var(--fc-surface-muted);
  color: var(--fc-ink);
}

body.fc-has-nav .category-filter-btn.active {
  border-color: var(--fc-green);
  background: #e8f3ee;
  box-shadow: none;
  color: var(--fc-green-strong);
}

body.fc-has-nav .category-filter-btn.active:hover {
  border-color: var(--fc-green-strong);
  background: #dcece4;
  color: var(--fc-green-strong);
}

/* An even grid: three exercises per row, two on a phone. */
body.fc-has-nav .videos {
  gap: 16px;
}

body.fc-has-nav .video-item {
  width: calc((100% - 32px) / 3);
  margin-bottom: 0;
  padding: 10px;
}

body.fc-has-nav .video-item,
body.fc-has-nav .video-item:hover {
  box-shadow: none;
  transform: none;
}

body.fc-has-nav .video-item:hover {
  border-color: #aabbb5;
}

/* Thumbnails fill their card instead of floating in it. The sizes come from
   the script as inline styles, hence the !important. */
body.fc-has-nav .video-item img,
body.fc-has-nav .video-item .thumbnail-placeholder,
body.fc-has-nav .video-item.custom-upload-card > [style*='dashed'] {
  box-sizing: border-box;
  width: 100% !important;
  height: auto !important;
  aspect-ratio: 5 / 3;
  border-radius: 6px !important;
  object-fit: cover;
  transform: none !important;
}

body.fc-has-nav .video-item span {
  margin-top: 8px;
  font-size: 14px;
}

body.fc-has-nav .load-more-btn {
  min-height: 40px;
  padding: 0 16px;
  border: 1px solid var(--fc-border);
  border-radius: var(--fc-radius);
  background: var(--fc-surface);
  box-shadow: none;
  color: var(--fc-ink-soft);
  font-size: 13px;
  font-weight: 600;
  transform: none;
}

body.fc-has-nav .load-more-btn:hover {
  border-color: #aabbb5;
  background: var(--fc-surface-muted);
}

/* ---------- Training plan ---------- */

body.fc-has-nav .trainingsplan {
  margin-top: 24px;
  padding: 20px;
  border: 1px solid var(--fc-border);
  border-radius: var(--fc-radius);
  box-shadow: none;
}

body.fc-has-nav .trainingsplan h2 {
  margin: 0 0 14px;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0;
}

body.fc-has-nav #header-info {
  justify-content: flex-start;
  gap: 12px;
  margin-bottom: 20px;
  text-align: left;
}

body.fc-has-nav .trainingsplan .section > h3 {
  color: var(--fc-ink);
  font-size: 14px;
  font-weight: 650;
  letter-spacing: 0;
}

/* The item markup comes from the script with inline styles; only its look is
   adjusted here. */
body.fc-has-nav .trainingsplan .section ul li > div:first-child {
  margin-bottom: 8px !important;
  color: var(--fc-ink);
  font-weight: 650 !important;
  text-align: left !important;
  text-decoration: none !important;
}

body.fc-has-nav .trainingsplan .section ul li button {
  width: 30px;
  padding: 0 !important;
  border: 1px solid var(--fc-border) !important;
  border-radius: 6px;
  background: var(--fc-surface) !important;
  box-shadow: none;
  color: #b42318 !important;
  font-size: 18px;
  line-height: 1;
  transform: none;
}

body.fc-has-nav .trainingsplan .section ul li button:hover {
  border-color: #f0b4ae !important;
  background: #fdf1f0 !important;
}

body.fc-has-nav .trainingsplan .section ul li input[type='number'],
body.fc-has-nav .trainingsplan .section ul li .move-dropdown {
  border: 1px solid var(--fc-border);
  border-radius: 6px;
  background: var(--fc-surface);
  color: var(--fc-ink);
  font-size: 13px;
}

body.fc-has-nav .trainingsplan > div:last-child {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 20px !important;
  font-size: 0;
  text-align: left !important;
}

body.fc-has-nav .trainingsplan > div:last-child button {
  min-height: 44px;
  padding: 0 18px;
  border-radius: var(--fc-radius);
  box-shadow: none;
  font-size: 14px;
  font-weight: 600;
  transform: none;
}

body.fc-has-nav .trainingsplan > div:last-child button[onclick='downloadPDF()'] {
  background: var(--fc-green);
  color: #ffffff;
}

body.fc-has-nav .trainingsplan > div:last-child button[onclick='downloadPDF()']:hover {
  background: var(--fc-green-strong);
}

body.fc-has-nav .trainingsplan > div:last-child button[onclick='exportICS()'] {
  border: 1px solid var(--fc-border);
  background: var(--fc-surface);
  color: var(--fc-ink-soft);
}

body.fc-has-nav .trainingsplan > div:last-child button[onclick='exportICS()']:hover {
  border-color: #aabbb5;
  background: var(--fc-surface-muted);
}

@media (max-width: 768px) {
  body.fc-has-nav .container {
    padding: 18px 14px 32px;
  }

  .training-page-title {
    font-size: 22px;
  }

  body.fc-has-nav .videos {
    gap: 10px;
  }

  body.fc-has-nav .video-item {
    width: calc((100% - 10px) / 2) !important;
    padding: 8px;
  }

  body.fc-has-nav .video-item span {
    font-size: 13px;
  }

  body.fc-has-nav .trainingsplan {
    margin: 20px 0 0;
  }

  /* A plan item on a phone: picture and notes across, then one row with the
     minutes, the section and the remove button. */
  body.fc-has-nav .training-plan-item-content {
    flex-direction: row !important;
    flex-wrap: wrap !important;
    align-items: center !important;
    gap: 8px !important;
  }

  body.fc-has-nav .training-plan-item-content > img,
  body.fc-has-nav .training-plan-item-content > textarea {
    flex: 0 0 100%;
  }

  body.fc-has-nav .training-plan-item-content > input[type='number'] {
    flex: 0 0 84px;
    width: 84px !important;
  }

  body.fc-has-nav .training-plan-item-content > select {
    flex: 1 1 120px;
    order: 2;
    width: auto !important;
  }

  body.fc-has-nav .training-plan-item-content > button {
    flex: 0 0 44px;
    order: 3;
    width: 44px !important;
  }

  body.fc-has-nav .trainingsplan > div:last-child button {
    margin: 0 !important;
  }

  body.fc-has-nav .trainingsplan {
    padding: 16px 14px;
  }

  body.fc-has-nav .trainingsplan > div:last-child button {
    flex: 1 1 100%;
  }
}

@media print {
  .fc-nav {
    display: none;
  }

  body.fc-has-nav {
    padding: 0;
  }
}
