/* ========= GMBS /orders — 최종본 (순수 CSS) ========= */

/* 데스크탑 기본: 모바일용 상태/추적은 숨김 */
.gmbs-status-inline,
.gmbs-track-inline {
  display: none;
}

body.woocommerce-account .gmbs-date--m {
  display: none !important;
}

/* GMBS /orders layout tokens */
body.woocommerce-account {
  --gmbs-wrap: 1060px; /* 전체 콘텐츠 최대폭 */
  --gmbs-pad: 12px; /* 좌우 패딩 */
  --gmbs-gap: 20px; /* 그리드 간격(요청: 30px) */
}

/* 섹션 래퍼: 모든 내부와 동일 폭/패딩 */
body.woocommerce-account .gmbs-order-block {
  margin-top: 20px;
  max-width: var(--gmbs-wrap);
  margin-inline: auto;
  padding-inline: var(--gmbs-pad);
  box-sizing: border-box;
  position: relative;
  overflow-x: hidden; /* 안전가드 */
}

/* 주문 템플릿이 뱉는 hr(끝선)을 전부 숨김 — 우리는 ::after만 사용 */
.woocommerce-MyAccount-content hr.gmbs-order-end {
  display: none !important;
}
/* 혹시 다른 기본 hr가 섞여도 모두 숨기고, 우리 '벤더 구분선'만 보이게 */
.gmbs-order-block hr:not(.gmbs-order-vendor-divider) {
  display: none;
}

/* #01 시작 디바이더: 음수 마진 제거, 콘텐츠 폭 100% */
body.woocommerce-account .gmbs-order-block::before {
  content: "";
  display: block;
  height: 0;
  border-top: 3px solid #000;
  width: 100%;
}

/* #17 끝 디바이더: 섹션 내부에서 동일 폭으로 그림 */
body.woocommerce-account .gmbs-order-block::after {
  content: "";
  display: block;
  height: 0;
  border-top: 1px solid #000;
  width: 100%;
  margin-top: 32px; /* 끝선 위 여백 */
  margin-bottom: 45px; /* 다음 주문과 간격 */
}

/* 내부 요소들은 래퍼 규칙 제거(폭/패딩 없음, 섹션에 맞춤) */
body.woocommerce-account .gmbs-order-head,
body.woocommerce-account .gmbs-vendor-row,
body.woocommerce-account .gmbs-order-vendor-divider {
  max-width: none;
  padding: 0;
  box-sizing: border-box;
}

/* 02~05: 헤더 라인 */
body.woocommerce-account .gmbs-order-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid #000; /* 05 */
}

.gmbs-order-head .gmbs-order-headline {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}
.gmbs-order-head .gmbs-label {
  font-weight: 400;
  opacity: 0.9;
}
.gmbs-order-head .gmbs-date,
.gmbs-order-head .gmbs-orderno {
  font-weight: 700;
}
.gmbs-order-head .gmbs-gap {
  width: 12px;
  display: inline-block;
}

/* 04: 주문상세 링크(버튼풍) + V 화살표 */
.gmbs-order-view {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  text-decoration: none;
  color: #2d4f0d; /* 장바구니로 돌아가기 톤에 맞춤 */
  font-weight: 400; /* 볼드 아님 */
  border: 0;
  background: transparent;
  padding: 0;
  border-radius: 0;
}
.gmbs-order-view:hover {
  text-decoration: underline;
}
.gmbs-order-view .gmbs-arrow {
  width: 18px;
  height: 18px;
  position: relative;
  top: 1px;
  display: inline-block;
  vertical-align: middle;
}

/* 06: 공급업체명 */
.gmbs-vendor-row {
  margin-top: 20px;
}
.gmbs-vendor-name a {
  font-weight: 700;
  font-size: 18px;
  line-height: 1.25;
  color: inherit;
  text-decoration: none;
}

.gmbs-vendor-name {
  margin-bottom: 10px;
}

/* 07~16: 벤더 그리드 (아이템행 | 배송비(한칸) | 상태 | 액션) */
.gmbs-vendor-grid {
  display: grid;
  /* items | ship | status | actions */
  grid-template-columns:
    minmax(0, 2.5fr) /* 아이템(유연, 가장 넓게) */
    minmax(90px, 0.55fr) /* 배송비(최소폭 살짝 더 낮춤) */
    minmax(130px, 0.95fr) /* 상태(최소폭 살짝 더 낮춤) */
    minmax(140px, 0.6fr); /* 액션(최소 140px로 더 타이트) */
  grid-auto-rows: minmax(64px, auto);
  column-gap: var(--gmbs-gap); /* = 30px (토큰) */
  row-gap: calc(var(--gmbs-gap) * 1.5); /* 세로 간격 */
  align-items: start;
  width: 100%;
}

