/* ========================================
   David's Coffee - Stylesheet
   브라운/아이보리 테마 디자인
   v2.4 - 장바구니 스크롤 개선
   ======================================== */

/* === 기본 설정 === */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* 색상 팔레트 - 브라운/아이보리 테마 */
    --warm-beige: #F5E6D3;
    --light-beige: #E8D5C4;
    --caramel-brown: #A67B5B;
    --dark-caramel: #8B6F47;
    --terracotta: #C17B5C;
    --cream-white: #FFFEF0;
    --light-cream: #FFF8F0;
    --deep-brown: #4A3428;
    --medium-brown: #6B4423;
    
    /* 그림자 */
    --shadow: rgba(139, 111, 71, 0.15);
    --shadow-hover: rgba(139, 111, 71, 0.25);
    
    /* 강조 색상 */
    --gold: #DAA520;
}

body {
    font-family: 'Noto Sans KR', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: linear-gradient(135deg, var(--cream-white) 0%, var(--light-cream) 50%, var(--warm-beige) 100%);
    color: var(--deep-brown);
    min-height: 100vh;
    padding-bottom: 80px;
}

/* === 헤더 === */
.header {
    background: linear-gradient(135deg, var(--dark-caramel), var(--caramel-brown));
    color: white;
    padding: 20px;
    text-align: center;
    box-shadow: 0 4px 15px var(--shadow);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.logo {
    font-size: 26px;
    font-weight: 700;
    margin-bottom: 5px;
}

.subtitle {
    font-size: 14px;
    opacity: 0.9;
}

/* === 탭 메뉴 === */
.tabs {
    display: flex;
    gap: 10px;
    padding: 15px 20px;
    max-width: 1200px;
    margin: 0 auto;
    position: sticky;
    top: 85px;
    background: linear-gradient(135deg, var(--cream-white), var(--light-beige));
    z-index: 998;
    border-bottom: 3px solid var(--caramel-brown);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.tab-btn {
    flex: 1;
    padding: 12px 20px;
    border: 2px solid var(--caramel-brown);
    background: white;
    color: var(--deep-brown);
    font-size: 16px;
    font-weight: 600;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s;
}

.tab-btn.active {
    background: linear-gradient(135deg, var(--caramel-brown), var(--dark-caramel));
    color: white;
    box-shadow: 0 4px 10px var(--shadow);
}

/* === 제품 섹션 === */
.products-section {
    display: none;
    padding: 20px;
}

.products-section.active {
    display: block;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

.products-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 15px;
}

/* === 제품 카드 === */
.product-card {
    background: white;
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 4px 15px var(--shadow);
    transition: all 0.3s;
    position: relative;
    border: 2px solid transparent;
}

.product-card:hover {
    border-color: var(--caramel-brown);
    box-shadow: 0 6px 20px var(--shadow-hover);
    transform: translateY(-2px);
}

.product-card.sold-out {
    opacity: 0.6;
    position: relative;
}

.product-card.sold-out::after {
    content: 'SEASON OUT';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(-15deg);
    background: rgba(193, 123, 92, 0.95);
    color: white;
    font-size: 28px;
    font-weight: 900;
    padding: 15px 40px;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    z-index: 10;
    pointer-events: none;
}

.product-info {
    padding: 15px;
}

.product-header {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 10px;
}

.product-icon {
    font-size: 40px;
    flex-shrink: 0;
}

.product-title {
    flex: 1;
}

.product-name {
    font-size: 18px;
    font-weight: 700;
    color: var(--deep-brown);
    margin-bottom: 5px;
    line-height: 1.3;
}

.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 700;
    margin-bottom: 8px;
    text-transform: uppercase;
}

.badge.new {
    background: linear-gradient(135deg, #FF6B6B, #EE5A6F);
    color: white;
}

.badge.best {
    background: linear-gradient(135deg, var(--gold), #B8860B);
    color: white;
}

.badge.discount {
    background: linear-gradient(135deg, #4ECDC4, #44A08D);
    color: white;
}

.badge.limited {
    background: linear-gradient(135deg, #9B59B6, #8E44AD);
    color: white;
}

.badge.seasonout {
    background: linear-gradient(135deg, var(--terracotta), #A55A4A);
    color: white;
}

.product-description {
    font-size: 14px;
    color: var(--medium-brown);
    line-height: 1.5;
    margin-bottom: 15px;
}

/* === 옵션 선택 === */
.product-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.option-btn {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--light-beige);
    background: white;
    border-radius: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: all 0.3s;
}

.option-btn:hover {
    border-color: var(--caramel-brown);
    background: var(--light-cream);
}

.option-btn.selected {
    border-color: var(--caramel-brown);
    background: linear-gradient(135deg, var(--warm-beige), var(--light-beige));
}

.option-size {
    font-size: 15px;
    font-weight: 600;
    color: var(--deep-brown);
}

.option-price {
    font-size: 17px;
    font-weight: 700;
    color: var(--caramel-brown);
}

.add-to-cart-btn {
    width: 100%;
    padding: 14px;
    margin-top: 10px;
    background: linear-gradient(135deg, var(--caramel-brown), var(--dark-caramel));
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s;
}

.add-to-cart-btn:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 15px var(--shadow-hover);
}

.add-to-cart-btn:active {
    transform: scale(0.98);
}

.add-to-cart-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    opacity: 0.6;
}

/* === 장바구니 버튼 (고정) === */
.cart-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, var(--terracotta), #A55A4A);
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 24px;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(193, 123, 92, 0.4);
    z-index: 1001;
    transition: all 0.3s;
}

.cart-btn:hover {
    transform: scale(1.1);
}

.cart-count {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #FF6B6B;
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
}

/* === 오버레이 === */
.overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1002;
}

.overlay.active {
    display: block;
}

/* === 장바구니 사이드바 (개선됨) === */
.cart-sidebar {
    position: fixed;
    top: 0;
    right: -100%;
    width: 90%;
    max-width: 400px;
    height: 100%;
    background: white;
    box-shadow: -4px 0 20px rgba(0,0,0,0.2);
    z-index: 1003;
    transition: right 0.3s;
    display: flex;
    flex-direction: column;
    overflow: hidden; /* 전체 스크롤 활성화 */
}

.cart-sidebar.active {
    right: 0;
}

.cart-header {
    background: linear-gradient(135deg, var(--caramel-brown), var(--dark-caramel));
    color: white;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0; /* 헤더 고정 */
}

.cart-header h2 {
    font-size: 20px;
}

.close-btn {
    background: none;
    border: none;
    color: white;
    font-size: 36px;
    cursor: pointer;
    line-height: 1;
}

/* === 장바구니 본문 (전체 스크롤 영역) === */
.cart-body {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
}

.empty-cart {
    text-align: center;
    padding: 60px 20px;
    color: #999;
}

.empty-cart p:first-child {
    font-size: 60px;
}

.empty-cart p:last-child {
    font-size: 16px;
    margin-top: 10px;
}

/* === 장바구니 아이템 === */
.cart-item {
    background: var(--light-cream);
    border-radius: 10px;
    padding: 15px;
    margin-bottom: 10px;
    border: 2px solid var(--light-beige);
}

.cart-item-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 10px;
}

