/*
  Page Design (backend/config/theme).
  --t-<key> variables and data-t-<key> attributes on <html> are printed by main_template from the theme config.
*/

/* ---------- page shell: footer stays at the bottom on short pages ---------- */
.site-shell {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.site-body {
  flex: 1 0 auto;
  display: flex;
  flex-direction: column;
  padding-left: 16px;
  padding-right: 16px;
}

.site-main {
  flex: 1 0 auto;
}

/* ---------- logo bar ---------- */
.site-topbar {
  background: var(--t-hdr_bar_bg);
  z-index: 1020;
}

html:not([data-t-hdr_bar_enable="1"]) .site-topbar {
  display: none;
}

html[data-t-hdr_bar_sticky="1"] .site-topbar {
  position: sticky;
  top: 0;
}

html[data-t-hdr_bar_shadow="1"] .site-topbar {
  box-shadow: 0 6px 24px -14px rgba(0, 0, 0, .45);
}

.site-topbar__inner {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: calc(var(--t-hdr_bar_logo_h) + 20px);
  padding-top: 10px;
  padding-bottom: 10px;
}

html[data-t-hdr_bar_align="center"] .site-topbar__inner {
  justify-content: center;
  text-align: center;
}

.site-topbar__logo {
  height: auto;
  max-height: var(--t-hdr_bar_logo_h);
  width: auto;
  max-width: 60vw;
  object-fit: contain;
}

.site-topbar__text {
  color: var(--t-hdr_bar_text_color);
  font-weight: 600;
  font-size: clamp(14px, 2.2vw, 18px);
  line-height: 1.3;
}

.site-topbar__text:empty {
  display: none;
}

/* ---------- key visual ---------- */
.site-header {
  padding-top: var(--t-hdr_space_top);
  padding-bottom: var(--t-hdr_space_bottom);
}

html[data-t-hdr_hero_enable="0"] .site-header {
  display: none;
}

.site-hero {
  display: block;
  width: 100%;
  max-width: var(--t-hdr_hero_w);
  height: auto;
  margin: 0 auto;
  image-rendering: -webkit-optimize-contrast;
}

/* ---------- footer ---------- */
.site-footer {
  flex-shrink: 0;
  background: var(--t-ftr_bg);
  color: var(--t-ftr_text_color);
  padding: var(--t-ftr_pad) 16px;
  margin-top: 32px;
}

html[data-t-ftr_divider="1"] .site-footer {
  border-top: 1px solid var(--t-ftr_divider_color);
}

.site-footer__inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
}

html[data-t-ftr_layout="split"] .site-footer__inner {
  flex-direction: row;
  justify-content: space-between;
  text-align: left;
}

.site-footer__logo img {
  display: block;
  height: auto;
  max-height: var(--t-ftr_logo_h);
  width: auto;
  max-width: 80vw;
  object-fit: contain;
}

html[data-t-ftr_logo_enable="0"] .site-footer__logo {
  display: none;
}

.site-footer__text {
  font-size: var(--t-ftr_text_size);
  line-height: 1.6;
  white-space: pre-line;
}

.site-footer__text:empty {
  display: none;
}

/* ---------- home action buttons ---------- */
.home-actions {
  --btn-w: var(--t-home_btn_w);
  --btn-h: var(--t-home_btn_h);
  --btn-radius: var(--t-home_btn_radius);
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: var(--t-home_btn_gap);
  padding: 16px 0;
}

html[data-t-home_btn_dir="column"] .home-actions {
  flex-direction: column;
}

html[data-t-home_btn_upper="0"] .home-actions .ButtonStyle {
  text-transform: none;
  letter-spacing: .02em;
}

/* ---------- register / login form ---------- */
.tf-reg {
  --f-title-color: var(--t-reg_title_color);
  --f-title-size: var(--t-reg_title_size);
  --f-subtitle-color: var(--t-reg_subtitle_color);
  --f-card-bg: var(--t-reg_card_bg);
  --f-card-border: var(--t-reg_card_border);
  --f-card-border-w: var(--t-reg_card_border_w);
  --f-card-radius: var(--t-reg_card_radius);
  --f-input-bg: var(--t-reg_input_bg);
  --f-input-text: var(--t-reg_input_text);
  --f-input-border: var(--t-reg_input_border);
  --f-input-border-w: var(--t-reg_input_border_w);
  --f-input-radius: var(--t-reg_input_radius);
  --f-input-focus: var(--t-reg_input_focus);
  --f-label-color: var(--t-reg_label_color);
  --f-note-color: var(--t-reg_note_color);
}