/* 내용 긴 경우에도 줄바꿈/수축 허용 */
.gmbs-item-cell,
.gmbs-ship-col,
.gmbs-status-cell,
.gmbs-actions-cell {
  min-width: 0;
}

/* 드문 반올림 오버플로우 1px 가드 */
.gmbs-vendor-grid {
  overflow-x: clip;
}
@supports not (overflow: clip) {
  .gmbs-vendor-grid {
    overflow-x: hidden;
  }
}

/* 배송비 셀: 2열, 모든 행 세로 커버 */
.gmbs-ship-col {
  grid-column: 2;
  align-self: stretch;
  display: grid; /* 내부 그리드로 중앙정렬 */
  align-items: center;
  justify-content: center;
  text-align: center;
  word-break: keep-all;
  white-space: normal;
  font-size: 16px;
  color: #000;
  line-height: 1.25;
}

/* 07~10: 아이템 셀(1열) */
.gmbs-item-cell {
  grid-column: 1;
  display: grid;
  grid-template-columns: 90px 1fr;
  column-gap: 15px;
  align-items: flex-start;
}
.gmbs-thumb img {
  width: 90px;
  height: 90px;
  object-fit: cover;
  display: block;
}
.gmbs-desc {
  display: flex;
  flex-direction: column;
}
.gmbs-title {
  font-weight: 700;
  line-height: 1.35;
  margin: 0 0 4px;
  font-size: 20px;
}
.gmbs-opts,
.gmbs-line {
  font-size: 15px;
  color: #9b9b9b;
}
.gmbs-updated {
  color: #9b9b9b;
  font-size: 11px;
  margin-top: 2px;
  line-height: 1.2;
} /* 8번: 동일 색상 지정 */

a.gmbs-link-plain {
  color: inherit;
  text-decoration: none;
}

/* 12~14: 상태 셀(3열) */
.gmbs-status-cell {
  grid-column: 3;
  align-self: stretch;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  gap: 2px;
  font-size: 13px;
}
.gmbs-status-cell > * {
  margin: 0 !important;
}

.gmbs-vendor-grid .gmbs-status-cell .gmbs-track {
  margin-top: 6px !important;
} /* 필요하면 8~12px로 조절 */

.gmbs-status {
  font-weight: 800;
  font-size: 21px;
  line-height: 1.15;
}

/* 15: 액션 셀(4열) */
.gmbs-actions-cell {
  grid-column: 4;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: stretch;
}
.gmbs-actions-cell .gmbs-btn {
  width: 100%;
  text-align: center;
  box-sizing: border-box;
}