.cart-item-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--deep-brown);
    flex: 1;
}

.cart-item-remove {
    background: none;
    border: none;
    color: var(--terracotta);
    font-size: 24px;
    cursor: pointer;
    line-height: 1;
}

.cart-item-option {
    font-size: 13px;
    color: var(--medium-brown);
    margin-bottom: 10px;
}

.cart-item-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.quantity-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.quantity-btn {
    width: 30px;
    height: 30px;
    border: 2px solid var(--caramel-brown);
    background: white;
    color: var(--caramel-brown);
    border-radius: 6px;
    font-size: 18px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.quantity-btn:hover {
    background: var(--light-beige);
}

.quantity-display {
    font-size: 15px;
    font-weight: 600;
    min-width: 30px;
    text-align: center;
}

.cart-item-price {
    font-size: 16px;
    font-weight: 700;
    color: var(--caramel-brown);
}

/* === 구분선 (• • •) === */
.cart-divider {
    text-align: center;
    padding: 15px 0;
    color: var(--caramel-brown);
    font-size: 20px;
    letter-spacing: 8px;
}

/* === 배송 정보 폼 === */
.shipping-info {
    padding: 15px;
    background: var(--light-cream);
    border-top: 1px solid var(--light-beige);
}

.shipping-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--deep-brown);
    margin-bottom: 12px;
}

