/* ==========================================================================
   Công cụ tính hoa hồng đại lý — dựng theo Figma "Untitled"
   PC : node 1:72  (frame 1920, vùng nội dung 1318)
   MB : node 1:228 (frame 375,  vùng nội dung 323)

   --cc-u = 1px trong Figma. Trên PC giá trị này được suy ra từ bề rộng thật
   của khối (container query) nên toàn bộ khoảng cách / cỡ chữ giữ đúng tỷ lệ
   với bản thiết kế ở mọi bề rộng.
   ========================================================================== */

.expandable-panel-wrapper.cc-figma {
  --cc-u: 0.8px;
  --cc-blue: #0e7ded;
  --cc-blue-deep: #005bc3;
  --cc-orange: #c86605;
  --cc-chip-bg: #bde7fd;
  --cc-chip-border: #eaf6e9;
  --cc-mb-blue: #118acb;

  container-type: inline-size;
  margin: 20px 0 28px;
  overflow: visible;
  color: var(--cc-blue) !important;
  font-family: Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* Không phụ thuộc reset của trang: mọi kích thước dưới đây tính theo border box */
.expandable-panel-wrapper.cc-figma,
.expandable-panel-wrapper.cc-figma *,
.expandable-panel-wrapper.cc-figma *::before,
.expandable-panel-wrapper.cc-figma *::after {
  box-sizing: border-box;
}

@supports (width: 1cqw) {
  /* 100 / 1318 = bề rộng 1px Figma quy ra % bề rộng khối */
  .expandable-panel-wrapper.cc-figma > * {
    --cc-u: 0.0758725cqw;
  }
}

/* ---------- Tab tiêu đề ---------- */

.cc-figma .expandable-panel-header {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: none;
  box-shadow: none;
  overflow: visible;
}

.cc-figma .expandable-panel-title {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: calc(860 * var(--cc-u));
  aspect-ratio: 748 / 51;
  background: none;
  overflow: hidden;
}

/* Hai ảnh preload 1 lần, fade qua lại — không fetch lại */
.cc-figma .cc-tab-slide {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: fill;
  pointer-events: none;
  user-select: none;
}

.cc-figma .cc-tab-slide.is-a {
  opacity: 1;
  animation: cc-tab-fade-out 0.5s ease-in-out infinite;
}

.cc-figma .cc-tab-slide.is-b {
  opacity: 0;
  animation: cc-tab-fade-in 0.5s ease-in-out infinite;
}

@keyframes cc-tab-fade-out {
  0%,
  42% {
    opacity: 1;
  }
  50%,
  92% {
    opacity: 0;
  }
  100% {
    opacity: 1;
  }
}

@keyframes cc-tab-fade-in {
  0%,
  42% {
    opacity: 0;
  }
  50%,
  92% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .cc-figma .cc-tab-slide.is-a,
  .cc-figma .cc-tab-slide.is-b {
    animation: none;
  }

  .cc-figma .cc-tab-slide.is-b {
    display: none;
  }
}

.cc-figma .panel-icon {
  display: none;
}

/* Chữ đã nằm trong ảnh tab — giữ text cho screen reader */
.cc-figma .panel-title-text {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Bản PC: mũi tên không có trong thiết kế, cả dải banner là vùng bấm */
.cc-figma .expandable-panel-arrow {
  display: none;
  position: absolute;
  top: 50%;
  right: calc(18 * var(--cc-u));
  width: calc(20 * var(--cc-u));
  height: calc(20 * var(--cc-u));
  transform: translateY(-50%);
  transition: transform 0.3s ease;
}

.cc-figma .expandable-panel-arrow svg {
  display: block;
  width: 100%;
  height: 100%;
}

.cc-figma .expandable-panel-header.active .expandable-panel-arrow {
  transform: translateY(-50%) rotate(180deg);
}

.cc-figma .expandable-panel-content.active {
  max-height: none;
  overflow: visible;
}

.cc-figma .expandable-panel-body {
  margin-top: calc(39 * var(--cc-u));
  padding: 0;
  background: transparent;
  color: inherit;
}

/* ---------- Khung trắng ---------- */

.cc-figma .cc-shell {
  position: relative;
  width: 100%;
  padding: calc(15 * var(--cc-u)) calc(20 * var(--cc-u)) calc(33 * var(--cc-u));
  border-radius: calc(20 * var(--cc-u));
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 calc(5 * var(--cc-u)) calc(10 * var(--cc-u)) calc(6 * var(--cc-u)) rgba(0, 92, 203, 0.2);
  overflow: hidden;
}

/* ---------- Tiêu đề từng phần ---------- */

.cc-figma .cc-section-head {
  display: flex;
  align-items: center;
  gap: calc(11 * var(--cc-u));
  margin: 0 calc(9 * var(--cc-u)) calc(19 * var(--cc-u));
}

.cc-figma .cc-results-block .cc-section-head {
  margin-top: calc(25 * var(--cc-u));
  margin-bottom: calc(16 * var(--cc-u));
}

.cc-figma .cc-section-title {
  display: inline-flex;
  align-items: center;
  gap: calc(11 * var(--cc-u));
  margin: 0;
  font-family: inherit;
  font-size: calc(32 * var(--cc-u));
  font-weight: 700;
  line-height: 1.18;
  text-transform: uppercase;
  color: var(--cc-blue);
  white-space: nowrap;
}

.cc-figma .cc-section-title img {
  width: calc(39 * var(--cc-u));
  height: calc(50 * var(--cc-u));
  object-fit: contain;
}

.cc-figma .cc-section-title.is-results {
  text-decoration: underline;
  text-underline-offset: calc(4 * var(--cc-u));
}

.cc-figma .cc-chip {
  display: inline-flex;
  align-items: center;
  min-height: calc(38 * var(--cc-u));
  padding: calc(7 * var(--cc-u)) calc(13 * var(--cc-u));
  border: calc(1.4 * var(--cc-u)) solid var(--cc-chip-border);
  border-radius: calc(20 * var(--cc-u));
  background: var(--cc-chip-bg);
  box-shadow: none;
  color: var(--cc-blue);
  font-size: calc(20.8 * var(--cc-u));
  font-weight: 500;
  line-height: 1.15;
  white-space: nowrap;
}

/* ---------- Hai hộp nhập liệu ---------- */

.cc-figma .cc-input-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: calc(14 * var(--cc-u));
}

.cc-figma .cc-box {
  position: relative;
  display: flex;
  flex-direction: column;
  aspect-ratio: 632 / 327;
  min-height: 0;
  padding: calc(52 * var(--cc-u)) 0 0;
  border-radius: 0;
  background: url("../images/commission/box-frame.png") center / 100% 100% no-repeat;
  overflow: visible;
}

/* Tiêu đề + nhãn phụ đặt theo đúng toạ độ trên dải xanh của khung */
.cc-figma .cc-box-header {
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  height: calc(52 * var(--cc-u));
}

.cc-figma .cc-box-title {
  position: absolute;
  top: calc(14 * var(--cc-u));
  left: calc(29 * var(--cc-u));
  margin: 0;
  font-family: inherit;
  font-size: calc(32 * var(--cc-u));
  font-weight: 900;
  line-height: 1.18;
  text-transform: uppercase;
  color: #fff;
  text-shadow: 0 calc(4 * var(--cc-u)) calc(4 * var(--cc-u)) #015ece;
  white-space: nowrap;
}

.cc-figma .cc-box-chip {
  position: absolute;
  top: calc(18 * var(--cc-u));
  left: calc(222 * var(--cc-u));
  display: inline-flex;
  align-items: center;
  min-height: calc(30 * var(--cc-u));
  padding: calc(4 * var(--cc-u)) calc(18 * var(--cc-u));
  border: calc(1.4 * var(--cc-u)) solid var(--cc-chip-border);
  border-radius: calc(20 * var(--cc-u));
  background: var(--cc-chip-bg);
  color: var(--cc-blue);
  font-size: calc(18 * var(--cc-u));
  font-weight: 500;
  line-height: 1.15;
  white-space: nowrap;
}

.cc-figma .cc-box-deco {
  position: absolute;
  top: calc(-28 * var(--cc-u));
  right: calc(47 * var(--cc-u));
  width: calc(140 * var(--cc-u));
  height: calc(86 * var(--cc-u));
  object-fit: contain;
  pointer-events: none;
}

.cc-figma .cc-box-members .cc-box-deco {
  right: calc(30 * var(--cc-u));
  width: calc(185 * var(--cc-u));
}

.cc-figma .cc-box-members .cc-box-title {
  left: calc(20 * var(--cc-u));
}

.cc-figma .cc-box-members .cc-box-chip {
  left: calc(223 * var(--cc-u));
}

.cc-figma .cc-box-rows {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: calc(42 * var(--cc-u));
  padding: 0 calc(80 * var(--cc-u)) 0 calc(64 * var(--cc-u));
}

.cc-figma .cc-box-members .cc-box-rows {
  padding-right: calc(48 * var(--cc-u));
  padding-left: calc(65 * var(--cc-u));
}

.cc-figma .cc-row {
  display: grid;
  grid-template-columns: calc(40 * var(--cc-u)) minmax(0, 1fr) calc(180 * var(--cc-u));
  align-items: center;
  column-gap: calc(24 * var(--cc-u));
  margin: 0;
}

.cc-figma .cc-row-icon {
  width: calc(40 * var(--cc-u));
  height: calc(40 * var(--cc-u));
  object-fit: contain;
}

.cc-figma .cc-row-label {
  display: inline-flex;
  align-items: center;
  gap: calc(4 * var(--cc-u));
  font-family: inherit;
  font-size: calc(20 * var(--cc-u));
  font-weight: 500;
  line-height: 1.15;
  color: var(--cc-blue);
  white-space: nowrap;
}

.cc-figma .cc-info {
  flex-shrink: 0;
  width: calc(17 * var(--cc-u));
  height: calc(17 * var(--cc-u));
  object-fit: contain;
}

/* ---------- Ô nhập kèm nút ± ---------- */

.cc-figma .cc-stepper {
  display: grid;
  grid-template-columns: calc(32 * var(--cc-u)) minmax(0, 1fr) calc(32 * var(--cc-u));
  align-items: center;
  height: calc(40 * var(--cc-u));
  border: calc(2 * var(--cc-u)) solid var(--cc-blue);
  border-radius: calc(15 * var(--cc-u));
  background: #fff;
  overflow: hidden;
}

.cc-figma .cc-stepper button {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--cc-blue);
  font-family: inherit;
  font-size: calc(22 * var(--cc-u));
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
}

