/* ===== Design tokens ===== */
:root {
  --tb-ics-brand: #d70c18;
  --tb-ics-brand-dark: #8a0a12;
  --tb-ics-text: #333;
  --tb-ics-text-secondary: #666;
  --tb-ics-text-muted: #999;
  --tb-ics-text-faint: #b0b0b0;
  --tb-ics-surface: #fff;
  --tb-ics-bg: #f4f4f4;
  --tb-ics-border: #e4e4e4;
  --tb-ics-divider: #f0f0f0;
  --tb-ics-scroll-thumb: #d0d0d0;
}

/* ===== Reset (minimal) ===== */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}

ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

input {
  font: inherit;
}

/* ===== Page canvas ===== */
.taishinbank-page {
  min-height: 100vh;
  background: #e9ebee;
  font-family: "PingFang TC", "Microsoft JhengHei", "Helvetica Neue", Arial, sans-serif;
  color: var(--tb-ics-text);
  margin: 0;
}

/* ===== Floating action button ===== */
.taishinbank-ics-fab {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--tb-ics-brand);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 100;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.taishinbank-ics-fab:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.3);
}

.taishinbank-ics-fab:active {
  transform: translateY(0);
}

.taishinbank-ics-fab[hidden] {
  display: none;
}

.taishinbank-ics-fab img {
  width: 38px;
  height: 38px;
  display: block;
  border-radius: 50%;
  background: var(--tb-ics-surface);
}

/* ===== Root frame (floating widget) ===== */
.taishinbank-ics {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 410px;
  height: 720px;
  background: var(--tb-ics-bg);
  overflow: hidden;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.22);
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  font-size: 16px;
  z-index: 99;
}

.taishinbank-ics[hidden] {
  display: none;
}

@media (max-height: 760px) {
  .taishinbank-ics {
    height: calc(100vh - 32px);
    bottom: 16px;
  }
}

@media (max-width: 480px) {
  .taishinbank-ics {
    inset: 0;
    width: 100%;
    height: 100%;
    height: 100dvh;
    border-radius: 0;
    box-shadow: none;
  }
}

.taishinbank-ics--fullscreen {
  position: fixed;
  inset: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
  border-radius: 0;
  box-shadow: none;
}

.taishinbank-ics--fullscreen #taishinbank-ics-btn-minimize {
  display: none;
}

.taishinbank-ics--size-small {
  font-size: 14px;
}

.taishinbank-ics--size-medium {
  font-size: 16px;
}

.taishinbank-ics--size-large {
  font-size: 18px;
}

/* ===== Header ===== */
.taishinbank-ics-header {
  flex: 0 0 auto;
  height: 56px;
  background: var(--tb-ics-brand);
  color: var(--tb-ics-surface);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  position: relative;
  z-index: 5;
}

.taishinbank-ics-header__title {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 1px;
}

.taishinbank-ics-header__actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.taishinbank-ics-header__icon-btn {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.taishinbank-ics-header__icon-btn img {
  display: block;
  height: 18px;
  width: auto;
}

#taishinbank-ics-btn-more img {
  height: 20px;
}

#taishinbank-ics-btn-minimize img {
  height: 14px;
  filter: brightness(0) invert(1);
}

/* ===== Chat ===== */
.taishinbank-ics-chat {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 16px 14px 14px;
  background: var(--tb-ics-bg);
}

.taishinbank-ics-chat__list {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.taishinbank-ics-chat__row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.taishinbank-ics-chat__row--user {
  flex-direction: row-reverse;
}

.taishinbank-ics-chat__avatar {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--tb-ics-surface);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.taishinbank-ics-chat__avatar img {
  width: 100%;
  height: 100%;
  display: block;
}

.taishinbank-ics-chat__bubble-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 305px;
}

.taishinbank-ics-chat__row--user .taishinbank-ics-chat__bubble-group {
  align-items: flex-end;
}

.taishinbank-ics-chat__bubble {
  background: var(--tb-ics-surface);
  border-radius: 14px;
  padding: 12px 14px;
  font-size: 0.95em;
  line-height: 1.55;
  color: var(--tb-ics-text);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  word-break: break-word;
}

.taishinbank-ics-chat__row--user .taishinbank-ics-chat__bubble {
  background: var(--tb-ics-brand);
  color: var(--tb-ics-surface);
}

/* ===== Typing indicator ===== */
.taishinbank-ics-chat__bubble--loading {
  padding: 12px 14px;
  display: inline-flex;
  align-items: center;
}

.taishinbank-ics-typing {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 12px;
}

.taishinbank-ics-typing__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #c0c0c0;
  animation: taishinbank-ics-typing-bounce 1.2s ease-in-out infinite;
}

