/* ================= CSS ================= */

/* 기본 레이아웃 */
body {
  font-family: Arial, sans-serif;
  margin: 0;
  padding: 0;
  background-color: #fafafa;
  overflow: hidden;
}

.container {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* ================= 상단 탭 ================= */
.tab-bar {
  display: flex;
  border-bottom: 1px solid #ccc;
  background: #f0f0f0;
  height: 100px;
  min-height: 100px;
  align-items: center;
  box-sizing: border-box;
}

.tab-buttons {
  display: flex;
  gap: 30px;
  margin-left: 20px;
}

.tab-buttons button {
  padding: 10px 30px;
  font-size: 25px;
  cursor: pointer;
  border: none;
  background: inherit;
  transition: background 0.2s;
  font-weight: bold;
  white-space: nowrap;
}

.tab-buttons button.active {
  background-color: #0077ff;
  color: #fff;
  border-radius: 4px 4px 0 0;
}

/* ================= 좌/중/우 3단 레이아웃 ================= */
.content-wrapper {
  display: flex;
  flex: 1;
  height: calc(100vh - 100px);
  width: 100%;
}

.sidebar {
  flex: 0 0 33%; 
  min-width: 300px;
  padding: 20px;
  box-sizing: border-box;
  border-right: 1px solid #ccc;
  display: flex;
  flex-direction: column;
  background-color: #fff;
  overflow-y: auto; 
  scrollbar-gutter: stable; 
}

.center-area {
  flex: 0 0 30%; 
  display: flex;
  flex-direction: column;
  background-color: #f9f9f9;
  border-right: 1px solid #ccc;
  box-sizing: border-box;
  padding: 20px;
  overflow: hidden;
}

.right-space {
  flex: 1; 
  background-color: #fff;
  box-sizing: border-box;
  scrollbar-gutter: stable;
}

/* ================= 사이드바 제목 스타일 ================= */
.sidebar h2 {
  font-size: 35px;
  margin-top: 20px;
  margin-bottom: 10px;
  color: #333;
}
.sidebar h2:first-of-type { margin-top: 0; }

.button-group {
  display: flex;
  flex-wrap: wrap; /* 줄바꿈 허용 */
  gap: 8px; /* 버튼 사이 간격 */
  margin-bottom: 20px;
}

/* ================= 재질/공구 상세 버튼 스타일 수정 ================= */
.button-group button {
  /* ★ 핵심 수정: 3열 고정 (100% / 3 = 33.33%) ★ */
  /* flex: [늘어남] [줄어듦] [기본크기] */
  flex: 0 0 calc(33.33% - 6px); /* 0으로 설정하여 마지막 줄이 늘어나지 않게 함 */
  
  padding: 15px 5px; /* 상하 패딩 조절 */
  min-height: 90px;  /* ★ 높이를 통일하여 두 줄인 버튼과 맞춤 ★ */
  font-size: 22px;   /* 글자 크기 살짝 조정 (박스 크기 대비) */
  cursor: pointer;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: #f8f8f8;
  transition: all 0.1s;
  
  /* 텍스트 중앙 정렬 및 줄바꿈 처리 */
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  word-break: keep-all; /* 단어 단위 줄바꿈으로 깔끔하게 */
  line-height: 1.2;
}

.button-group button.active {
  background-color: #4CAF50;
  color: #fff;
  border-color: #4CAF50;
  font-weight: bold;
}

.calc-btn {               /* 중앙 담기 버튼 박스 수정 */
  margin: 20px auto 0;     /* ← 가운데 정렬 */
  padding: 20px;
  font-size: 25px;
  font-weight: bold;
  width: 80%;
  background-color: #2196F3;
  color: white;
  border: none;
  cursor: pointer;
  border-radius: 6px;
  flex-shrink: 0;
}

/* ================= 결과 표 디자인 ================= */


.result-box {
  width: 100%;
  height: 100%;
  background-color: #fff;
  border: 1px solid #ccc;
  border-radius: 8px;
  overflow: auto;
  box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.result-box table {
  width: 100%;
  border-collapse: collapse;
}

.result-box th, .result-box td {
  border: 2px solid #ddd;
  padding: 15px;
  text-align: left;
  font-size: 25px; 
}

.result-box th {
  background-color: #f4f4f4;
  width: 35%; 
  color: #333;
  font-weight: bold;
}

.result-box td {
  background-color: #fff;
  color: #000;
}

/* ================= 중앙 담기 버튼 래퍼 ================= */
.result-btn-wrap {
  display: flex;
  justify-content: center;
  margin-top: 20px;
}

.add-btn {
  width: 60%;       /* 원하는 폭 */
}


/* ================= 우측 담기 영역 (장바구니) ================= */

.right-space {
  overflow-y: auto;
  padding: 10px;
}

.right-space .calc-btn { /*   출력 버튼    */
  width: 100%;
  margin-bottom: 15px;
}


.cart-item {
  background-color: #fff;
  border: 1px solid #ccc;
  border-radius: 8px;
  margin-bottom: 20px;
  padding: 10px;
  box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

/* 중앙 결과표와 동일한 테이블 스타일 재사용 */
.cart-item table {
  width: 100%;
  border-collapse: collapse;
}

.cart-item th,
.cart-item td {
  border: 2px solid #ddd;
  padding: 15px;
  text-align: left;
  font-size: 22px;
}

.cart-item th {
  background-color: #f4f4f4;
  width: 35%;
  font-weight: bold;
}

/* ================= 우측 담기 카드 ================= */

.right-space {
  overflow-y: auto;
  padding: 10px;
}

.cart-item {
  background-color: #fff;
  border: 1px solid #ccc;
  border-radius: 8px;
  margin-bottom: 20px;
  padding: 10px;
  box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

/* 상단 삭제 버튼 영역 */
.cart-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between; /* 좌측 제목 / 우측 삭제 */
  margin-bottom: 10px;
}

/* 가공 이름 input */
.cart-item-title {
  font-size: 22px;
  font-weight: bold;
  color: #333;
  border: none;
  outline: none;
  background: transparent;
  width: 70%;
  text-align: left; /* ⭐ 좌측 정렬 */
}

.cart-delete-btn {
  padding: 6px 14px;
  font-size: 18px;
  font-weight: bold;
  background-color: #e53935;
  color: #fff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

.cart-delete-btn:hover {
  background-color: #c62828;
}

/* 테이블 스타일 (중앙과 동일 계열) */
.cart-item table {
  width: 100%;
  border-collapse: collapse;
}

.cart-item th,
.cart-item td {
  border: 2px solid #ddd;
  padding: 15px;
  text-align: left;
  font-size: 22px;
}

.cart-item th {
  background-color: #f4f4f4;
  width: 35%;
  font-weight: bold;
}


/* 카드 제목 */
.cart-item-title {
  font-size: 22px;
  font-weight: bold;
  color: #333;
}

/* ================= 출력 제목 입력 ================= */
.print-title-input {
  width: 100%;
  padding: 12px;
  font-size: 22px;
  margin-bottom: 10px;
  box-sizing: border-box;
  border: 1px solid #ccc;
  border-radius: 6px;
}

/* ================= 모바일 반응형 ================= */
@media (max-width: 900px) {

  /* 모바일에서 body 스크롤 허용 (현재 overflow:hidden 때문에 스크롤 막힘) */
  body {
    overflow: auto;
  }

  /* 전체 높이: 100vh 고정은 모바일 주소창 때문에 흔들림 → 최소 높이로 */
  .container {
    height: auto;
    min-height: 100vh;
  }

  /* 상단 탭 높이 줄이고, 탭이 많으면 가로 스크롤 */
  .tab-bar {
    height: auto;
    min-height: 0;
    padding: 10px 0;
  }

  .tab-buttons {
    margin-left: 10px;
    gap: 10px;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 6px;
  }

  .tab-buttons button {
    font-size: 18px;
    padding: 10px 14px;
  }

  /* 3단 레이아웃 → 세로 1단 */
  .content-wrapper {
    flex-direction: column;
    height: auto;
  }

  /* 좌/중/우를 모두 100% 폭으로 */
  .sidebar,
  .center-area,
  .right-space {
    flex: none;
    width: 100%;
    min-width: 0;
    border-right: none;
  }

  .sidebar {
    border-bottom: 1px solid #ccc;
    padding: 14px;
    max-height: none;
    overflow: visible;
  }

  .center-area {
    padding: 14px;
    overflow: visible;
    border-bottom: 1px solid #ccc;
  }

  /* 결과 박스는 모바일에서 “고정 높이”보다 내용 중심 */
  .result-box {
    height: auto;
    max-height: 60vh;   /* 너무 길면 내부 스크롤 */
  }

  /* 우측 담기 영역은 아래로 내려오고 스크롤 허용 */
  .right-space {
    padding: 14px;
    max-height: none;
  }

  /* 섹션 제목 크기 다운 */
  .sidebar h2 {
    font-size: 22px;
    margin-top: 14px;
    margin-bottom: 8px;
  }

  /* 버튼: 모바일에서는 2열(가독/엄지) */
  .button-group button {
    flex: 0 0 calc(50% - 6px);
    min-height: 64px;
    font-size: 16px;
    padding: 12px 6px;
  }

  /* 계산 버튼 */
  .calc-btn {
    width: 100%;
    font-size: 18px;
    padding: 14px;
    margin: 14px 0 0;
  }

  /* 결과 테이블 글자/패딩 축소 */
  .result-box th, .result-box td {
    font-size: 16px;
    padding: 10px;
  }

  /* 담기 카드 */
  .cart-item th, .cart-item td {
    font-size: 15px;
    padding: 10px;
  }

  .cart-item-title {
    font-size: 16px;
    width: 65%;
  }

  .cart-delete-btn {
    font-size: 14px;
    padding: 6px 10px;
  }

  .print-title-input {
    font-size: 16px;
    padding: 10px;
  }
}

/* 더 작은 폰(예: 430px 이하)에서는 1열 버튼 */
@media (max-width: 430px) {
  .button-group button {
    flex: 0 0 100%;
  }
}

