/**
 * Bottom Floating Bar - 공통 컴포넌트 CSS
 * 인터넷/휴대폰 페이지에서 공유
 *
 * 사용법:
 * <link rel="stylesheet" href="/css/bottom-floating-bar.css">
 */

/* ========================================
   CSS 스코핑/격리 (전역 스타일 상속 차단)
   ======================================== */
.floating-bar-v2,
.floating-bar-v2 *,
.floating-bar-v2 *::before,
.floating-bar-v2 *::after,
.bottom-bar,
.bottom-bar *,
.bottom-bar *::before,
.bottom-bar *::after {
  box-sizing: border-box !important;
  line-height: 1.2 !important;
  letter-spacing: normal;
}

.floating-bar-v2,
.bottom-bar {
  font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* 버튼/링크 기본 스타일 리셋 */
.floating-bar-v2 button,
.floating-bar-v2 a,
.bottom-bar button,
.bottom-bar a {
  margin: 0;
  padding: 0;
  font-family: inherit;
  font-size: inherit;
  line-height: inherit !important;
  text-decoration: none;
  color: inherit;
}

/* ========================================
   하단 플로팅 바 V2 (모바일)
   ======================================== */
.floating-bar-v2 {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100000;
  display: flex;
  flex-direction: column;
  align-items: center;
}

@media (min-width: 768px) {
  .floating-bar-v2 {
    display: none;
  }
}

.floating-bar-v2__container {
  width: 100%;
  max-width: 500px;
  background: white;
  border-radius: 24px 24px 0 0;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.12);
  position: relative;
}

/* 토글 핸들 */
.floating-bar-v2__toggle {
  width: 100%;
  display: flex;
  justify-content: center;
  padding: 12px 0 4px;
  cursor: pointer;
  border-radius: 23px 23px 0 0;
  -webkit-tap-highlight-color: transparent;
  height: 10px;
}

.floating-bar-v2__toggle:active {
  background: #f9fafb;
}

.floating-bar-v2__chevron {
  width: 20px;
  height: 20px;
  color: #d1d5db;
  transition: transform 0.3s ease;
}

.floating-bar-v2[aria-expanded="true"] .floating-bar-v2__chevron {
  transform: rotate(180deg);
}

/* 펼침 영역 */
.floating-bar-v2__details {
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease-in-out;
  background: rgba(249, 250, 251, 0.5);
}

.floating-bar-v2[aria-expanded="true"] .floating-bar-v2__details {
  max-height: 300px;
  opacity: 1;
}

.floating-bar-v2__details-inner {
  padding: 4px 24px 16px;
  border-bottom: 1px solid #f3f4f6;
}

.floating-bar-v2__details-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.floating-bar-v2__gift-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #f43f5e;
  font-weight: 700;
  font-size: 15px;
}

.floating-bar-v2__gift-badge i {
  font-size: 14px;
}

.floating-bar-v2__collapse-btn {
  display: flex;
  align-items: center;
  gap: 2px;
  color: #3b82f6;
  font-size: 14px;
  font-weight: 500;
  background: none;
  border: none;
  cursor: pointer;
}

.floating-bar-v2__price-rows {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.floating-bar-v2__price-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
  color: #6b7280;
}

.floating-bar-v2__price-value {
  font-weight: 500;
  color: #111827;
}

.floating-bar-v2__price-row--discount {
  color: #f43f5e;
  font-weight: 500;
}

.floating-bar-v2__price-row--discount span:last-child {
  color: #f43f5e;
}

/* 메인 바 */
.floating-bar-v2__main {
  padding: 8px 20px 24px;
  padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  background: white;
}

.floating-bar-v2__top-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
  font-size: 13px;
}

.floating-bar-v2__gift-info {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #2563eb;
  font-weight: 500;
  font-size: 13px;
  letter-spacing: -0.02em;
}

.floating-bar-v2__gift-info i {
  color: #f43f5e;
  font-size: 13px;
}

.floating-bar-v2__detail-btn {
  display: flex;
  align-items: center;
  gap: 2px;
  color: #2563eb;
  font-size: 13px;
  font-weight: 500;
  background: none;
  border: none;
  cursor: pointer;
}

.floating-bar-v2__price-display {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 20px;
}

.floating-bar-v2__price-label {
  display: flex;
  flex-direction: column;
  gap: 2px;
  color: #6b7280;
  font-weight: 500;
  font-size: 11px;
  line-height: 1.3;
  letter-spacing: -0.01em;
}

.floating-bar-v2__price-label .product-line {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.floating-bar-v2__price-label .product-line .label {
  color: #9ca3af;
}

.floating-bar-v2__price-amount {
  color: #2563eb;
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.03em;
}

.floating-bar-v2__buttons {
  display: flex;
  gap: 10px;
  height: 52px !important;
  min-height: 52px !important;
}

.floating-bar-v2__btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100% !important;
  min-height: 48px !important;
  padding: 12px 16px !important;
  font-size: 16px !important;
  font-weight: 700;
  line-height: 1 !important;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  white-space: nowrap;
}