.tf-login {
  --f-title-color: var(--t-login_title_color);
  --f-title-size: var(--t-login_title_size);
  --f-subtitle-color: var(--t-login_subtitle_color);
  --f-card-bg: var(--t-login_card_bg);
  --f-card-border: var(--t-login_card_border);
  --f-card-border-w: var(--t-login_card_border_w);
  --f-card-radius: var(--t-login_card_radius);
  --f-input-bg: var(--t-login_input_bg);
  --f-input-text: var(--t-login_input_text);
  --f-input-border: var(--t-login_input_border);
  --f-input-border-w: var(--t-login_input_border_w);
  --f-input-radius: var(--t-login_input_radius);
  --f-input-focus: var(--t-login_input_focus);
  --f-label-color: var(--t-login_label_color);
  --f-note-color: var(--t-login_note_color);
}

.tf {
  width: 100%;
  max-width: 520px;
  margin: 8px auto 0;
}

.tf__title {
  display: block;
  color: var(--f-title-color);
  font-size: clamp(20px, 5.6vw, var(--f-title-size));
  font-weight: 700;
  line-height: 1.3;
  text-align: center;
  margin: 0;
}

.tf__subtitle {
  color: var(--f-subtitle-color);
  text-align: center;
  font-size: 15px;
  margin: 6px 0 0;
}

.tf__subtitle:empty {
  display: none;
}

.tf__card {
  background: var(--f-card-bg);
  border: var(--f-card-border-w) solid var(--f-card-border);
  border-radius: var(--f-card-radius);
  padding: clamp(20px, 5vw, 32px);
  margin-top: 16px;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

html[data-t-reg_card_shadow="1"] .tf-reg .tf__card,
html[data-t-login_card_shadow="1"] .tf-login .tf__card {
  box-shadow: 0 24px 48px -24px rgba(0, 0, 0, .35);
}

.tf .form-control {
  background-color: var(--f-input-bg);
  color: var(--f-input-text);
  border: var(--f-input-border-w) solid var(--f-input-border) !important;
  border-radius: var(--f-input-radius) !important;
  transition: border-color .15s ease, box-shadow .15s ease;
}

.tf .form-control:focus {
  border-color: var(--f-input-focus) !important;
  box-shadow: 0 0 0 4px rgba(0, 0, 0, .06);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--f-input-focus) 20%, transparent);
}

.tf form.was-validated .form-control:invalid {
  border-color: #dc3545 !important;
}

.tf .form-floating > label {
  color: var(--f-label-color);
}

.tf__note {
  display: block;
  color: var(--f-note-color);
  font-size: 14px;
  margin-top: 4px;
}

.tf__note:empty {
  display: none;
}

.tf__actions {
  display: flex;
  justify-content: center;
  margin-top: 24px;
}

.tf__actions .ButtonStyle {
  --btn-w: 100%;
  max-width: 320px;
}

html[data-t-reg_btn_custom="1"] .tf-reg .ButtonStyle {
  --btn-bg1: var(--t-reg_btn_bg1);
  --btn-bg2: var(--t-reg_btn_bg2);
  --btn-text: var(--t-reg_btn_color);
  --btn-hover-text: var(--t-reg_btn_color);
}

html[data-t-login_btn_custom="1"] .tf-login .ButtonStyle {
  --btn-bg1: var(--t-login_btn_bg1);
  --btn-bg2: var(--t-login_btn_bg2);
  --btn-text: var(--t-login_btn_color);
  --btn-hover-text: var(--t-login_btn_color);
}