.cc-figma .cc-stepper button:hover {
  color: var(--cc-blue-deep);
}

.cc-figma .cc-stepper input {
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  text-align: center;
  font-family: inherit;
  font-size: calc(20 * var(--cc-u));
  font-weight: 500;
  color: var(--cc-blue);
  -moz-appearance: textfield;
  appearance: textfield;
}

.cc-figma .cc-stepper input:focus {
  outline: none;
  border: 0;
  box-shadow: none;
}

.cc-figma .cc-stepper input::-webkit-outer-spin-button,
.cc-figma .cc-stepper input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* Trạng thái lỗi do validate (vd: thành viên mới hợp lệ ≥ thành viên hợp lệ) */
.cc-figma .cc-stepper input.error {
  color: #dc3545;
}

.cc-figma .cc-stepper:has(input.error) {
  border-color: #dc3545;
  background: #fff5f5;
}

/* ---------- Ba thẻ kết quả ---------- */

.cc-figma .result-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: calc(10 * var(--cc-u));
  margin: 0 calc(9 * var(--cc-u));
}

.cc-figma .result-card {
  position: relative;
  display: block;
  aspect-ratio: 414 / 137;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: url("../images/commission/card-frame-blue.png") center / 100% 100% no-repeat;
  box-shadow: none;
  transition: none;
}