.floating-bar-v2__btn--outline {
  background: white;
  border: 1.5px solid #2563eb;
  color: #2563eb;
}

.floating-bar-v2__btn--outline:hover {
  background: #eff6ff;
}

.floating-bar-v2__btn--primary {
  background: #2563eb;
  border: none;
  color: white;
  box-shadow: 0 1px 3px rgba(37, 99, 235, 0.3);
}

.floating-bar-v2__btn--primary:hover {
  background: #1d4ed8;
}

/* ========================================
   플로팅 바 V2 - 모바일 (메인바 고정, 펼침영역 위로)
   ======================================== */
@media (max-width: 480px) {
  .floating-bar-v2__container {
    overflow: visible;
  }

  .floating-bar-v2__toggle {
    padding: 1px 0 4px;
  }

  .floating-bar-v2__details {
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out, opacity 0.25s ease-out;
  }

  .floating-bar-v2[aria-expanded="true"] .floating-bar-v2__details {
    max-height: 120px;
    opacity: 1;
  }

  .floating-bar-v2__details-inner {
    padding: 4px 16px 12px;
    border-bottom: 1px solid #f3f4f6;
  }

  .floating-bar-v2__details-header {
    margin-bottom: 8px;
  }

  .floating-bar-v2__gift-badge {
    font-size: 13px;
  }

  .floating-bar-v2__price-rows {
    gap: 6px;
  }

  .floating-bar-v2__price-row {
    font-size: 13px;
  }

  .floating-bar-v2__main {
    padding: 8px 16px 16px;
    padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    background: white;
  }

  .floating-bar-v2__top-row {
    margin-bottom: 4px;
  }

  .floating-bar-v2__gift-info {
    font-size: 13px;
  }

  .floating-bar-v2__detail-btn {
    font-size: 13px;
  }

  .floating-bar-v2__price-display {
    margin-bottom: 12px;
  }

  .floating-bar-v2__price-label {
    font-size: 11px;
  }

  .floating-bar-v2__price-amount {
    font-size: 16px;
  }

  .floating-bar-v2__buttons {
    height: 48px !important;
    min-height: 48px !important;
    gap: 8px;
  }

  .floating-bar-v2__btn {
    font-size: 15px !important;
    min-height: 44px !important;
    padding: 10px 14px !important;
  }
}

/* ========================================
   하단 플로팅 바 (PC 전용)
   ======================================== */
.bottom-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  background: white;
  border-top: 1px solid #e5e7eb;
  box-shadow: 0 -4px 20px -5px rgba(0,0,0,0.1);
  z-index: 100000;
  display: none;
}

@media (min-width: 768px) {
  .bottom-bar {
    display: block;
  }
}

.bottom-bar-inner {
  max-width: 1200px;
  margin: 0 auto;
  background: white;
}

/* 메인 바 */
.bar-main {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px 12px;
  padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
}

@media (min-width: 768px) {
  .bar-main {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 16px 20px;
  }
}

/* PC 플로팅바 선택 상품 표시 */
.selected-products-pc {
  display: flex;
  flex-direction: column;
  gap: 3px;
  color: #374151;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
  min-width: 280px;
  flex: 1;
}