/* ---------- small screens ---------- */
@media (max-width: 767.98px) {
  .site-topbar__logo {
    max-height: var(--t-hdr_bar_logo_h_m);
  }

  .site-topbar__inner {
    min-height: calc(var(--t-hdr_bar_logo_h_m) + 16px);
  }

  .site-header {
    padding-top: min(var(--t-hdr_space_top), 16px);
  }

  .site-footer__logo img {
    max-height: var(--t-ftr_logo_h_m);
  }

  html[data-t-ftr_layout="split"] .site-footer__inner {
    flex-direction: column;
    text-align: center;
  }

  .home-actions {
    flex-direction: column;
    --btn-h: var(--t-home_btn_h_m);
    gap: var(--t-home_btn_gap_m);
  }

  .home-actions .ButtonStyle {
    width: 100%;
    max-width: var(--t-home_btn_w_m);
  }

  /* register / login submit: the same size as the home buttons on phones */
  .tf__actions .ButtonStyle {
    --btn-h: 46px;
  }
}

/* register form email field (Page Design > ลงทะเบียน > ช่องอีเมล) */

/* fields from the register form builder */
.tf .form-select {
  background-color: var(--f-input-bg);
  color: var(--f-input-text);
  border: var(--f-input-border-w) solid var(--f-input-border) !important;
  border-radius: var(--f-input-radius) !important;
}

.tf .form-select:focus {
  border-color: var(--f-input-focus) !important;
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--f-input-focus) 20%, transparent);
}

.tf .form-check-input:checked {
  background-color: var(--f-input-focus);
  border-color: var(--f-input-focus);
}

.tf .form-check-input:focus {
  border-color: var(--f-input-focus);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--f-input-focus) 20%, transparent);
}

.tf-heading {
  padding-top: 4px;
  border-bottom: 1px solid var(--f-input-border);
  padding-bottom: 6px;
}

.tf-heading strong {
  display: block;
  color: var(--f-title-color);
  font-size: 16px;
}

.tf-heading p {
  color: var(--f-label-color);
  font-size: 14px;
  margin: 2px 0 0;
}

.tf-choice {
  margin: 0;
}

.tf-choice legend {
  color: var(--f-label-color);
  font-size: 15px;
  margin-bottom: 6px;
}

.tf-choice .form-check {
  margin-bottom: 4px;
}

.tf-consent .form-check-label,
.tf-choice .form-check-label {
  color: var(--f-input-text);
  font-size: 14px;
}

.tf-help {
  color: var(--f-label-color);
  font-size: 13px;
  margin-top: 4px;
}

.tf form.was-validated .form-select:invalid,
.tf .form-select.is-invalid {
  border-color: #dc3545 !important;
}

/* wrapper used to switch a whole field off when its condition is not met */
.tf-field {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

/* consent field: link to the T&C text */
.tf-terms-link {
  display: inline;
  margin-left: 4px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--f-input-focus);
  font-size: 13.5px;
  text-decoration: underline;
}

/* ---------- page background (Page Design > พื้นหลัง & Agenda) ---------- */
body {
  background-color: var(--t-bg_color);
  background-repeat: no-repeat;
  background-position: center top;
  background-size: cover;
  background-attachment: fixed;
}

html[data-t-bg_fit="contain"] body {
  background-size: contain;
}

html[data-t-bg_fit="width"] body {
  background-size: 100% auto;
}

html[data-t-bg_pos="center"] body {
  background-position: center center;
}

html[data-t-bg_pos="bottom"] body {
  background-position: center bottom;
}

html[data-t-bg_fixed="0"] body {
  background-attachment: scroll;
}

/* phones: iOS does not support fixed backgrounds */
@media (max-width: 767.98px) {
  body {
    background-attachment: scroll;
  }
}

/* ---------- home: key visual + buttons as one group, centred between the top and the footer ---------- */
.home-page .site-main {
  padding-top: var(--t-home_hero_gap);
  padding-bottom: 24px;
}

html[data-t-home_center="1"] .home-page .site-header {
  margin-top: auto;
}

html[data-t-home_center="1"] .home-page .site-main {
  flex: 0 0 auto;
  margin-bottom: auto;
}

/* ---------- register / login ---------- */
.tf-page .tf__note {
  font-size: 13px;
  margin-top: 10px;
}

