/* Shared page shell for paid add-on apps (root-level; not tied to any one module). */

html:has(.add-on-app) {
  height: 100%;
}

.add-on-app {
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  margin: 0;
  overflow: hidden;
  background: var(--bg, #0d1117);
  color: var(--text, #e6edf3);
  font-family: "Plus Jakarta Sans", "Segoe UI", system-ui, sans-serif;
  display: flex;
  flex-direction: column;
}

.add-on-frame {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  width: min(960px, calc(100% - 1rem));
  margin: 0 auto;
}

.add-on-body {
  flex: 1;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 0.4rem 0.5rem 1rem;
  padding-bottom: max(1rem, env(safe-area-inset-bottom, 0px));
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

/* Settings / library nav rows (Export, Import, Views, etc.). */
:is(.add-on-app, .pp-view-app) .mb-library-item {
  display: block;
  width: 100%;
  box-sizing: border-box;
  margin: 0.35rem 0 0;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border, #30363d);
  border-radius: 0.45rem;
  background: var(--bg, #0d1117);
  color: var(--text, #e6edf3);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

:is(.add-on-app, .pp-view-app) .mb-library-item:hover {
  background: var(--surface-hover, #21262d);
}

.add-on-body--settings {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding-bottom: 0;
}

.add-on-app .btn {
  min-height: 2.35rem;
  padding: 0.45rem 0.85rem;
  font-size: 1rem;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

/* Expand: full width + fixed shell when native fullscreen is unavailable (iOS). */
body.add-on-immersive-on .add-on-frame {
  width: 100%;
  max-width: none;
  margin: 0;
}

body.add-on-immersive-on .add-on-frame:not(:fullscreen):not(:-webkit-full-screen) {
  position: fixed;
  inset: 0;
  z-index: 80;
  height: 100vh;
  height: 100dvh;
  background: var(--bg, #0d1117);
}

/* Light mode — contained controls use --surface (white); page keeps --bg tint. Revert: remove this block. */
body.theme-light:is(.add-on-app, .pp-view-app) .add-on-field__input,
body.theme-light:is(.add-on-app, .pp-view-app) select.add-on-field__input {
  background-color: var(--surface, #ffffff);
}

body.theme-light:is(.add-on-app, .pp-view-app) .add-on-editor .library-squad-table thead th,
body.theme-light:is(.add-on-app, .pp-view-app) .add-on-editor .library-squad-table input {
  background: var(--surface, #ffffff);
}

body.theme-light:is(.add-on-app, .pp-view-app) .add-on-choice,
body.theme-light:is(.add-on-app, .pp-view-app) .rd-tx-choice {
  background: var(--surface, #ffffff);
}

body.theme-light:is(.add-on-app, .pp-view-app) .add-on-choice:disabled:hover,
body.theme-light:is(.add-on-app, .pp-view-app) .add-on-choice.is-disabled:hover,
body.theme-light:is(.add-on-app, .pp-view-app) .rd-tx-choice.is-disabled:hover,
body.theme-light:is(.add-on-app, .pp-view-app) .rd-tx-choice:disabled:hover {
  background: var(--surface, #ffffff);
}

body.theme-light:is(.add-on-app, .pp-view-app) .add-on-group-list__item,
body.theme-light:is(.add-on-app, .pp-view-app) .add-on-group-list__name,
body.theme-light:is(.add-on-app, .pp-view-app) .add-on-group-list__delete:not(.tc-opp-club-squad-badge),
body.theme-light:is(.add-on-app, .pp-view-app) .add-on-group-list__empty-cell {
  background: var(--surface, #ffffff);
}

body.theme-light:is(.add-on-app, .pp-view-app) .add-on-group-list__name:hover,
body.theme-light:is(.add-on-app, .pp-view-app) .add-on-group-list__item:hover {
  background: var(--surface-hover, #eef3f9);
}

body.theme-light:is(.add-on-app, .pp-view-app) .add-on-group-list__count {
  background: color-mix(in srgb, var(--muted, #5f6b79) 10%, var(--surface-hover, #eef3f9));
  color: var(--text, #111827);
}

body.theme-light:is(.add-on-app, .pp-view-app) .mb-library-item {
  background: var(--surface, #ffffff);
}

body.theme-light:is(.add-on-app, .pp-view-app) .mb-library-item:hover {
  background: var(--surface-hover, #eef3f9);
}

body.theme-light.tc-app .tc-report-question-chip {
  background: var(--surface, #ffffff);
}

/* library-input (match editor title/date/time, roster fields, etc.) */
body.theme-light:is(.add-on-app, .pp-view-app) input.library-input:not([type="checkbox"]):not([type="radio"]):not(
    [type="range"]
  ):not([type="file"]):not([type="color"]):not([type="hidden"]),
body.theme-light:is(.add-on-app, .pp-view-app) textarea.library-input,
body.theme-light:is(.add-on-app, .pp-view-app) select.library-input {
  background: var(--surface, #ffffff);
  background-color: var(--surface, #ffffff);
}

/* Team Coach — coach notes on roster + match workspace */
body.theme-light.tc-app .tc-roster-player-notes-box .lc-notes-compose textarea,
body.theme-light.tc-app .tc-match-workspace__notes .lc-notes-compose textarea,
body.theme-light.tc-app .tc-mw-notes-split__compose textarea,
body.theme-light.tc-app .tc-roster-player-notes-box .tc-player-note-text,
body.theme-light.tc-app .tc-match-workspace__notes .tc-player-note-text {
  background: var(--surface, #ffffff);
}

/* Team Coach — player report mini-tiles on roster */
body.theme-light.tc-app .tc-pr-tile {
  background: var(--surface, #ffffff);
}

/* Checkboxes — checked used surface-hover (pink tint on TC); keep white */
body.theme-light:is(.add-on-app, .pp-view-app) input[type="checkbox"]:not(.visually-hidden),
body.theme-light:is(.add-on-app, .pp-view-app) input[type="checkbox"]:not(.visually-hidden):checked {
  background-color: var(--surface, #ffffff);
}

/* Match Booth — match preview team info panels */
body.theme-light:is(.add-on-app, .pp-view-app) .mb-matches-preview__info.mb-settings-section__box {
  background: var(--surface, #ffffff);
}

/* Add-on scroll hosts — themed scrollbars (page + library columns) */
body.add-on-app :is(
    .add-on-body,
    .mb-library-list__scroll,
    .mb-library-editor__scroll,
    .mb-settings-prefs__scroll,
    .mb-settings-backup__scroll,
    .tc-roster-player-notes-box .lc-notes-list
  ) {
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--muted, #8b949e) 65%, var(--border, #30363d)) var(--bg, #0d1117);
}

body.add-on-app :is(
    .add-on-body,
    .mb-library-list__scroll,
    .mb-library-editor__scroll,
    .mb-settings-prefs__scroll,
    .mb-settings-backup__scroll,
    .tc-roster-player-notes-box .lc-notes-list
  )::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

body.add-on-app :is(
    .add-on-body,
    .mb-library-list__scroll,
    .mb-library-editor__scroll,
    .mb-settings-prefs__scroll,
    .mb-settings-backup__scroll,
    .tc-roster-player-notes-box .lc-notes-list
  )::-webkit-scrollbar-track {
  background: var(--bg, #0d1117);
  border-radius: 8px;
}

body.add-on-app :is(
    .add-on-body,
    .mb-library-list__scroll,
    .mb-library-editor__scroll,
    .mb-settings-prefs__scroll,
    .mb-settings-backup__scroll,
    .tc-roster-player-notes-box .lc-notes-list
  )::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--muted, #8b949e) 55%, var(--border, #30363d));
  border-radius: 8px;
  border: 2px solid var(--bg, #0d1117);
}

body.add-on-app :is(
    .add-on-body,
    .mb-library-list__scroll,
    .mb-library-editor__scroll,
    .mb-settings-prefs__scroll,
    .mb-settings-backup__scroll,
    .tc-roster-player-notes-box .lc-notes-list
  )::-webkit-scrollbar-thumb:hover {
  background: var(--muted, #8b949e);
}