.cc-figma .result-card:hover {
  transform: none;
  box-shadow: none;
}

.cc-figma .result-card.is-platform {
  background-image: url("../images/commission/card-frame-orange.png");
}

.cc-figma .result-card.is-rate {
  background-image: url("../images/commission/card-frame-cyan.png");
}

.cc-figma .result-card-icon {
  position: absolute;
  top: calc(-8 * var(--cc-u));
  left: calc(10 * var(--cc-u));
  width: calc(156 * var(--cc-u));
  height: calc(153 * var(--cc-u));
  pointer-events: none;
}

.cc-figma .result-card-icon img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.cc-figma .result-card.is-profit .result-card-icon {
  top: calc(-10 * var(--cc-u));
  left: calc(6 * var(--cc-u));
  width: calc(158 * var(--cc-u));
  height: calc(155 * var(--cc-u));
}

.cc-figma .result-card.is-rate .result-card-icon {
  top: 0;
  left: calc(19 * var(--cc-u));
  width: calc(139 * var(--cc-u));
  height: calc(137 * var(--cc-u));
}

.cc-figma .result-card-content {
  position: absolute;
  top: calc(28 * var(--cc-u));
  left: calc(168 * var(--cc-u));
  display: block;
  width: calc(230 * var(--cc-u));
  gap: 0;
  text-align: center;
}

