/* ================================================
   아이템 상세 페이지 CSS
   ================================================ */

.detail-main {
    background: #FBFFF1;
    min-height: calc(100vh - 120px);
    padding: 40px 0;
}

.detail-grid {
    display: grid;
    grid-template-columns: 380px 1fr;
    gap: 30px;
    margin-top: 20px;
}

/* ================================================
   왼쪽 섹션 - 아이템 정보
   ================================================ */

.left-section {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* 아이템 카드 */
.item-card {
    background: linear-gradient(135deg, #4a4556 0%, #3C3744 100%);
    border-radius: 16px;
    padding: 0;
    color: white;
    box-shadow: 0 8px 24px rgba(0,0,0,0.3);
    overflow: hidden;
}

.item-card-header {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 24px;
    background: rgba(0,0,0,0.2);
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.item-image {
    width: 100px;
    height: 100px;
    border-radius: 12px;
    border: 3px solid rgba(180, 197, 228, 0.4);
    background: rgba(255,255,255,0.05);
    padding: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.item-info {
    flex: 1;
}

.item-title {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 8px;
    color: white;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.item-server {
    font-size: 14px;
    color: rgba(255,255,255,0.7);
    margin-bottom: 6px;
}

.item-rank {
    font-size: 13px;
    color: #B4C5E4;
    font-weight: 600;
    background: rgba(180, 197, 228, 0.2);
    padding: 4px 12px;
    border-radius: 12px;
    display: inline-block;
}

/* 통계 - 3x2 그리드 */
.item-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(2, auto);
    gap: 1px;
    background: rgba(255,255,255,0.1);
    padding: 0;
}

.stat-row {
    display: flex;
    flex-direction: column;
    padding: 15px 12px;
    border: none;
    background: rgba(0,0,0,0.15);
    overflow: hidden;
}

/* 1번째 줄: 최신가격, 전일가격, 전일대비 */
.stat-row:nth-child(1),
.stat-row:nth-child(2),
.stat-row:nth-child(3) {
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

/* 2번째 줄: 변동율 (1칸), 그래프 (2칸) */
.stat-row:nth-child(4) {
    /* 변동율 */
}

.stat-row:nth-child(5) {
    /* 그래프 */
    grid-column: span 2;
    padding: 10px 12px;
}

.stat-label {
    font-size: 11px;
    color: rgba(255,255,255,0.6);
    margin-bottom: 6px;
    font-weight: 500;
}

.stat-value {
    font-size: 13px;
    font-weight: 700;
    color: white;
    white-space: nowrap;
    word-break: keep-all;
    letter-spacing: -0.5px;
}
    white-space: nowrap;
    word-break: keep-all;
}

/* 미니 그래프 */
.stat-mini-chart {
    margin-top: 8px;
    height: 50px;
}

.stat-mini-chart canvas {
    width: 100% !important;
    height: 50px !important;
}

/* 연관 아이템 */
.related-items {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.section-title {
    font-size: 16px;
    font-weight: 700;
    color: #2C2C2C;
    margin-bottom: 16px;
}

#relatedItemsList {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.related-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: 8px;
    background: #f8f9fa;
    text-decoration: none;
    transition: all 0.2s;
}

.related-item:hover {
    background: #e9ecef;
    transform: translateX(4px);
}

.related-item-image {
    width: 40px;
    height: 40px;
    border-radius: 6px;
    border: 2px solid #e0e0e0;
}

.related-item-info {
    flex: 1;
}

.related-item-name {
    font-size: 14px;
    font-weight: 600;
    color: #2C2C2C;
    margin-bottom: 4px;
}

.related-item-price {
    font-size: 12px;
    color: #666;
}

/* ================================================
   오른쪽 섹션 - 그래프 & 가격 내역
   ================================================ */

.right-section {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* 그래프 섹션 */
.chart-section {
    background: white;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    margin-top: 0;
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.date-range-selector {
    display: flex;
    align-items: center;
    gap: 12px;
}

.date-range-selector label {
    font-size: 14px;
    color: #666;
    font-weight: 500;
}

.date-range-selector input[type="date"] {
    padding: 8px 12px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-size: 13px;
    color: #2C2C2C;
    background: white;
    cursor: pointer;
    transition: border-color 0.2s;
}

.date-range-selector input[type="date"]:hover {
    border-color: #B4C5E4;
}

.date-range-selector input[type="date"]:focus {
    outline: none;
    border-color: #3C3744;
}

.chart-container {
    position: relative;
    height: 350px;
}

/* 가격 내역 섹션 */
.price-history-section {
    background: white;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.table-container {
    overflow-x: auto;
}

.price-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.price-table thead {
    background: #f8f9fa;
    border-bottom: 2px solid #e0e0e0;
}

.price-table th {
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    color: #2C2C2C;
    font-size: 13px;
}

.price-table tbody tr {
    border-bottom: 1px solid #f0f0f0;
    transition: background 0.2s;
}

.price-table tbody tr:hover {
    background: #f8f9fa;
}

.price-table tbody tr:last-child {
    border-bottom: none;
}

.price-table td {
    padding: 14px 16px;
    color: #333;
}

.price-table td:nth-child(1) {
    color: #666;
    font-size: 13px;
}

.price-table td:nth-child(2) {
    font-weight: 600;
    color: #2C2C2C;
}

/* ================================================
   반응형
   ================================================ */

@media (max-width: 1024px) {
    .detail-grid {
        grid-template-columns: 1fr;
    }

    .left-section {
        grid-row: 2;
    }

    .right-section {
        grid-row: 1;
    }
}

@media (max-width: 640px) {
    /* 3단계: 6.1인치 상세 페이지 최적화 */
    .detail-main { padding: 15px 0 !important; }
    
    /* 부모 컨테이너를 Flex로 강제 설정하여 순서(order) 작동 보장 */
    .detail-grid { 
        display: flex !important;
        flex-direction: column !important; 
        gap: 20px !important; 
    }

    /* 순서 명시: 정보 카드(1) -> 그래프(2) */
    .left-section { order: 1 !important; display: flex !important; flex-direction: column !important; }
    .right-section { order: 2 !important; display: flex !important; flex-direction: column !important; }

    /* 아이템 카드 헤더 최적화 */
    .item-card-header {
        padding: 20px !important;
        flex-direction: row !important; /* 6.1인치 가로 충분하므로 유지하되 크기 조절 */
        text-align: left !important;
        gap: 15px !important;
    }
    .item-image { width: 70px !important; height: 70px !important; padding: 5px !important; }
    .item-title { font-size: 18px !important; }

    /* ★ 통계 그리드 재설계 (3열 -> 2열) */
    .item-stats {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    .stat-row:nth-child(3) { border-bottom: 1px solid rgba(255,255,255,0.1); } /* 구분선 보정 */
    .stat-row:nth-child(5) { grid-column: span 2 !important; } /* 그래프는 꽉 차게 */

    /* 그래프 섹션 다이어트 */
    .chart-section { padding: 15px !important; }
    .chart-header { flex-direction: column !important; align-items: flex-start !important; gap: 10px; }
    .date-range-selector { width: 100% !important; display: grid !important; grid-template-columns: 1fr 1fr; gap: 5px; }
    .date-range-selector label { display: none; } /* 공간 절약 */
    .chart-container { height: 280px !important; }

    /* 가격 내역 표 */
    .price-history-section { padding: 15px !important; }
    .price-table { font-size: 11px !important; }
    .price-table th, .price-table td { padding: 10px 5px !important; }

    /* 모바일 호버 효과 제거 */
    .related-item:hover { transform: none !important; background: #f8f9fa !important; }
    .price-table tbody tr:hover { background: transparent !important; }
    .btn-diff:hover, .btn-mode:hover { background-color: white !important; border-color: #E0E0E0 !important; }
    .btn-diff.active:hover, .btn-mode.active:hover { background-color: #B4C5E4 !important; }
}