.taishinbank-ics-typing__dot:nth-child(2) {
  animation-delay: 0.15s;
}

.taishinbank-ics-typing__dot:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes taishinbank-ics-typing-bounce {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: 0.4;
  }
  30% {
    transform: translateY(-4px);
    opacity: 1;
  }
}

.taishinbank-ics-chat__time {
  font-size: 0.78em;
  line-height: 1;
  color: var(--tb-ics-text-faint);
}

/* ===== Feedback ===== */
.taishinbank-ics-feedback {
  display: flex;
  align-items: center;
  gap: 14px;
}

.taishinbank-ics-feedback__btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.85em;
  line-height: 1;
  color: var(--tb-ics-text-muted);
  opacity: 0.5;
  transition: opacity 0.15s ease;
}

.taishinbank-ics-feedback__btn img {
  width: 16px;
  height: 16px;
  display: block;
}

.taishinbank-ics-feedback__btn--helpful {
  color: var(--tb-ics-brand);
  font-weight: 700;
}

.taishinbank-ics-feedback__btn--not-helpful {
  color: #555;
  font-weight: 700;
}

.taishinbank-ics-feedback__btn--selected {
  opacity: 1;
}

.taishinbank-ics-feedback__thankyou {
	color: var(--tb-ics-brand);
}

/* ===== Hyperlink-style text ===== */
.taishinbank-ics-link {
  color: var(--tb-ics-brand);
  text-decoration: underline;
  font-weight: 700;
}

/* ===== Input area ===== */
.taishinbank-ics-input {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px 16px;
  background: var(--tb-ics-surface);
}

.taishinbank-ics-input__field {
  flex: 1 1 auto;
  height: 42px;
  border-radius: 22px;
  border: 1px solid var(--tb-ics-border);
  background: var(--tb-ics-surface);
  padding: 0 16px;
  font-size: 0.92em;
  color: var(--tb-ics-text);
  outline: none;
  box-shadow: inset 0 3px 6px rgba(0, 0, 0, 0.18);
}

.taishinbank-ics-input__field::placeholder {
  color: #b8b8b8;
}

.taishinbank-ics-input__field:focus {
  border-color: var(--tb-ics-brand);
}

.taishinbank-ics-input__send {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.taishinbank-ics-input__send img {
  width: 32px;
  height: 32px;
  display: block;
}

/* ===== Dropdown (font size & more) ===== */
.taishinbank-ics-dropdown {
  position: absolute;
  top: 50px;
  z-index: 20;
}

.taishinbank-ics-dropdown[hidden] {
  display: none;
}

.taishinbank-ics-dropdown--font-size {
  right: 88px;
}

.taishinbank-ics-dropdown--more {
  right: 54px;
}

/* Fullscreen 隱藏了 minimize 鈕（寬 32 + gap 10 = 42px），dropdown 需同步左移 */
.taishinbank-ics--fullscreen .taishinbank-ics-dropdown--font-size {
  right: 46px;
}

.taishinbank-ics--fullscreen .taishinbank-ics-dropdown--more {
  right: 12px;
}

.taishinbank-ics-dropdown__panel {
  background: var(--tb-ics-surface);
  border-radius: 10px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18);
  min-width: 140px;
  padding: 8px 12px 10px;
  position: relative;
}

.taishinbank-ics-dropdown--font-size .taishinbank-ics-dropdown__panel {
  min-width: 200px;
  padding: 10px 16px 14px;
}

.taishinbank-ics-dropdown--font-size .taishinbank-ics-dropdown__panel::before,
.taishinbank-ics-dropdown--more .taishinbank-ics-dropdown__panel::before {
  content: "";
  position: absolute;
  top: -5px;
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-bottom: 5px solid var(--tb-ics-surface);
}

.taishinbank-ics-dropdown--font-size .taishinbank-ics-dropdown__panel::before {
  right: 18px;
}

.taishinbank-ics-dropdown--more .taishinbank-ics-dropdown__panel::before {
  right: 12px;
}

.taishinbank-ics-dropdown__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.taishinbank-ics-dropdown--font-size .taishinbank-ics-dropdown__header {
  border-bottom: 1px solid #ececec;
  padding-bottom: 6px;
  margin-bottom: 10px;
}

.taishinbank-ics-dropdown__title {
  font-size: 0.95em;
  color: #555;
  font-weight: 600;
}