.selected-products-pc .product-line {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.selected-products-pc .product-line .label {
  color: #6b7280;
  font-weight: 500;
}

.price-area {
  flex: 1.4;
  display: flex;
  align-items: center;
  flex-direction: column;
}

.price-area .final-price {
  margin-left: auto;
  text-align: right;
}

/* PC 가격 */
.pc-price {
  display: none;
}

@media (min-width: 768px) {
  .pc-price {
    display: block;
  }
}

.gift-pc {
  color: #ef4444;
  font-weight: 700;
  font-size: 18px;
  margin-bottom: 4px;
}

.price-summary {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: #6b7280;
  margin-bottom: 2px;
  flex-wrap: wrap;
}

.price-summary .divider {
  width: 1px;
  height: 12px;
  background: #d1d5db;
}

/* 최종 가격 */
.final-price {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

@media (min-width: 768px) {
  .final-price {
    flex-direction: row;
    align-items: center;
    gap: 12px;
  }
}

.final-label {
  font-size: 14px;
  font-weight: 700;
  color: #1f2937;
}

@media (min-width: 768px) {
  .final-label {
    font-size: 13px;
  }
}

.final-label .mobile-label {
  display: inline;
}

.final-label .pc-label {
  display: none;
}

@media (min-width: 768px) {
  .final-label .mobile-label {
    display: none;
  }
  .final-label .pc-label {
    display: inline;
  }
}

.final-label small {
  font-size: 12px;
  font-weight: 400;
  color: #9ca3af;
  margin-left: 4px;
}

@media (min-width: 768px) {
  .final-label small {
    font-size: 10px;
  }
}

.final-value {
  font-size: 20px;
  font-weight: 700;
  color: #2563eb;
  line-height: 1;
  margin-top: 4px;
  min-height: 28px;
  display: flex;
  align-items: center;
}

@media (min-width: 768px) {
  .final-value {
    font-size: 20px;
    margin-top: 0;
    min-height: 24px;
  }
}

/* 버튼 영역 */
.btn-area {
  display: flex;
  gap: 8px;
  height: 44px !important;
  min-height: 44px !important;
}

@media (min-width: 768px) {
  .btn-area {
    height: 56px !important;
    min-height: 56px !important;
    flex-shrink: 0;
  }
}

.bar-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 100% !important;
  min-height: 44px !important;
  padding: 10px 16px !important;
  font-size: 14px !important;
  font-weight: 700;
  line-height: 1 !important;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

@media (min-width: 768px) {
  .bar-btn {
    flex: none;
    width: 160px;
    font-size: 16px;
  }
}

.bar-btn.outline {
  background: white;
  color: #2563eb;
  border: 1px solid #2563eb;
}

.bar-btn.outline:hover {
  background: #eff6ff;
}

.bar-btn.primary {
  background: #2563eb;
  color: white;
  border: none;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.bar-btn.primary:hover {
  background: #1d4ed8;
}

@media (min-width: 768px) {
  .bar-btn.primary {
    width: 192px;
  }
}

/* ========================================
   페이지 타입별 요소 표시/숨김
   ======================================== */
/* 기본: 휴대폰 전용 요소 숨김 */
.floating-bar-v2__phone-only,
.pc-price--phone {
  display: none !important;
}

/* 휴대폰 페이지: 인터넷 전용 요소 숨김, 휴대폰 전용 표시 */
.floating-bar-v2--phone .floating-bar-v2__internet-only,
.bottom-bar--phone .pc-price--internet {
  display: none !important;
}

.floating-bar-v2--phone .floating-bar-v2__phone-only,
.bottom-bar--phone .pc-price--phone {
  display: block !important;
}

.floating-bar-v2--phone .floating-bar-v2__top-row {
  justify-content: flex-end;
}

/* ========================================
   휴대폰 펼침 영역 상세 정보 스타일
   ======================================== */
.floating-bar-v2__phone-details {
  padding: 0;
}

.floating-bar-v2__details-title {
  font-size: 14px;
  font-weight: 600;
  color: #1f2937;
}

.floating-bar-v2__info-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 8px 0;
  border-bottom: 1px solid #f3f4f6;
  font-size: 13px;
}

.floating-bar-v2__info-row:last-child {
  border-bottom: none;
}

.floating-bar-v2__info-label {
  color: #6b7280;
  font-weight: 500;
  flex-shrink: 0;
  min-width: 50px;
}

.floating-bar-v2__info-value {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  color: #1f2937;
  font-weight: 500;
  text-align: right;
}

.floating-bar-v2__carrier-info {
  font-size: 11px;
  color: #6b7280;
  font-weight: 400;
}

.floating-bar-v2__discount-type {
  font-size: 11px;
  color: #2563eb;
  font-weight: 500;
}

.floating-bar-v2__sub-info {
  font-size: 11px;
  color: #6b7280;
  font-weight: 400;
}

.floating-bar-v2__info-row--highlight {
  background: #fef2f2;
  margin: 8px -16px -12px;
  padding: 10px 16px;
  border-radius: 0 0 8px 8px;
  border-bottom: none;
}

.floating-bar-v2__info-value--discount {
  color: #dc2626 !important;
  font-weight: 700 !important;
  font-size: 15px !important;
}

/* ========================================
   PC 휴대폰 추가 정보 스타일
   ======================================== */
.pc-carrier-info,
.pc-plan-info {
  font-size: 12px;
  color: #6b7280;
  font-weight: 400;
  margin-left: 8px;
}

.pc-total-discount {
  color: #dc2626;
  font-weight: 600;
}

.pc-total-discount-value {
  color: #dc2626 !important;
  font-weight: 700 !important;
}

.bottom-bar--phone .pc-price--phone .price-summary {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: #6b7280;
}

/* ========================================
   페이지 하단 여백 (플로팅바 공간 확보)
   ======================================== */
/* 모바일: 플로팅바 높이 + 여유 공간 */
.detail-page .detail-info,
.inet-page .page-content {
  padding-bottom: 180px;
}

@media (min-width: 768px) {
  /* PC: 플로팅바 높이 + 여유 공간 */
  .detail-page .detail-info,
  .inet-page .page-content {
    padding-bottom: 120px;
  }
}

/* ========================================
   페이지와의 z-index 조정
   ======================================== */
/* 플로팅바가 모바일 하단 네비게이션 위에 표시 */
.inet-page ~ .mobile-bottom-nav,
.detail-page ~ .mobile-bottom-nav {
  z-index: 950;
}

/* ========================================
   가격 업데이트 중 상태
   ======================================== */
.price-updating {
  opacity: 0.7;
}

.final-value,
.floating-bar-v2__price-amount,
.floating-bar-v2__price-value {
  transition: opacity 0.15s ease-out;
}