.form-group {
    margin-bottom: 12px;
}

.form-input,
.form-textarea {
    width: 100%;
    padding: 10px;
    border: 2px solid var(--light-beige);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
}

.form-input:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--caramel-brown);
}

.radio-group {
    display: flex;
    gap: 15px;
}

.radio-label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 14px;
}

.radio-label input[type="radio"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* === 장바구니 요약 === */
.cart-summary {
    padding: 15px;
    border-top: 1px solid var(--light-beige);
    background: white;
    flex-shrink: 0; /* 요약 부분 고정 */
}

.summary-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    font-size: 15px;
}

.summary-total {
    display: flex;
    justify-content: space-between;
    font-size: 18px;
    font-weight: 700;
    color: var(--deep-brown);
    margin: 15px 0;
    padding-top: 15px;
    border-top: 2px solid var(--light-beige);
}

.total-price {
    color: var(--terracotta);
    font-size: 20px;
}

.checkout-btn {
    width: 100%;
    padding: 15px;
    background: linear-gradient(135deg, var(--terracotta), #A55A4A);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s;
}

.checkout-btn:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 15px rgba(193, 123, 92, 0.4);
}

.payment-info {
    text-align: center;
    font-size: 13px;
    color: var(--medium-brown);
    margin-top: 10px;
}

/* === 모달 === */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 2000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 15px;
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal-header {
    background: linear-gradient(135deg, var(--caramel-brown), var(--dark-caramel));
    color: white;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    font-size: 20px;
}

.modal-close {
    background: none;
    border: none;
    color: white;
    font-size: 32px;
    cursor: pointer;
    line-height: 1;
}

.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.order-details-box {
    background: var(--light-cream);
    border: 2px solid var(--light-beige);
    border-radius: 10px;
    padding: 15px;
    white-space: pre-wrap;
    font-size: 14px;
    line-height: 1.6;
    margin-bottom: 15px;
    max-height: 300px;
    overflow-y: auto;
}

.copy-btn {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, var(--terracotta), #A55A4A);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    margin-bottom: 15px;
    transition: all 0.3s;
}

.copy-btn:hover {
    transform: scale(1.02);
}

.wechat-guide {
    text-align: center;
    color: var(--medium-brown);
    font-size: 14px;
    line-height: 1.6;
}

.wechat-guide strong {
    color: var(--terracotta);
    font-weight: 700;
}

.modal-footer {
    padding: 15px 20px;
    border-top: 2px solid var(--light-beige);
}

.modal-confirm-btn {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, var(--caramel-brown), var(--dark-caramel));
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s;
}

.modal-confirm-btn:hover {
    transform: scale(1.02);
}

/* === 푸터 === */
.footer {
    background: linear-gradient(135deg, var(--dark-caramel), var(--caramel-brown));
    color: white;
    text-align: center;
    padding: 30px 20px;
    margin-top: 40px;
}

.footer p {
    margin: 8px 0;
    font-size: 14px;
}

/* === 알림 메시지 === */
.notification {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--terracotta);
    color: white;
    padding: 15px 30px;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(193, 123, 92, 0.4);
    z-index: 3000;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* === 반응형 디자인 === */
@media (min-width: 768px) {
    .products-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 20px;
    }
    
    .cart-sidebar {
        width: 400px;
    }
}

@media (min-width: 1024px) {
    .products-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}