.taishinbank-ics-dropdown__close {
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.taishinbank-ics-dropdown__close img {
  width: 12px;
  height: 12px;
  display: block;
}

/* font size options */
.taishinbank-ics-font-options {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 6px 2px;
}

.taishinbank-ics-font-options__btn {
  background: var(--tb-ics-brand);
  color: var(--tb-ics-surface);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  line-height: 1;
  position: relative;
  flex: 0 0 auto;
  padding: 0;
}

.taishinbank-ics-font-options__btn img {
  display: none;
}

.taishinbank-ics-font-options__btn span {
  display: inline-block;
}

.taishinbank-ics-font-options__btn[data-font-size="small"] {
  width: 22px;
  height: 22px;
  border-radius: 4px;
}

.taishinbank-ics-font-options__btn[data-font-size="small"] span {
  font-size: 12px;
}

.taishinbank-ics-font-options__btn[data-font-size="medium"] {
  width: 26px;
  height: 26px;
  border-radius: 5px;
}

.taishinbank-ics-font-options__btn[data-font-size="medium"] span {
  font-size: 15px;
}

.taishinbank-ics-font-options__btn[data-font-size="large"] {
  width: 30px;
  height: 30px;
  border-radius: 6px;
}

.taishinbank-ics-font-options__btn[data-font-size="large"] span {
  font-size: 18px;
}

.taishinbank-ics-font-options__btn--selected {
  outline: 2px solid var(--tb-ics-brand-dark);
  outline-offset: 1px;
}

/* more dropdown options */
.taishinbank-ics-dropdown--more .taishinbank-ics-dropdown__panel {
  min-width: 200px;
  padding: 10px 12px 12px;
}

.taishinbank-ics-dropdown__option {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 4px;
  border-bottom: 1px solid var(--tb-ics-divider);
  color: var(--tb-ics-brand);
  font-size: 0.95em;
  font-weight: 700;
  text-align: left;
}

.taishinbank-ics-dropdown__option:last-of-type {
  border-bottom: none;
}

.taishinbank-ics-dropdown__option-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.taishinbank-ics-dropdown__option-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  color: var(--tb-ics-brand);
}

.taishinbank-ics-dropdown__option-icon svg,
.taishinbank-ics-dropdown__option-icon img {
  display: block;
  width: 16px;
  height: 16px;
}

.taishinbank-ics-dropdown__option--expanded .taishinbank-ics-dropdown__option-icon {
  color: var(--tb-ics-text);
}

.taishinbank-ics-dropdown__expand {
  color: var(--tb-ics-text-muted);
  font-size: 1.2em;
  font-weight: 400;
  line-height: 1;
  width: 16px;
  text-align: center;
}

.taishinbank-ics-dropdown__sublist {
  border-bottom: 1px solid var(--tb-ics-divider);
  padding: 4px 0 8px;
  margin-bottom: 4px;
}

.taishinbank-ics-dropdown__sublist[hidden] {
  display: none;
}

.taishinbank-ics-dropdown__subitem {
  width: 100%;
  text-align: left;
  padding: 6px 4px 6px 32px;
  color: var(--tb-ics-brand);
  font-size: 0.9em;
  font-weight: 500;
}

/* ===== Modal (shared) ===== */
.taishinbank-ics-modal {
  position: absolute;
  inset: 0;
  z-index: 50;
  display: none;
}

.taishinbank-ics-modal--open,
.taishinbank-ics-modal:not([hidden]) {
  display: block;
}

.taishinbank-ics-modal[hidden] {
  display: none;
}

.taishinbank-ics-modal__overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
}

.taishinbank-ics-modal__sheet {
  position: absolute;
  inset: 72px 0 0 0; /* leave header + gap visible */
  background: rgba(255, 255, 255, 0.96);
  padding: 40px 14px 32px;
  overflow: hidden;
  border-top-left-radius: 16px;
  border-top-right-radius: 16px;
  display: flex;
  flex-direction: column;
}

.taishinbank-ics-modal__close {
  position: absolute;
  top: 12px;
  right: 14px;
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
}

.taishinbank-ics-modal__close img {
  width: 14px;
  height: 14px;
  display: block;
}

.taishinbank-ics-modal__title {
  margin: 0 0 18px;
  text-align: center;
  font-size: 1.05em;
  color: var(--tb-ics-brand);
  font-weight: 700;
}

.taishinbank-ics-modal__section {
  margin-bottom: 28px;
}

.taishinbank-ics-modal__section:last-child {
  margin-bottom: 0;
}

.taishinbank-ics-modal__section-title {
  text-align: center;
  font-size: 1em;
  color: var(--tb-ics-text);
  font-weight: 700;
  margin: 0 0 14px;
}

.taishinbank-ics-modal__paragraph {
  font-size: 0.875em;
  line-height: 1.7;
  color: var(--tb-ics-text-secondary);
  margin: 0 0 14px;
  text-align: justify;
}

.taishinbank-ics-modal__paragraph:last-child {
  margin-bottom: 0;
}

