/* ===========================
   공통 계층 구조 정의 (요청13 적용)
   =========================== */

/* 모든 요소에 border-box 적용 */
* {
  box-sizing: border-box;
}

/* HTML과 BODY에 기본 여백 제거 + 가로 스크롤 방지 */
html, body {
  margin: 0;
  padding: 0;
  overflow-x: hidden;
  font-family: 'Arial', sans-serif;
  background-color: #f4f4f4;
}

/* 모든 모달은 최상위 계층 유지 */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 9999 !important;
  width: 100vw;
  height: 100vh;
  display: none;
  justify-content: center;
  align-items: center;
  background-color: rgba(0, 0, 0, 0.5);
}

/* 모달 내용 */
.modal-content {
  background-color: #fff;
  padding: 20px;
  border-radius: 12px;
  max-width: 400px;
  width: 90%;
  max-height: 90%;
  overflow-y: auto;
}

/* 바텀시트는 모달보다 아래 계층 */
.bottom-sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100vw;              /* ✅ 화면 기준 가로폭 적용 */
  box-sizing: border-box;    /* ✅ 내용 너비 기준 계산 */
  background: white;
  border-top-left-radius: 16px;
  border-top-right-radius: 16px;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
  z-index: 1000;
  display: none;
  flex-direction: column;
}

.bottom-sheet.show {
  display: flex;
}

/* 결제수단 버튼*/
.payment-options {
  display: flex;
  gap: 20px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 20px;
}

.payment-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  font-size: 18px;
  border-radius: 10px;
  border: 1px solid #ccc;
  background: #f2f2f2;
  cursor: pointer;
  transition: background 0.2s;
}

.payment-btn img {
  width: 36px;
  height: 36px;
}

.payment-btn:hover {
  background-color: #007bff;
  color: white;
}

.cart-badge-container {
	position: fixed;
    top: 15px;
    right: 15px;
    z-index: 1000;
    background: white;
    border: 2px solid #ccc;
    border-radius: 30px;
    padding: 6px 12px;
    display: flex;
    align-items: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    font-size: 16px;
    cursor: pointer;
}

.cart-badge-container img {
    width: 24px;
    height: 24px;
    margin-right: 8px;
}

#loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    transition: opacity 0.3s ease-out;
}

.spinner {
    border: 6px solid #f3f3f3;
    border-top: 6px solid #007bff; /* 테마에 맞는 색상으로 변경 가능 */
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 결과 모달 버튼 스타일 */
.result-modal-actions {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 25px;
}
.result-modal-actions .modal-action-btn {
	padding: 12px 25px;
	border: 1px solid #ccc;
	border-radius: 8px;
	cursor: pointer;
	font-size: 16px;
	background-color: #f0f0f0;
    min-width: 120px;
}
.result-modal-actions .modal-action-btn.primary {
    background-color: #007bff; /* 주요 액션 버튼 색상 */
    color: white;
    border-color: #007bff;
}


/* 영수증 모달 스타일 */
.receipt-paper {
  background-color: #fff;
  padding: 20px;
  border-radius: 5px;
  width: 90%;
  max-width: 380px;
  font-family: 'Courier New', Courier, monospace;
  box-shadow: 0 5px 15px rgba(0,0,0,0.2);
  border: 1px solid #eee;
}

#receiptModal .receipt-header {
  position: relative; /* 자식인 저장 버튼의 위치 기준이 됨 */
  text-align: center;
  padding-bottom: 15px;
  border-bottom: 1px dashed #999;
}
.save-receipt-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  background: none;
  border: none;
  font-size: 22px;
  color: #888;
  cursor: pointer;
  padding: 5px;
}
.save-receipt-btn:hover {
  color: #007bff;
}

#receiptModal .receipt-header h3 {
  margin: 0 0 5px 0;
  font-size: 20px;
}

.receipt-header p {
  margin: 0;
  font-size: 14px;
}

.receipt-body {
  padding: 15px 0;
}

.receipt-section {
  margin-bottom: 15px;
  padding-bottom: 15px;
  border-bottom: 1px dashed #999;
}

.receipt-section:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

#receiptInfo div, #receiptTotal div {
  display: flex;
  justify-content: space-between;
  margin-bottom: 5px;
  font-size: 14px;
}

