/* ==========================================================================
   X720 Modal System (Login & Register)
   Version: v6.1 (A11y Warning Fix & Class Sync)
   ========================================================================== */

/* --- 0. 基礎設定 --- */
.custom-modal-dialog {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100% !important;
  height: 100%;
  min-height: 100%;
  margin: 0 !important;
  padding: 0 !important;
  max-width: 100% !important;
  pointer-events: none;
}

.custom-modal-content {
  pointer-events: auto;
  border: none;
  box-shadow: none;
  background-color: transparent;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  position: relative;
  background: #ffffff;
  border-radius: 12px;
  margin: auto;
  width: auto;
  overflow: hidden;
}

.close-btn-wrapper {
  display: flex;
  flex-direction: row;
  justify-content: flex-end;
  align-items: center;
  padding: 2px 24px;
  gap: 8px;
  width: 100%;
  height: 28px;
  flex: 0 0 auto;
  order: 0;
  align-self: stretch;
}

.btn-close-custom {
  width: 24px;
  height: 24px;
  background: transparent
    url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%236C757D'%3e%3cpath d='M.293.293a1 1 0 0 1 1.414 0L8 6.586 14.293.293a1 1 0 1 1 1.414 1.414L9.414 8l6.293 6.293a1 1 0 0 1-1.414 1.414L8 9.414l-6.293 6.293a1 1 0 0 1-1.414-1.414L6.586 8 .293 1.707a1 1 0 0 1 0-1.414z'/%3e%3c/svg%3e")
    center/1em auto no-repeat;
  border: 0;
  opacity: 1;
}

/* --- A. 登入視窗 (Login) --- */
.login-main-container {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  flex: none;
  order: 1;
  align-self: stretch;
}

.text-group-wrapper {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  padding: 0px;
  gap: 8px;
  width: 100%;
  flex: none;
  order: 0;
  align-self: stretch;
}

.login-heading {
  font-family: "Segoe UI", sans-serif;
  font-weight: 700;
  color: #343a40;
  margin: 0;
  width: 100%;
}

.login-desc-scroll {
  width: 100%;
  overflow-y: auto;
  padding-right: 5px;
}

.login-desc-text {
  font-family: "Segoe UI", sans-serif;
  font-weight: 350;
  color: #343a40;
  line-height: 160%;
  margin: 0;
}

.login-desc-scroll::-webkit-scrollbar,
.register-scroll-area::-webkit-scrollbar {
  width: 4px;
}
.login-desc-scroll::-webkit-scrollbar-thumb,
.register-scroll-area::-webkit-scrollbar-thumb {
  background-color: #ccc;
  border-radius: 2px;
}

.form-group-wrapper {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 0px;
  gap: 16px;
  width: 100%;
  flex: none;
  order: 1;
  align-self: stretch;
}

.custom-input-group {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  padding: 0;
  position: relative;
  width: 100%;
  isolation: isolate;
}

.input-icon-box {
  position: absolute;
  z-index: 2;
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
  background-color: #4fa8d8;
  -webkit-mask-repeat: no-repeat;
  -webkit-mask-position: center;
  -webkit-mask-size: contain;
  mask-repeat: no-repeat;
  mask-position: center;
  mask-size: contain;
}

.icon-mail {
  -webkit-mask-image: url("../../img/placeholders/icon/all=mail.svg");
  mask-image: url("../../img/placeholders/icon/all=mail.svg");
}
.icon-password {
  -webkit-mask-image: url("../../img/placeholders/icon/all=password.svg");
  mask-image: url("../../img/placeholders/icon/all=password.svg");
}

.custom-input-field {
  box-sizing: border-box;
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
  background: #ffffff;
  border: 1px solid #ced4da;
  border-radius: 8px;
  font-family: "Segoe UI", sans-serif;
  font-weight: 350;
  color: #343a40;
}
.custom-input-field:focus {
  border-color: #4fa8d8;
  outline: none;
}
.custom-input-field::placeholder {
  color: #6c757d;
}

.btn-submit-login {
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: center;
  width: 100%;
  background: #343a40;
  border-radius: 8px;
  border: none;
  color: #ffffff;
  font-family: "Segoe UI";
  font-weight: 400;
  cursor: pointer;
}