.gmbs-btn {
  display: inline-block;
  padding: 6px 10px;
  text-decoration: none;
  border-radius: 0;
  color: #000;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}
.gmbs-btn--line {
  border: 1px solid #000;
  background: #fff;
  font-weight: 400;
}
.gmbs-btn--solid {
  border: 1px solid #9cfe20;
  background: #9cfe20;
  font-weight: 400;
}
.gmbs-btn--line:hover {
  background: #9cfe20;
  border-color: #9cfe20;
  color: #000;
}

/* 16: 벤더 사이 구분선 */
.gmbs-order-vendor-divider {
  border: 0;
  height: 1px;
  background: #000;
  margin: 32px 0px 24px;
  display: block;
  width: 100%;
}

/* Woo 기본/테마에서 끼어드는 hr 차단 (우리 hr만 보이게) */
.woocommerce-MyAccount-content
  hr:not(.gmbs-order-end):not(.gmbs-order-vendor-divider) {
  display: none;
}
body.woocommerce-account .gmbs-vendor-row,
body.woocommerce-account .gmbs-order-head {
  box-sizing: border-box;
}

.gmbs-pagination {
  margin: 20px 0 10px;
  text-align: center;
}
.gmbs-pagination .page-numbers {
  display: inline-block;
  padding: 6px 10px;
  border: 1px solid #000;
  margin: 0 3px;
  text-decoration: none;
  color: #000;
}
.gmbs-pagination .current {
  background: #000;
  color: #fff;
}

/* ship-inline은 기본 비표시(모바일에서만 표시) */
.gmbs-ship-inline {
  display: none;
}

/* 헤더의 화살표 아이콘 안전 고정(전역 svg/path 규칙 무력화) */
.gmbs-order-view .gmbs-arrow {
  width: 18px;
  height: 18px;
  display: inline-block;
}
.gmbs-order-view .gmbs-arrow polygon {
  fill: currentColor;
}

/* ===== 모바일 전용(≤980px) ===== */
@media (max-width: 980px) {
  .gmbs-order-head {
    align-items: flex-start;
  }

  .gmbs-label--orderno,
  .gmbs-orderno {
    display: none;
  }

  /* 3) 주문상세 링크 줄바꿈 방지 */
  .gmbs-order-view {
    white-space: nowrap;
  }

  /* 4) 공급업체 줄 */
  .gmbs-vendor-row {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: baseline;
  }

  .gmbs-vendor-name {
    grid-column: 1;
    margin: 2px 0 18px;
  }

  .gmbs-ship-inline {
    grid-column: 2;
    display: block;
    text-align: right;
    font-size: 14px;
    color: #000;
  }

  /* 그리드 안의 배송비 칼럼은 모바일에서 숨김 */
  .gmbs-ship-col {
    display: none;
  }

  .gmbs-vendor-grid {
    grid-column: 1/-1;
  } /* 아래 상품 그리드는 전체 폭 사용 */

  .gmbs-item-cell {
    grid-template-columns: 72px 1fr;
  }

  .gmbs-thumb {
    width: 72px;
    height: 72px;
  }

  .gmbs-thumb img {
    width: 100% !important;
    height: 100% !important;
    aspect-ratio: 1/1;
    object-fit: cover;
    display: block;
  }

  .gmbs-status-cell {
    display: none;
  } /* 데스크톱용 상태 칼럼 숨김 */

  .gmbs-status-inline {
    display: block;
    grid-column: 2;
    margin-top: 4px;
  }

  .gmbs-status-inline .gmbs-status-txt {
    font-weight: 700;
    font-size: 16px;
    line-height: 1.2;
  }

  .gmbs-status-inline .gmbs-upd-inline {
    margin-left: 6px;
    font-weight: 400;
    font-size: 14px;
    color: #9b9b9b;
  }

  .gmbs-status-inline .gmbs-track-inline {
    display: block; /* 줄 바꿈 */
    margin-top: 2px;
    font-size: 13px;
    color: #9b9b9b;
  }
  .gmbs-status-inline .gmbs-track-prov,
  .gmbs-status-inline .gmbs-track-num {
    display: inline; /* "업체명 추적번호" 한 줄로 */
  }

  /* 6·7) 액션 버튼은 그 다음 줄에 가로로 꽉 차게 */
  .gmbs-vendor-grid {
    grid-template-columns: 1fr;
    row-gap: 10px;
  }
  .gmbs-actions-cell {
    grid-column: 1;
    flex-direction: row; /* 세로 → 가로 */
    gap: 6px;
  }
  .gmbs-actions-cell .gmbs-btn {
    flex: 1 1 0; /* 버튼 수에 맞춰 균등 분할 */
    width: auto; /* 100% 고정 해제 */
  }

  /* 벤더 간 디바이더 간격 절반 */
  .gmbs-order-vendor-divider {
    margin: 10px 0 12px;
  }

  .gmbs-pager__nums {
    display: flex;
    align-items: center;
  }
  .gmbs-page,
  .gmbs-page.is-current {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 24px; /* 모바일 고정 높이 */
    line-height: 24px; /* 폰트 메트릭 보정 */
    vertical-align: middle;
    padding: 0 1px;
  }

  body.woocommerce-account .gmbs-date--d {
    display: none !important;
  } /* 모바일: 긴 형식 숨김 */
  body.woocommerce-account .gmbs-date--m {
    display: inline !important;
  } /* 모바일: 짧은 형식 노출 */

  .gmbs-item-cell {
    grid-template-columns: 72px 1fr;
  } /* 필요 시 썸네일 폭 조정 */

  /* [모바일] 섹션 끝 디바이더 위/아래 간격 축소 */
  body.woocommerce-account .gmbs-order-block::after {
    margin-top: 10px;
    margin-bottom: 40px;
  }

  /* (선택) 벤더 구분선도 더 타이트하게 하고 싶으면: */
  .gmbs-order-vendor-divider {
    margin: 10px 0 12px;
  }
}