.receipt-item-header, .receipt-item {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  margin-bottom: 3px;
}

.receipt-item-header {
  font-weight: bold;
  border-bottom: 1px solid #333;
  padding-bottom: 5px;
  margin-bottom: 5px;
}

.receipt-actions {
  display: flex;
  justify-content: center;
  gap: 15px;
  margin-top: 25px;
}

/* 영수증 하단 메시지 영역 스타일 */
#receiptModal .receipt-footer {
  text-align: center;
  margin-top: 20px;
  padding-top: 15px;
  border-top: 1px dashed #999;
  font-size: 14px;
  color: #555;
}

/* 긴 오류 메시지가 영역을 넘어가지 않도록 줄바꿈 처리 */
#receiptModal #receiptMessage {
  word-wrap: break-word;     /* 오래된 브라우저 지원 */
  overflow-wrap: break-word; /* 표준 속성 */
  text-align: left;          /* 긴 메시지는 왼쪽 정렬이 가독성이 좋음 */
}

/* POS Bill 영역 스타일 */
#receiptModal #receiptPosBill {
  margin-top: 15px;
  padding-top: 15px;
  border-top: 2px solid #333; /* 명확한 구분선 */
  font-size: 13px;
  white-space: pre-wrap; /* 서버에서 온 줄바꿈(\n)을 그대로 표시 */
  text-align: left;
}
/* 장바구니 뱃지 애니메이션 */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
  20%, 40%, 60%, 80% { transform: translateX(5px); }
}
.cart-badge-container.shake {
  animation: shake 0.5s ease-in-out;
}

/* --- 바텀시트 장바구니 내부 스타일 --- */
.bottom-sheet-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 10px;
  border-bottom: 2px solid #eee;
}

.bottom-sheet-title {
  font-size: 20px;
  font-weight: bold;
  color: #333;
}

.close-sheet-btn {
  background: none;
  border: none;
  font-size: 28px;
  color: #666;
  cursor: pointer;
  padding: 5px;
  line-height: 1;
}

.order-list {
  max-height: 40vh;
  overflow-y: auto;
  margin-bottom: 20px;
}

.cart-empty-message {
  text-align: center;
  color: #888;
  padding: 40px 0;
}

.order-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 5px;
  border-bottom: 1px solid #f0f0f0;
}

.order-item-info {
  flex-grow: 1;
}

.order-item-name {
  font-weight: bold;
}
.order-item-price {
  font-size: 0.9em;
  color: #666;
}

.order-item-quantity {
  display: flex;
  align-items: center;
  gap: 12px;
}

.quantity-btn, .remove-btn {
  background-color: #e9e9e9;
  border: 1px solid #ddd;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 18px;
  font-weight: bold;
  color: #555;
}

.remove-btn {
  background-color: #fbebeb;
  color: #d9534f;
  border-color: #f8d7da;
}

.order-total {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 2px solid #eee;
  font-size: 18px;
  font-weight: bold;
  text-align: right;
}

.bottom-sheet-actions {
  margin-top: 20px;
  text-align: center;
}

.order-btn {
  background-color: #007bff;
  color: white;
  border: none;
  padding: 15px 30px;
  border-radius: 30px;
  font-size: 18px;
  cursor: pointer;
  transition: background-color 0.3s;
  width: 100%;
}

.order-btn:hover {
  background-color: #0056b3;
}
.order-btn:disabled {
  background-color: #ccc;
  cursor: not-allowed;
}
/* --- 반응형 스타일: 모바일 화면 --- */
@media screen and (max-width: 768px) {
    .bottom-sheet {
        width: 95%; /* 스마트폰 화면에서는 95% 너비로 조정 */
        bottom: 10px; /* 하단에 약간의 여백 추가 */
        border-radius: 16px; /* 모든 모서리를 둥글게 처리 */
    }
}

/* ===========================
   Custom Dialog (구조)
   =========================== */
.dialog-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1001; /* loading-overlay보다 위에 표시 */
}

.dialog-box {
    width: 90%;
    max-width: 450px;
    text-align: center;
}

.dialog-actions {
    display: flex;
    justify-content: space-evenly;
    gap: 15px;
}

.dialog-actions button {
    cursor: pointer;
    min-width: 120px;
}