.link-wrapper {
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: center;
  padding: 0;
  width: 100%;
}
.create-account-link {
  font-family: "Segoe UI";
  font-weight: 400;
  text-decoration-line: underline;
  color: #343a40;
  cursor: pointer;
}

.btn-social {
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: center;
  width: 100%;
  background: #ffffff;
  border: 1px solid #6c757d;
  box-shadow: 0px 2px 4px rgba(0, 0, 0, 0.25);
  border-radius: 8px;
  color: #343a40;
  font-family: "Segoe UI";
  font-weight: 400;
  cursor: pointer;
}
.btn-social img {
  margin-right: 8px;
}

/* --- B. 註冊視窗 (Register) --- */
.register-content {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.register-header {
  flex: 0 0 auto;
  width: 100%;
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.register-title {
  font-family: "Segoe UI";
  font-weight: 700;
  color: #343a40;
  margin-bottom: 8px;
}

.register-subtitle {
  font-family: "Segoe UI";
  font-weight: 350;
  line-height: 160%;
  color: #343a40;
  margin: 0;
}

.register-scroll-area {
  flex: 1 1 auto;
  width: 100%;
  overflow-y: auto;
  padding-right: 4px;
  scrollbar-width: thin;
  scrollbar-color: #ccc transparent;
}

.register-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.reg-form-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.reg-label {
  font-family: "Segoe UI";
  font-weight: 350;
  color: #ad2d24;
  margin: 0;
}
.reg-form-group:nth-child(7) .reg-label,
.reg-form-group:nth-child(8) .reg-label {
  color: #343a40;
}

.reg-input-wrapper {
  position: relative;
  width: 100%;
}

.reg-input {
  width: 100%;
  height: 42px;
  background: #ffffff;
  border: 1px solid #ced4da;
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 16px;
  color: #343a40;
  font-family: "Segoe UI";
  font-weight: 350;
}
.reg-input::placeholder {
  color: #6c757d;
}
.reg-input:focus {
  border-color: #4fa8d8;
  outline: none;
}

/* 性別選單 */
.gender-group {
  display: flex;
  gap: 16px;
}
.gender-option {
  flex: 1;
  height: 42px;
  background: #efefef;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  position: relative;
  border: 1px solid transparent;
  transition: all 0.2s;
}
.gender-option input {
  display: none;
}
.gender-option span {
  color: #343a40;
  font-size: 16px;
}

.gender-option:has(input:checked) {
  background: #ffffff;
  border: 1px solid #ced4da;
}
/* 對應 HTML 的 class="icon-check-box" */
.icon-check-box {
  width: 20px;
  height: 20px;
  display: none;
  background-color: #ad2d24;
  -webkit-mask: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='currentColor'%3e%3cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M5 13l4 4L19 7'/%3e%3c/svg%3e")
    no-repeat center/contain;
  mask: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='currentColor'%3e%3cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M5 13l4 4L19 7'/%3e%3c/svg%3e")
    no-repeat center/contain;
}
.gender-option:has(input:checked) .icon-check-box {
  display: block;
}

/* 生日 Icon */
.input-suffix-icon {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  background-color: #4fa8d8;
  -webkit-mask-image: url("../../img/placeholders/icon/all=calendar.svg");
  mask-image: url("../../img/placeholders/icon/all=calendar.svg");
  -webkit-mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  pointer-events: none;
}

/* 上傳照片 */
.upload-photo-box {
  width: 100%;
  height: 100px;
  background: #f8f9fa;
  border: 1px dashed #ced4da;
  border-radius: 8px;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  position: relative;
  /* 新增：防止背景圖溢出 */
  overflow: hidden;
}

/* --- 新增：檔名顯示區塊樣式 --- */
.upload-filename-display {
  /* 預設隱藏，有檔案時 JS 會改成 block */
  display: none;

  /* 使用指定的顏色變數 (若變數未定義則使用後備色) */
  background-color: var(--secondary-color-1, #343a40);
  color: var(--color-white, #ffffff);

  padding: 8px 12px;
  border-radius: 8px;
  margin-bottom: 8px; /* 與下方圖片框的間距 */
  font-size: 14px;
  font-family: "Segoe UI", sans-serif;

  /* 防止超長檔名破版 */
  word-break: break-all;
  line-height: 1.4;
}

/* 原有的 upload-photo-box 樣式維持不變，但確保有 overflow: hidden */
.upload-photo-box {
  width: 100%;
  height: 100px;
  background: #f8f9fa;
  border: 1px dashed #ced4da;
  border-radius: 8px;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  position: relative;
  /* 確保背景圖不溢出圓角 */
  overflow: hidden;
}

.upload-icon {
  width: 24px;
  height: 24px;
  background-color: #343a40;
  -webkit-mask: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2'%3e%3crect x='3' y='3' width='18' height='18' rx='2' ry='2'/%3e%3ccircle cx='8.5' cy='8.5' r='1.5'/%3e%3cpolyline points='21 15 16 10 5 21'/%3e%3c/svg%3e")
    no-repeat center/contain;
  mask: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2'%3e%3crect x='3' y='3' width='18' height='18' rx='2' ry='2'/%3e%3ccircle cx='8.5' cy='8.5' r='1.5'/%3e%3cpolyline points='21 15 16 10 5 21'/%3e%3c/svg%3e")
    no-repeat center/contain;
}
.upload-file-input {
  position: absolute;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

/* 條款 Checkbox */
.terms-wrapper {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 8px;
}
.checkbox-container {
  position: relative;
  width: 24px;
  height: 24px;
  flex: 0 0 24px;
}
.checkbox-container input {
  opacity: 0;
  cursor: pointer;
  height: 100%;
  width: 100%;
  position: absolute;
  z-index: 2;
}
.checkmark {
  position: absolute;
  top: 0;
  left: 0;
  height: 24px;
  width: 24px;
  border: 1px solid #343a40;
  border-radius: 4px;
  background: #fff;
  pointer-events: none;
}
.checkbox-container input:checked ~ .checkmark {
  background: #343a40;
}
.checkmark:after {
  content: "";
  position: absolute;
  display: none;
  left: 8px;
  top: 4px;
  width: 6px;
  height: 12px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
.checkbox-container input:checked ~ .checkmark:after {
  display: block;
}

.terms-text {
  font-size: 16px;
  color: #343a40;
  line-height: 1.5;
}
.terms-text a {
  color: #ad2d24;
  text-decoration: underline;
}

.register-footer {
  flex: 0 0 auto;
  padding-top: 16px;
  display: flex;
  gap: 16px;
  width: 100%;
}
.btn-reg-cancel {
  flex: 1;
  height: 45px;
  background: #f8f9fa;
  border-radius: 8px;
  border: none;
  color: #343a40;
  font-size: 18px;
}
.btn-reg-submit {
  flex: 1;
  height: 45px;
  background: #343a40;
  border-radius: 8px;
  border: none;
  color: #ffffff;
  font-size: 18px;
}

/* --- RWD --- */
@media (min-width: 1025px) {
  .custom-modal-content:not(.register-content) {
    width: 488px !important;
    height: 673px;
    padding: 24px 0px 40px;
    gap: 8px;
  }
  .login-main-container {
    padding: 0px 48px;
    gap: 24px;
    height: 573px;
  }
  .text-group-wrapper {
    height: 221px;
  }
  .login-heading {
    font-size: 24px;
    line-height: 130%;
    height: 31px;
  }
  .login-desc-scroll {
    height: 182px;
  }
  .login-desc-text {
    font-size: 16px;
  }
  .form-group-wrapper {
    height: 328px;
  }
  .custom-input-group {
    height: 42px;
  }
  .input-icon-box {
    left: 12px;
  }
  .custom-input-field {
    font-size: 16px;
    padding: 8px 12px 8px 48px;
  }
  .btn-submit-login {
    height: 45px;
    font-size: 18px;
    padding: 8px 40px;
  }
  .link-wrapper {
    height: 29px;
  }
  .create-account-link {
    font-size: 18px;
  }
  .btn-social {
    height: 45px;
    font-size: 18px;
    padding: 8px 40px;
  }
  .btn-social img {
    width: 29px;
    height: 29px;
  }

  .register-content {
    width: 488px !important;
    height: 800px;
    padding: 24px 0 40px 0;
  }
  .register-header,
  .register-scroll-area,
  .register-footer {
    padding-left: 48px;
    padding-right: 48px;
  }
  .register-title {
    font-size: 24px;
  }
  .register-subtitle {
    font-size: 16px;
  }
}

@media (min-width: 768px) and (max-width: 1024px) {
  .custom-modal-content:not(.register-content) {
    width: 488px !important;
    height: 557px;
    padding: 16px 0px 24px;
    gap: 4px;
  }
  .login-main-container {
    padding: 0px 32px;
    gap: 24px;
    height: 485px;
  }
  .text-group-wrapper {
    height: 171px;
  }
  .login-heading {
    font-size: 24px;
    line-height: 130%;
    height: 31px;
  }
  .login-desc-scroll {
    height: 132px;
  }
  .login-desc-text {
    font-size: 14px;
  }
  .form-group-wrapper {
    height: 290px;
  }
  .custom-input-group {
    height: 34px;
  }
  .input-icon-box {
    width: 20px;
    height: 20px;
    left: 12px;
  }
  .custom-input-field {
    font-size: 14px;
    padding: 6px 12px 6px 42px;
  }
  .btn-submit-login {
    height: 38px;
    font-size: 16px;
    padding: 6px 40px;
  }
  .link-wrapper {
    height: 28px;
  }
  .create-account-link {
    font-size: 16px;
  }
  .btn-social {
    height: 38px;
    font-size: 16px;
    padding: 6px 40px;
  }
  .btn-social img {
    width: 24px;
    height: 24px;
  }

  .register-content {
    width: 488px !important;
    height: 788px;
    padding: 16px 0 40px 0;
  }
  .register-header,
  .register-scroll-area,
  .register-footer {
    padding-left: 32px;
    padding-right: 32px;
  }
  .register-title {
    font-size: 24px;
  }
  .register-subtitle {
    font-size: 14px;
  }
  .reg-input {
    height: 34px;
    font-size: 14px;
  }
  .gender-option {
    height: 34px;
  }
  .btn-reg-cancel,
  .btn-reg-submit {
    height: 38px;
    font-size: 16px;
  }
}

@media (max-width: 767px) {
  .custom-modal-content:not(.register-content) {
    width: var(--container-fluid-width, 91.8vw);
    max-width: 360px;
    height: 618px;
    max-height: 95vh;
    padding: 16px 0px 24px;
    gap: 4px;
  }
  .login-main-container {
    flex: 1 1 auto;
    height: auto;
    overflow-y: auto;
    min-height: 0;
    padding: 0px 32px;
    gap: 24px;
    padding-bottom: 20px;
  }
  .text-group-wrapper {
    height: 232px;
    flex: 0 0 auto;
  }
  .login-heading {
    font-size: 20px;
    line-height: 130%;
    height: 26px;
  }
  .login-desc-scroll {
    height: 198px;
  }
  .login-desc-text {
    font-size: 14px;
  }
  .form-group-wrapper {
    height: 290px;
    flex: 0 0 auto;
  }
  .custom-input-group {
    height: 34px;
  }
  .input-icon-box {
    width: 20px;
    height: 20px;
    left: 12px;
  }
  .custom-input-field {
    font-size: 14px;
    padding: 6px 12px 6px 42px;
  }
  .btn-submit-login {
    height: 38px;
    font-size: 16px;
    padding: 6px 40px;
  }
  .link-wrapper {
    height: 28px;
  }
  .create-account-link {
    font-size: 16px;
  }
  .btn-social {
    height: 38px;
    font-size: 16px;
    padding: 6px 40px;
  }
  .btn-social img {
    width: 24px;
    height: 24px;
  }

  .register-content {
    width: var(--container-fluid-width, 91.8vw);
    max-width: 360px;
    height: 788px;
    max-height: 95vh;
    padding: 16px 0 40px 0;
  }
  .register-header,
  .register-scroll-area,
  .register-footer {
    padding-left: 32px;
    padding-right: 32px;
  }
  .register-title {
    font-size: 20px;
  }
  .register-subtitle {
    font-size: 14px;
  }
  .reg-input {
    height: 34px;
    font-size: 14px;
  }
  .gender-option {
    height: 34px;
  }
  .terms-text {
    font-size: 14px;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
  }
  .btn-reg-cancel,
  .btn-reg-submit {
    height: 38px;
    font-size: 16px;
  }
}