.cc-figma .result-card-title {
  margin: 0 0 calc(4 * var(--cc-u));
  font-family: inherit;
  font-size: calc(20 * var(--cc-u));
  font-weight: 700;
  line-height: 1.17;
  text-transform: uppercase;
  text-align: center;
  white-space: nowrap;
  color: var(--cc-blue);
}

.cc-figma .result-card.is-platform .result-card-title {
  color: var(--cc-orange);
}

.cc-figma .result-value-pill {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: calc(48 * var(--cc-u));
  height: auto;
  padding: calc(6 * var(--cc-u)) calc(10 * var(--cc-u));
  border: 0;
  border-radius: calc(50 * var(--cc-u));
  background: rgba(255, 255, 255, 0.8);
  box-shadow: none;
  box-sizing: border-box;
}

.cc-figma .result-card-value {
  margin: 0;
  font-family: inherit;
  font-size: calc(18 * var(--cc-u));
  font-weight: 700;
  line-height: 1.2;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--cc-blue) !important;
}

.cc-figma .result-card.is-platform .result-card-value {
  color: var(--cc-orange) !important;
}

/* ---------- Banner tổng hoa hồng ---------- */

.cc-figma .total-commission-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: calc(10 * var(--cc-u));
  height: calc(108 * var(--cc-u));
  margin: calc(20 * var(--cc-u)) calc(9 * var(--cc-u)) 0;
  padding: 0 calc(20 * var(--cc-u));
  border: calc(1 * var(--cc-u)) solid #fff;
  border-radius: calc(30 * var(--cc-u));
  background: linear-gradient(rgba(203, 234, 253, 0.5), rgba(203, 234, 253, 0.5)),
    url("../images/commission/total-banner-bg.png") center / cover no-repeat;
  box-shadow: 0 calc(4 * var(--cc-u)) calc(4 * var(--cc-u)) rgba(1, 96, 208, 0.3),
    inset calc(2 * var(--cc-u)) calc(-2 * var(--cc-u)) calc(5 * var(--cc-u)) rgba(1, 101, 209, 0.3);
}

.cc-figma .total-commission-label,
.cc-figma .total-commission-value,
.cc-figma .total-commission-currency {
  font-family: inherit;
  font-size: calc(32 * var(--cc-u));
  font-weight: 700;
  line-height: 1.18;
  text-transform: uppercase;
  color: var(--cc-blue);
  white-space: nowrap;
}

/* ==========================================================================
   MB — Figma node 1:228
   ========================================================================== */

