/* --- Gacha Log Modal Styles --- */

#gacha-log-modal .log-modal-content {
    width: 95%; /* 90% -> 95%로 너비 소폭 확장 */
    max-width: 1100px;
    height: 90vh; /* 85vh -> 90vh로 높이 확장 */
    border-radius: 16px;
    background: #fdfdfd;
    overflow-y: auto; /* 전체 컨텐츠 스크롤 적용 */
    display: block; /* flex 대신 block으로 자연스러운 흐름 유도 */
    position: relative;
}

/* 통계 영역 */
.gacha-log-stats {
    background: #f5f5f5;
    padding: 20px; /* 패딩 소폭 증가 */
    border-bottom: 1px solid #ddd;
    font-size: 0.75rem; /* 0.85rem -> 0.75rem 축소 */

}

.stat-row-top {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 10px;
}

.stat-category-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #e9e9e9;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
    user-select: none;
    transition: background 0.2s;
}
.stat-category-header:hover { background: #dedede; }
.stat-category-header.active .toggle-icon { transform: rotate(180deg); }
.stat-category-header .toggle-icon { transition: transform 0.2s; font-size: 0.7rem; }

.stat-header-thumb {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid #ddd;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.stat-header-thumb-container {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.stat-header-plan {
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 14px;
    height: 14px;
    z-index: 2;
    filter: drop-shadow(1px 1px 1px rgba(0,0,0,0.5));
}

.stat-row-bottom {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    padding: 10px 5px;
    background: #fff;
    border-radius: 0 0 6px 6px;
    border: 1px solid #e9e9e9;
    border-top: none;
}
.stat-row-bottom.hidden { display: none; }

.stat-item { display: flex; flex-direction: column; align-items: center; }
.stat-item.full-width { flex-direction: row; justify-content: space-between; align-items: center; }
.stat-label { color: #888; font-size: 0.7rem; font-weight: 600; } /* 0.8rem -> 0.7rem 축소, 색상도 연하게 보정 */
.stat-value { color: var(--primary-color); font-weight: bold; font-size: 0.85rem; } /* 1rem -> 0.85rem 축소 */

/* 리스트 그리드 영역 */
.gacha-log-list {
    padding: 20px;
    display: grid;
    /* 반응형 그리드: 리스트의 가로 폭을 더 넓게 쓰도록 최적화 */
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    grid-auto-rows: 130px;
    grid-auto-flow: dense;
    gap: 12px;
    padding-bottom: 50px; /* 마지막 아이템 가독성 확보 */
}

/* 공통 아이템 스타일 */
.log-item {
    position: relative;
    background: #fff;
    border-radius: 8px;
    border: 1px solid #eee;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    overflow: hidden;
    transition: transform 0.15s, box-shadow 0.15s;
    cursor: default;
}
.log-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    z-index: 2;
}

/* 등급별 테두리 포인트 */
.log-item.rarity-ssr { border: 1px solid #d4a5ff; box-shadow: 0 0 0 1px #d4a5ff inset; }
.log-item.rarity-sr { border: 1px solid #ffe082; box-shadow: 0 0 0 1px #ffe082 inset; }

/* 타입: 프로듀스 아이돌 (세로형 2칸 차지) */
.log-item.type-produce {
    grid-column: span 1;
    grid-row: span 2;
}
.log-item.type-produce .log-card-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* 타입: 서포트 카드 (가로형 1칸 차지) */
.log-item.type-support {
    grid-column: span 1;
    grid-row: span 1;
    display: block; /* 중앙 정렬용 flex 제거 */
    padding: 0; /* 패딩 제거하여 꽉 채움 */
    background-color: rgba(255, 255, 255, 0.2); /* 배경 이미지와 섞일 기본 색상 */
    background-size: cover;
    background-position: center;
    background-blend-mode: overlay; /* 이미지와 색상을 부드럽게 섞음 */
}

.log-item.type-support.rarity-ssr {
    background-image: url('../images/ssrbackground.jpg');
}

.log-item.type-support.rarity-sr {
    background-image: url('../images/srbackground.jpg');
}

.log-item.type-support .log-card-img {
    width: 100%;
    height: 100%;
    object-fit: contain; /* 비율 유지하며 꽉 채움 */
    background: transparent; /* 배경이 보이도록 투명화 */
    display: block;
    /* 흰색 테두리 효과 강화 (2px) */
    filter: 
        drop-shadow(2px 0 0 #fff) 
        drop-shadow(-2px 0 0 #fff) 
        drop-shadow(0 2px 0 #fff) 
        drop-shadow(0 -2px 0 #fff)
        drop-shadow(2px 2px 4px rgba(0,0,0,0.4));
}

/* 배지 (왼쪽 위 등급 이미지) */
.log-badge-rarity {
    position: absolute !important;
    top: 3px; 
    left: 3px;
    width: auto; /* 너비 자동 */
    height: 16px; /* 세로 높이 고정 */
    object-fit: contain;
    z-index: 10;
    filter: drop-shadow(1px 1px 1px rgba(0,0,0,0.5));
    pointer-events: none;
}

/* 카운트 (오른쪽 위) */
.log-badge-count {
    position: absolute;
    top: 3px; right: 3px;
    background: rgba(0, 0, 0, 0.65);
    color: #fff;
    font-size: 0.6rem;
    font-weight: bold;
    padding: 1px 5px;
    border-radius: 4px;
    z-index: 5;
}

/* 이름 (하단 오버레이) */
.log-item-name-overlay {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.8), rgba(0,0,0,0));
    color: #fff;
    font-size: 0.65rem;
    padding: 12px 4px 4px; /* 그라데이션 확보를 위한 상단 패딩 */
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-shadow: 0 1px 2px rgba(0,0,0,0.8);
}

/* 가챠 기록 모달 닫기 버튼 */
.close-log-modal {
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 24px;
    font-weight: bold;
    color: #666;
    cursor: pointer;
    z-index: 100;
    line-height: 1;
    transition: color 0.2s;
}
.close-log-modal:hover { color: var(--primary-color); }

@media (max-width: 768px) {
    .gacha-log-list {
        grid-template-columns: repeat(auto-fill, minmax(75px, 1fr));
        grid-auto-rows: 75px;
        padding: 10px;
        gap: 8px;
    }
    .log-badge-rarity { font-size: 0.55rem; padding: 1px 4px; }
    .log-item-name-overlay { font-size: 0.55rem; padding: 8px 2px 2px; }
    .stat-row-bottom { grid-template-columns: repeat(3, 1fr); font-size: 0.65rem; } /*0.7 -> 0.65 축소*/
    .close-log-modal { top: 5px; right: 10px; font-size: 20px; }
    
    /* 모바일 통계 폰트 정밀 축소 */
    .gacha-log-stats { font-size: 0.65rem; padding: 12px; }
    .stat-label { font-size: 0.6rem; }
    .stat-value { font-size: 0.75rem; }
    .stat-category-header { font-size: 0.7rem; padding: 6px 10px; }
    .stat-header-thumb { width: 22px; height: 22px; }
}