.tf__card .tf__actions {
  margin-top: 20px;
}

.tf__card .tf__actions .ButtonStyle {
  --btn-w: 100%;
  max-width: none;
}

/* smaller key visual above the form ("compact", and "split" below 1200px) */
html[data-t-form_layout="compact"] .tf-page .site-hero {
  width: auto;
  max-width: min(100%, var(--t-hdr_hero_w));
  max-height: 260px;
}

@media (max-width: 1199.98px) {
  html[data-t-form_layout="split"] .tf-page .site-hero {
    width: auto;
    max-width: min(100%, var(--t-hdr_hero_w));
    max-height: 260px;
  }
}

@media (max-width: 767.98px) {
  html[data-t-form_layout="compact"] .tf-page .site-hero,
  html[data-t-form_layout="split"] .tf-page .site-hero {
    max-height: 150px;
  }
}

/* "split" on computers: key visual on the left, form on the right, both in the first screen */
@media (min-width: 1200px) {
  html[data-t-form_layout="split"] .tf-page .site-body {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
    grid-template-rows: auto 1fr;
    align-items: center;
    column-gap: 56px;
    width: 100%;
    max-width: 1320px;
    margin: 0 auto;
  }

  html[data-t-form_layout="split"] .tf-page .site-topbar {
    grid-column: 1 / -1;
    grid-row: 1;
  }

  html[data-t-form_layout="split"] .tf-page .site-header {
    grid-column: 1;
    grid-row: 2;
    padding: 32px 0;
  }

  html[data-t-form_layout="split"] .tf-page .site-main {
    grid-column: 2;
    grid-row: 2;
    padding: 32px 0;
  }

  html[data-t-form_layout="split"] .tf-page .site-hero {
    max-width: 100%;
  }

  html[data-t-form_layout="split"] .tf-page .tf {
    margin: 0;
    max-width: 480px;
  }
}

/* ---------- T&C / PDPA notice (App\Support\Terms) ---------- */
.terms-notice {
  font-size: 15px;
  line-height: 1.7;
}

.terms-notice h3 {
  font-size: 1rem;
  font-weight: 700;
  margin: 1.25rem 0 .4rem;
}

.terms-notice ul {
  padding-left: 1.25rem;
  margin-bottom: .75rem;
}

.terms-notice__meta {
  margin-top: 1.5rem;
  font-size: .85rem;
  color: #6b7c79;
}

.tf-marketing {
  margin-top: 12px;
}

/* ---------- viewer popups (Agenda, T&C / PDPA): soft scale-in on computers, bottom sheet on phones ---------- */
.modal-backdrop.show {
  opacity: .45;
}

.site-modal {
  --sm-ease: cubic-bezier(.2, .8, .2, 1);
  transition: opacity .2s linear;
}