@media (max-width: 768px) {
  .expandable-panel-wrapper.cc-figma,
  .expandable-panel-wrapper.cc-figma > * {
    --cc-u: 1px;
  }

  .expandable-panel-wrapper.cc-figma {
    margin: 12px 0;
  }

  /* Bỏ khung xanh .title-item — banner là 1 khối full width */
  .title-item:has(.expandable-panel-wrapper.cc-figma) {
    background: transparent !important;
    padding: 0 !important;
    border-radius: 0 !important;
  }

  .cc-figma .expandable-panel-header,
  .cc-figma .expandable-panel-header.active {
    display: block;
    width: 100%;
    padding: 0 !important;
    margin: 0;
    background: transparent !important;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .cc-figma .expandable-panel-title {
    max-width: none;
    width: 100%;
    aspect-ratio: 488 / 69;
    min-height: 0;
    padding: 0;
    border-radius: 10px;
    overflow: hidden;
    background: none;
  }

  /* Khi mở panel: banner xích xuống sát khối nhập liệu */
  .cc-figma .expandable-panel-header.active {
    position: relative;
    z-index: 2;
    margin-bottom: -12px;
  }

  .cc-figma .expandable-panel-header.active .expandable-panel-title {
    transform: translateY(8px);
  }

  .cc-figma .expandable-panel-content.active .expandable-panel-body {
    margin-top: 0 !important;
    padding: 0 !important;
  }

  .cc-figma .expandable-panel-content.active .cc-shell {
    margin-top: 0;
    padding-top: 40px;
  }

  .cc-figma .panel-title-text {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  .cc-figma .expandable-panel-arrow {
    display: none;
  }

  .cc-figma .expandable-panel-body {
    margin-top: 0;
  }

  .cc-figma .cc-shell {
    padding: 16px 14px 18px;
    border: 3px solid var(--cc-mb-blue);
    border-top: 0;
    border-radius: 0 0 20px 20px;
    background: #dff3fc;
    box-shadow: none;
  }

  .cc-figma .cc-section-head,
  .cc-figma .cc-results-block .cc-section-head {
    margin: 0 0 12px;
  }

  .cc-figma .cc-results-block .cc-section-head {
    margin-top: 14px;
  }

  .cc-figma .cc-section-title,
  .cc-figma .cc-section-title.is-results {
    gap: 8px;
    font-size: 16px;
    color: var(--cc-mb-blue);
    text-decoration: none;
  }

  .cc-figma .cc-section-title img {
    width: 22px;
    height: 28px;
  }

  .cc-figma .cc-chip {
    display: none;
  }

  .cc-figma .cc-input-grid {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .cc-figma .cc-box {
    aspect-ratio: auto;
    padding: 0;
    background: none;
  }

  .cc-figma .cc-box-header,
  .cc-figma .cc-box-deco,
  .cc-figma .cc-row-icon,
  .cc-figma .cc-info,
  .cc-figma .result-card-icon {
    display: none;
  }

  .cc-figma .cc-box-rows,
  .cc-figma .cc-box-members .cc-box-rows {
    display: block;
    padding: 0;
  }

  .cc-figma .cc-row {
    grid-template-columns: 1fr;
    row-gap: 4px;
    margin-bottom: 21px;
  }

  .cc-figma .cc-box-members .cc-row:last-child {
    margin-bottom: 0;
  }

  .cc-figma .cc-row-label {
    font-size: 14px;
    font-weight: 400;
    color: var(--cc-mb-blue);
    white-space: normal;
  }

  .cc-figma .cc-stepper {
    grid-template-columns: 1fr;
    height: 44px;
    border: 2px solid var(--cc-mb-blue);
    border-radius: 8px;
  }

  .cc-figma .cc-stepper button {
    display: none;
  }

  .cc-figma .cc-stepper input {
    padding: 0 12px;
    font-size: 15px;
    font-weight: 400;
    text-align: left;
    color: #333;
  }

  .cc-figma .cc-stepper input::placeholder {
    color: #9aa0a6;
  }

  .cc-figma .result-cards {
    grid-template-columns: 1fr;
    gap: 21px;
    margin: 0;
  }

  .cc-figma .result-card,
  .cc-figma .result-card.is-profit,
  .cc-figma .result-card.is-rate {
    aspect-ratio: auto;
    min-height: 64px;
    padding: 10px 12px;
    border-radius: 14px;
    background: linear-gradient(180deg, #eaf7ff 0%, #d8f4ff 100%);
    box-shadow: inset 0 -2px 11px #06a9fb, 0 4px 0 var(--cc-blue-deep);
  }

  .cc-figma .result-card.is-platform {
    display: none;
  }

  .cc-figma .result-card-content {
    position: static;
    width: auto;
  }

  .cc-figma .result-card-title {
    margin: 0 0 3px;
    font-size: 14px;
    font-weight: 900;
    white-space: normal;
    color: var(--cc-blue-deep);
  }

  .cc-figma .result-value-pill {
    height: auto;
    background: transparent;
  }

  .cc-figma .result-card-value {
    font-size: 16px;
    font-weight: 900;
    color: var(--cc-mb-blue) !important;
  }

  .cc-figma .total-commission-banner {
    height: auto;
    min-height: 35px;
    gap: 5px;
    margin: 27px 0 0;
    padding: 8px 12px;
    border-radius: 30px;
  }

  .cc-figma .total-commission-label,
  .cc-figma .total-commission-value,
  .cc-figma .total-commission-currency {
    font-size: 18px;
    color: var(--cc-mb-blue);
  }
}