/* ===== Scrollable body (shared) ===== */
.taishinbank-ics-modal--declarations .taishinbank-ics-modal__body,
.taishinbank-ics-modal--notes .taishinbank-ics-modal__body,
.taishinbank-ics-modal__card-body {
  scrollbar-width: thin;
  scrollbar-color: var(--tb-ics-scroll-thumb) transparent;
  scrollbar-gutter: stable;
}

.taishinbank-ics-modal--declarations .taishinbank-ics-modal__body::-webkit-scrollbar-track,
.taishinbank-ics-modal--notes .taishinbank-ics-modal__body::-webkit-scrollbar-track,
.taishinbank-ics-modal__card-body::-webkit-scrollbar-track {
  background: transparent;
}

.taishinbank-ics-modal--declarations .taishinbank-ics-modal__body::-webkit-scrollbar-thumb,
.taishinbank-ics-modal--notes .taishinbank-ics-modal__body::-webkit-scrollbar-thumb,
.taishinbank-ics-modal__card-body::-webkit-scrollbar-thumb {
  background: var(--tb-ics-scroll-thumb);
  border-radius: 999px;
}

.taishinbank-ics-modal--declarations .taishinbank-ics-modal__body,
.taishinbank-ics-modal--notes .taishinbank-ics-modal__body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: scroll;
  padding: 0 22px;
}

.taishinbank-ics-modal--declarations .taishinbank-ics-modal__body::-webkit-scrollbar,
.taishinbank-ics-modal--notes .taishinbank-ics-modal__body::-webkit-scrollbar {
  width: 3px;
}

.taishinbank-ics-modal__body--notes {
  padding-top: 4px;
}

/* ===== Consent modal specific ===== */
.taishinbank-ics-modal--consent .taishinbank-ics-modal__sheet {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 20px 20px;
}

.taishinbank-ics-modal__lead {
  color: var(--tb-ics-brand);
  font-weight: 700;
  text-align: center;
  font-size: 0.95em;
  line-height: 1.6;
  margin: 0 0 14px;
}

.taishinbank-ics-modal__card {
  width: 100%;
  flex: 1 1 auto;
  background: var(--tb-ics-surface);
  border: 1px solid var(--tb-ics-border);
  border-radius: 6px;
  padding: 14px 4px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.taishinbank-ics-modal__card-title {
  text-align: center;
  margin: 0 0 10px;
  font-size: 1em;
  color: #222;
  font-weight: 700;
}

.taishinbank-ics-modal__card-body {
  flex: 1 1 auto;
  overflow-y: scroll;
  font-size: 0.88em;
  line-height: 1.7;
  color: #555;
  text-align: justify;
  padding: 0 24px 0 20px;
}

.taishinbank-ics-modal__card-body::-webkit-scrollbar {
  width: 4px;
}

.taishinbank-ics-modal__card-body::-webkit-scrollbar-track {
  margin: 2px 0;
}

.taishinbank-ics-modal__card-body::-webkit-scrollbar-thumb:hover {
  background: #b5b5b5;
}

.taishinbank-ics-modal__action {
  margin-top: 14px;
}

.taishinbank-ics-modal__confirm-btn {
  background: var(--tb-ics-brand);
  color: var(--tb-ics-surface);
  border-radius: 999px;
  padding: 7px 42px;
  font-size: 0.95em;
  font-weight: 700;
}

.taishinbank-ics-modal__confirm-btn:active {
  transform: translateY(1px);
}

/* ===== Notes modal specific ===== */
.taishinbank-ics-notes__hours {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  margin-bottom: 20px;
  padding: 0 8px;
}

.taishinbank-ics-notes__hours-item {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  column-gap: 6px;
  row-gap: 4px;
  align-items: center;
  flex: 1 1 0;
}

.taishinbank-ics-notes__hours-icon {
  grid-row: 1 / span 2;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  overflow: hidden;
  border: 1px solid #ddd;
  background: var(--tb-ics-surface);
  display: flex;
  align-items: center;
  justify-content: center;
}

.taishinbank-ics-notes__hours-icon img,
.taishinbank-ics-notes__hours-icon svg {
  width: 100%;
  height: 100%;
  display: block;
}

.taishinbank-ics-notes__hours-label {
  grid-column: 2;
  grid-row: 1;
  font-size: 0.9em;
  color: #222;
  font-weight: 700;
  line-height: 1.2;
  align-self: end;
}

.taishinbank-ics-notes__hours-badge {
  grid-column: 2;
  grid-row: 2;
  font-size: 0.6em;
  color: var(--tb-ics-brand);
  border: 1px solid var(--tb-ics-brand);
  border-radius: 999px;
  padding: 2px 8px;
  white-space: nowrap;
  justify-self: start;
  align-self: start;
}

@media (max-width: 414px) {
  .taishinbank-ics-notes__hours-label {
    font-size: 0.75em;
  }
}