.site-modal.show {
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

.site-modal .modal-content {
  border: 0;
  border-radius: 20px;
  box-shadow: 0 24px 64px rgb(0 0 0 / .28);
  overflow: hidden;
}

.site-modal.fade .modal-dialog {
  opacity: 0;
  transform: translateY(16px) scale(.97);
  transition: transform .34s var(--sm-ease), opacity .22s ease;
  will-change: transform, opacity;
}

.site-modal.show .modal-dialog {
  opacity: 1;
  transform: none;
}

.site-modal .modal-header {
  position: relative;
  padding: 16px 20px;
  border-bottom: 1px solid rgb(0 0 0 / .06);
}

.site-modal .modal-title {
  font-weight: 700;
}

.site-modal .modal-body {
  overscroll-behavior: contain;
}

.site-modal .modal-footer {
  border-top: 1px solid rgb(0 0 0 / .06);
}

/* agenda picture: placeholder while it loads, then fades in */
.agenda-pic {
  position: relative;
  min-height: 40vh;
  border-radius: 12px;
  background: linear-gradient(100deg, #eef2f1 40%, #f8faf9 50%, #eef2f1 60%) 0 0 / 200% 100%;
  animation: agenda-shimmer 1.2s linear infinite;
}

.agenda-pic img {
  display: block;
  width: 100%;
  height: auto;
  opacity: 0;
  transition: opacity .35s ease;
}

.agenda-pic.is-loaded {
  min-height: 0;
  background: none;
  animation: none;
}

.agenda-pic.is-loaded img {
  opacity: 1;
}

@keyframes agenda-shimmer {
  to {
    background-position: -200% 0;
  }
}

.agenda-zoom {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  font-size: 14px;
  color: inherit;
  opacity: .75;
}

/* T&C popup: one tap to agree */
.terms-actions {
  display: grid;
  gap: 8px;
  width: 100%;
  justify-items: center;
}

.terms-actions .ButtonStyle {
  --btn-w: 100%;
  max-width: 420px;
}

.terms-decline {
  border: 0;
  background: none;
  color: #6b7c79;
  font-size: 14px;
  text-decoration: underline;
  padding: 6px 12px;
}

@media (max-width: 575.98px) {
  .site-modal .modal-dialog,
  .site-modal .modal-dialog-centered {
    display: flex;
    align-items: flex-end;
    max-width: none;
    min-height: 100%;
    height: 100%;
    margin: 0;
  }

  .site-modal .modal-content {
    max-height: 92dvh;
    border-radius: 20px 20px 0 0;
  }

  .site-modal .modal-dialog-scrollable .modal-content {
    max-height: 92dvh;
  }

  .site-modal.fade .modal-dialog {
    opacity: 1;
    transform: translateY(100%);
    transition: transform .38s var(--sm-ease);
  }

  .site-modal.show .modal-dialog {
    transform: none;
  }

  /* grab handle: drag the top of the sheet down to close */
  .site-modal .modal-header {
    padding-top: 22px;
    touch-action: none;
  }

  .site-modal .modal-header::before {
    content: "";
    position: absolute;
    top: 8px;
    left: 50%;
    width: 40px;
    height: 4px;
    margin-left: -20px;
    border-radius: 2px;
    background: rgb(0 0 0 / .18);
  }

  .site-modal[data-bs-backdrop="static"] .modal-header::before {
    display: none;
  }

  .site-modal .modal-footer {
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
  }
}

@media (prefers-reduced-motion: reduce) {
  .site-modal.fade .modal-dialog {
    transform: none;
    transition: opacity .15s linear;
  }

  .agenda-pic {
    animation: none;
  }
}

/* ---------- base (kept from the old body.css / main.css) ---------- */
body {
  font-family: 'Noto Sans Thai', sans-serif !important;
}

/* larger tick boxes and radio buttons: register form, popups, polls */
input[type="radio"],
input[type="checkbox"] {
  scale: 1.3;
}

.form-floating > .form-select {
  padding-bottom: 5px;
}

/* ---------- register / login: loading layer over the card after submit ---------- */
.tf__card {
  position: relative;
}

.tf-busy {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 16px;
  text-align: center;
  border-radius: inherit;
  background: rgba(255, 255, 255, .78);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  color: var(--f-label-color, #212529);
  animation: tf-busy-in .2s ease both;
}

.tf-busy .spinner-border {
  color: var(--btn-bg1, currentColor);
  margin-bottom: 10px;
}

.tf-busy__text {
  margin: 0;
  font-weight: 600;
  line-height: 1.6;
}

.tf-busy__note {
  margin: 0;
  font-size: .875rem;
  line-height: 1.6;
  opacity: .75;
}

.tf-busy__note:empty {
  display: none;
}

@keyframes tf-busy-in {
  from { opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .tf-busy {
    animation: none;
  }
}

/* ---------- popup buttons (Button Manager type "popup"): picture, text, action button ---------- */
.btn-popup .agenda-pic {
  min-height: 24vh;
}

/* known size: the box already has the picture's shape, so no placeholder height and no jump */
.btn-popup .agenda-pic.has-size,
.btn-popup .agenda-pic.is-loaded {
  min-height: 0;
}

/* ready before the popup opened: no fade */
.agenda-pic.is-instant img {
  transition: none;
}

.btn-popup__text {
  margin: 16px 0 0;
  line-height: 1.7;
  white-space: normal;
}

.btn-popup__actions {
  display: flex;
  justify-content: center;
  margin-top: 18px;
}
