/* ==========================================================================
   1. 기본 설정 (Variables & Reset)
   ========================================================================== */
:root {
    --ba-blue: #128CFF;
    --ba-cyan: #00D1FF;
    --ba-dark: #2B3A42;
    --ba-bg: #F3F7F8;
    --ba-gray: #D0D7DB;
    --tab-active: #FFE500;
    --bonus-pink: #ff4f94; 
}

* { box-sizing: border-box; }

body {
    font-family: 'Noto Sans KR', sans-serif;
    background-color: var(--ba-bg);
    color: var(--ba-dark);
    margin: 0;
    padding: 20px;
    display: flex;
    justify-content: center;
    min-height: 100vh;
}

.container {
    width: 100%;
    max-width: 900px;
    background: white;
    border-radius: 15px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.05);
    padding: 25px;
    overflow: hidden;
}

h1 {
    text-align: center;
    color: var(--ba-blue);
    margin-bottom: 20px;
    font-weight: 800;
}

/* ==========================================================================
   2. 상단 탭 (Tabs)
   ========================================================================== */
.shop-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 25px;
    justify-content: center;
    flex-wrap: wrap;
}

.tab-btn {
    padding: 10px 15px;
    border: 2px solid var(--ba-gray);
    background: white;
    border-radius: 30px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
    flex: 1;
    text-align: center;
    color: #777;
    min-width: 100px;
    white-space: nowrap;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tab-btn.active {
    background-color: #2E4764;
    border-color: #2E4764;
    color: #FAD50A;
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(46, 71, 100, 0.4);
}

.tab-icon {
    width: 30px;
    height: 30px;
    object-fit: contain;
    margin-right: 6px;
}

/* ==========================================================================
   3. 아이템 카드 (Item Card)
   ========================================================================== */
.shop-section { display: none; }

.shop-section.active {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px; 
    margin-bottom: 30px;
    width: 100%;
}

.item-card {
    border: 2px solid #eee;
    border-radius: 12px;
    padding: 10px;
    text-align: center;
    background: #fff;
    position: relative;
    transition: all 0.15s cubic-bezier(0.25, 0.8, 0.25, 1);
    box-shadow: 0 4px 6px rgba(0,0,0,0.04); 
    cursor: pointer;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-width: 0;
}

.item-card:not(.disabled):hover {
    transform: translateY(3px);
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
    border-color: #ddd;
}

.item-card.selected {
    border-color: var(--ba-blue);
    background-color: #F0F9FF;
    box-shadow: 0 1px 2px rgba(18, 140, 255, 0.2);
    transform: translateY(3px);
}

.item-card.disabled {
    opacity: 0.6;
    background-color: #f9f9f9;
    pointer-events: none;
    box-shadow: none;
}

/* 체크박스 숨김 (기능만 유지) */
.item-checkbox {
    position: absolute;
    opacity: 0;
    width: 0; height: 0;
    pointer-events: none;
    z-index: -1;
}

/* 카드 내부 요소 */
.card-top {
    margin-bottom: 8px;
    border-bottom: 1px dashed #eee;
    padding-bottom: 8px;
}

.item-name {
    font-size: 0.85rem;
    font-weight: bold;
    color: #333;
    margin-bottom: 5px;
    white-space: pre-line;
    display: -webkit-box;
    -webkit-line-clamp: 2; 
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    height: 2.6em; 
    line-height: 1.3;
    padding: 0 2px;
}

.img-box {
    width: 75px;
    height: 75px;
    margin: 0 auto 8px;
    background: #fafafa;
    border-radius: 10px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #e0e0e0;
}

.img-box img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.limit-badge {
    font-size: 0.7rem;
    background: #f0f0f0;
    color: #666;
    padding: 2px 6px;
    border-radius: 10px;
    display: inline-block;
    border: 1px solid #ddd;
    margin-bottom: 5px;
}

.limit-badge.unlimited {
    background-color: #E8F5E9;
    color: #2E7D32;
    border-color: #C8E6C9;
    font-weight: bold;
}

.price-tag {
    background-color: #EAF4FF;
    color: #128CFF;
    border-radius: 5px;
    padding: 4px 0;
    font-size: 0.85rem;
    font-weight: bold;
    margin: 0;
}

.price-tag span {
    font-size: 0.7rem;
    color: #7F9EB8;
    margin-right: 3px;
    font-weight: normal;
}

/* 카드 하단 컨트롤 (슬라이더/입력) */
.control-row {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: auto;
}

input[type=range] {
    flex: 1;
    cursor: pointer;
    accent-color: var(--ba-blue);
    height: 5px;
    min-width: 0;
}

.qty-input-sm {
    width: 60px;
    padding: 6px 4px;
    border: 1px solid #ccc;
    border-radius: 6px;
    text-align: center;
    font-weight: bold;
    font-size: 0.9rem;
    background: white;
    box-sizing: border-box;
}

.qty-input-sm:focus {
    border-color: var(--ba-blue);
    outline: none;
}

/* ==========================================================================
   4. 계산 결과 영역 (Result Area)
   ========================================================================== */
.calc-area {
    background-color: #FAFAFA;
    border-top: 2px dashed var(--ba-gray);
    padding-top: 20px;
    margin-top: 20px;
}

.row { 
    display: flex; 
    gap: 20px; 
    margin-bottom: 40px; 
    flex-wrap: wrap; 
}

.col { 
    flex: 1; 
    min-width: 250px;
}

label { display: block; font-size: 0.9rem; font-weight: bold; color: #555; margin-bottom: 5px;}
select, .main-input { padding: 10px; border: 2px solid #ccc; border-radius: 8px; width: 100%; box-sizing: border-box; }
.main-input[readonly] { background: #eee; color: var(--ba-blue); font-weight: bold; }

/* 추천 스테이지 박스 */
.recommend-box {
    background: #fff;
    border: 2px solid var(--ba-blue);
    border-radius: 10px;
    padding: 15px;
    text-align: center;
    box-shadow: 0 4px 10px rgba(18, 140, 255, 0.1);
    height: auto;
    min-height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.rec-label { font-size: 0.75rem; color: #999; font-weight: bold; letter-spacing: 1px; margin-bottom: 5px; }
.rec-name { font-size: 1.3rem; font-weight: 900; color: var(--ba-blue); margin-bottom: 5px; white-space: nowrap; }
.rec-info { font-size: 0.85rem; color: #555; background: #f0f9ff; padding: 4px 10px; border-radius: 15px; display: inline-block; }

/* 결과 박스 */
.result-box {
    background: linear-gradient(135deg, var(--ba-blue), var(--ba-cyan));
    color: white;
    padding: 25px;
    border-radius: 15px;
    margin-top: 50px;
    text-align: center;
    box-shadow: 0 10px 25px rgba(18, 140, 255, 0.4);
    position: relative;
    z-index: 5;
}

.res-title { font-size: 1rem; opacity: 0.9; margin-bottom: 5px; }
.res-value { font-size: 2.2rem; font-weight: 900; margin: 10px 0; line-height: 1.2; }
.res-sub { font-size: 0.9rem; margin-top: 5px; opacity: 0.9; }

.res-surplus {
    font-size: 0.95rem;
    line-height: 1.5;
    color: white;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px dashed rgba(255,255,255,0.4);
    animation: fadeIn 0.5s ease-in-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

/* 결과창 아이템 스타일 */
.gain-item {
    position: relative;
    display: inline-flex;
    align-items: center;
    margin: 0 6px;
    background: white;
    padding: 4px 8px;
    border-radius: 8px;
    border: 2px solid #E0E0E0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

/* 결과창 전용 보너스 배지 (JS에서 사용) */
.bonus-badge {
    position: absolute;
    top: -8px; right: -5px;
    background-color: var(--bonus-pink);
    color: white;
    font-size: 0.6rem;
    font-weight: bold;
    padding: 2px 6px;
    border-radius: 10px;
    box-shadow: 0 2px 2px rgba(0,0,0,0.2);
    z-index: 10;
    line-height: 1;
    border: 1px solid #fff;
}

/* ==========================================================================
   5. 하단 드랍 테이블 (Drop Table)
   ========================================================================== */
.drop-info-area {
    margin-top: 40px;
    border-top: 2px dashed #eee;
    padding-top: 20px;
}

.drop-info-area h2 { font-size: 1.2rem; color: #555; margin-bottom: 15px; text-align: center; }

.drop-table-header {
    display: flex;
    justify-content: space-between;
    padding: 0 15px 8px;
    font-size: 0.85rem;
    font-weight: bold;
    color: #999;
    border-bottom: 1px solid #eee;
    margin-bottom: 10px;
}

.stage-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: white;
    border: 1px solid #eee;
    border-radius: 10px;
    padding: 12px 15px;
    margin-bottom: 8px;
    transition: 0.2s;
}

.stage-row:hover {
    border-color: var(--ba-cyan);
    box-shadow: 0 2px 8px rgba(0, 209, 255, 0.1);
}

.stage-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 120px;
}

.stage-title { font-weight: bold; color: #333; font-size: 0.95rem; }
.stage-ap-badge { font-size: 0.75rem; color: #888; background: #f5f5f5; padding: 2px 6px; border-radius: 4px; width: fit-content; }

.stage-items {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
}

/* 드랍 아이템 박스 */
.drop-badge {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px; height: 48px;
    margin: 3px;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    vertical-align: middle;
}

.drop-badge.bonus-item { border-color: #d0d0d0; }

.drop-badge img {
    width: 100%; height: 100%;
    object-fit: contain;
    padding: 4px;
    box-sizing: border-box;
}

/* 드랍 테이블 수량 텍스트 */
.drop-badge span:not(.table-bonus-badge) {
    position: absolute;
    bottom: 0px; right: 2px;
    font-size: 0.8rem;
    font-family: sans-serif;
    font-weight: 900;
    color: #333;
    text-shadow: -1px -1px 0 #fff, 1px -1px 0 #fff, -1px 1px 0 #fff, 1px 1px 0 #fff, 0px 0px 3px rgba(255,255,255,0.8);
    line-height: 1;
    pointer-events: none;
}

/* 드랍 테이블 보너스 배지 */
.table-bonus-badge {
    position: absolute;
    top: -5px; right: -5px;
    background-color: var(--bonus-pink);
    color: white;
    font-size: 10px;
    font-weight: 700;
    font-family: sans-serif;
    padding: 1px 6px;
    border-radius: 10px;
    box-shadow: 1px 1px 3px rgba(0,0,0,0.3);
    z-index: 10;
    pointer-events: none;
}

/* --- 공통 아이콘 --- */
.mini-icon { width: 18px; height: 18px; object-fit: contain; vertical-align: middle; margin-right: 2px; }
.mini-icon-white { width: 16px; height: 16px; object-fit: contain; vertical-align: middle; background: rgba(255,255,255,0.2); border-radius: 50%; }

/* ==========================================================================
   6. AP 계산기 위젯
   ========================================================================== */
.ap-widget {
    position: fixed;
    top: 20px; left: 20px;
    background: white;
    padding: 0;
    border-radius: 15px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    border: 2px solid var(--ba-blue);
    width: 240px;
    z-index: 1000;
    font-family: 'Noto Sans KR', sans-serif;
    overflow: hidden;
    transition: all 0.3s ease;
}

.ap-header {
    font-size: 0.9rem; font-weight: bold; color: white; background-color: var(--ba-blue);
    padding: 10px 15px; display: flex; justify-content: space-between; align-items: center; cursor: pointer;
}

.ap-body { padding: 15px; transition: all 0.3s ease; }
.ap-body.hidden { display: none; }

.ap-input-row { display: flex; align-items: center; justify-content: center; gap: 5px; margin-bottom: 10px; }

/* Spinner 제거 */
input[type=number]::-webkit-inner-spin-button, 
input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }

.ap-input-row input {
    width: 80px; padding: 8px; text-align: center; border: 1px solid #ccc; border-radius: 5px;
    font-weight: bold; font-size: 1.1rem; -moz-appearance: textfield;
}
.ap-input-row input:focus { border-color: var(--ba-blue); outline: none; }

.ap-btn {
    width: 35px; height: 35px; background-color: #F0F9FF;
    border: 1px solid var(--ba-blue);
    border-radius: 5px; color: var(--ba-blue);
    font-weight: bold; font-size: 1.2rem;
    cursor: pointer; display: flex; align-items: center; justify-content: center; padding: 0;
}
.ap-btn:active { background-color: #dfefff; transform: scale(0.95); }

.max-ap-text { font-weight: 900; color: #555; font-size: 1rem; margin-left: 5px; }
.slash { font-weight: bold; color: #ccc; }
.ap-result { text-align: center; font-size: 0.85rem; color: #555; background: #F0F9FF; padding: 8px; border-radius: 8px; }

/* ==========================================================================
   7. 반응형 (Media Queries)
   ========================================================================== */
/* 태블릿/좁은 PC (AP 위젯 고정 해제) */
@media (max-width: 1100px) {
    body { flex-direction: column; align-items: center; }
    .ap-widget { position: static; width: 100%; max-width: 900px; margin-bottom: 20px; }
    .ap-header { border-radius: 10px 10px 0 0; }
}

/* 그리드 3열 변경 (800px 이하) */
@media (max-width: 800px) {
    .shop-section.active { grid-template-columns: repeat(3, 1fr); }
}

/* 모바일 (500px 이하) */
@media (max-width: 500px) {
    .container { padding: 15px; }
    .shop-section.active { gap: 8px; }
    .qty-input-sm { width: 35px; font-size: 0.8rem; }
    .img-box { width: 50px; height: 50px; }
    
    /* 드랍 테이블 세로 배치 */
    .stage-row { flex-direction: column; align-items: flex-start; gap: 10px; }
    .stage-items { width: 100%; justify-content: flex-start; }
    .drop-table-header { display: none; }
}
/* =========================================
   [NEW] 드랍 테이블 3단 분리 (기본 vs 보너스)
   ========================================= */

/* 전체 줄 */
.stage-row {
    display: flex;
    align-items: center;
    background: white;
    border: 1px solid #eee;
    border-radius: 10px;
    padding: 10px 15px;
    margin-bottom: 8px;
    gap: 10px;
}

/* 1. 지역 정보 (고정 너비) */
.stage-info {
    width: 110px;
    flex-shrink: 0;
    border-right: 1px dashed #eee;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* 2. 기본 드랍 영역 (중간) */
.base-area {
    flex: 1; /* 남은 공간 차지 */
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    justify-content: center; /* 중앙 정렬 */
}

/* 3. 보너스 추가분 영역 (우측) */
.bonus-area {
    flex: 1; /* 남은 공간 차지 */
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    justify-content: flex-end; /* 우측 정렬 */
    padding-left: 10px;
    border-left: 2px solid #f0f0f0; /* 구분선 */
    background-color: #fafafa;      /* 배경색 살짝 다르게 */
    padding: 5px;
    border-radius: 8px;
    min-height: 40px;
    align-items: center;
}

/* --- 아이템 박스 스타일 --- */
.drop-badge {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 45px;
    height: 45px;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.drop-badge img {
    width: 100%; height: 100%;
    object-fit: contain;
    padding: 4px;
}

.drop-badge span:not(.table-bonus-badge) {
    position: absolute;
    bottom: 0; right: 2px;
    font-size: 0.75rem;
    font-weight: 900;
    color: #333;
    text-shadow: -1px -1px 0 #fff, 1px 1px 0 #fff, 0 0 3px white;
}

/* --- [핵심] 보너스 재화 전용 스타일 --- */
.drop-badge.bonus-drop {
    border-color: #FF4081;   /* 핑크색 테두리 */
    background-color: #FFF0F5; /* 연한 핑크 배경 */
}

.drop-badge.bonus-drop span:not(.table-bonus-badge) {
    color: #D81B60; /* 글자도 핑크색 */
}

/* Bonus 뱃지 */
.table-bonus-badge {
    position: absolute;
    top: -6px; right: -6px;
    background-color: #FF4081;
    color: white;
    font-size: 9px;
    font-weight: bold;
    padding: 1px 5px;
    border-radius: 8px;
    box-shadow: 1px 1px 2px rgba(0,0,0,0.2);
    z-index: 5;
}

/* 모바일 대응 */
@media (max-width: 700px) {
    .stage-row {
        flex-direction: column;
        align-items: stretch;
    }
    .stage-info {
        width: 100%;
        border-right: none;
        border-bottom: 1px dashed #eee;
        padding-bottom: 5px;
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }
    .base-area, .bonus-area {
        justify-content: flex-start; /* 모바일은 왼쪽 정렬 */
        border-left: none;
    }
    .bonus-area {
        background-color: #fff5f8; /* 모바일에서 보너스 영역 더 잘 보이게 */
    }
}


