/* 공통 기본 스타일 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Noto Sans KR', Arial, sans-serif;
    line-height: 1.6;
    color: #1f2933;
    background-color: #f7f6f2;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

main {
    flex: 1;
}

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

@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
}

/* 페이지 헤더 */
.page-header {
    background: #faf9f6;
    padding: 2rem;
    border-radius: 10px;
    border: 1px solid #e4e3dc;
    box-shadow: 0 2px 6px rgba(0,0,0,0.05);
    margin-bottom: 2rem;
    text-align: center;
}

/* 통계 카드 */
.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 2rem;
}

@media (max-width: 768px) {
    .stats {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
}

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

.stat-card {
    background: #faf9f6;
    padding: 1.5rem;
    border-radius: 10px;
    border: 1px solid #e4e3dc;
    box-shadow: 0 2px 6px rgba(0,0,0,0.05);
    text-align: center;
}

.stat-number {
    font-size: 2rem;
    font-weight: bold;
    color: #3498db;
}

.stat-label {
    color: #666;
    margin-top: 5px;
}

/* 검색 섹션 */
.search-section {
    background: #faf9f6;
    padding: 2rem;
    border-radius: 10px;
    border: 1px solid #e4e3dc;
    box-shadow: 0 2px 6px rgba(0,0,0,0.05);
    margin-bottom: 2rem;
}

.search-box {
    display: flex;
    gap: 10px;
    margin-bottom: 1rem;
}

.search-box input {
    flex: 1;
    padding: 12px;
    border: 2px solid #d0ccc2;
    border-radius: 6px;
    font-size: 16px;
    background: #f4f3ef;
    color: #1f2933;
    transition: background 0.2s ease, border-color 0.2s ease;
}

.search-box input:focus {
    outline: none;
    border-color: #c5c0b4;
    background: #f9f8f4;
}

.search-box button {
    padding: 12px 24px;
    background: #e0ded6;
    color: #1f2933;
    border: 1px solid #d0ccc2;
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
    transition: background 0.2s ease, border-color 0.2s ease;
}

.search-box button:hover {
    background: #d6d3c9;
    border-color: #c5c0b4;
}

/* 결과 섹션 */
.results-section {
    background: #faf9f6;
    padding: 2rem;
    border-radius: 10px;
    border: 1px solid #e4e3dc;
    box-shadow: 0 2px 6px rgba(0,0,0,0.05);
    position: relative;
    z-index: 1;
}

/* 잡지 그리드 */
.magazine-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

@media (max-width: 768px) {
    .magazine-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
        gap: 15px;
    }
}

@media (max-width: 480px) {
    .magazine-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 10px;
    }
}

.magazine-card {
    border: 1px solid #ddd;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.2s;
}

.magazine-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.magazine-cover-container {
    position: relative;
    overflow: hidden; /* transform으로 확대된 이미지가 밖으로 나가지 않도록 */
}

.magazine-cover {
    width: 100%;
    aspect-ratio: 3/4; /* 잡지 표준 비율 */
    object-fit: cover;
    background: #f0f0f0;
}

.search-unavailable-badge {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: rgba(220, 53, 69, 0.9);
    color: white;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.75em;
    font-weight: 600;
    backdrop-filter: blur(4px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.magazine-badge {
    position: absolute;
    top: 8px;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.7em;
    font-weight: 700;
    letter-spacing: 0.3px;
    color: #fff;
    backdrop-filter: blur(4px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.magazine-badge-new {
    left: 8px;
    background: rgba(46, 204, 113, 0.9);
}

.magazine-badge-hot {
    right: 8px;
    background: rgba(255, 107, 0, 0.9);
}

.magazine-info {
    padding: 15px;
}

.magazine-title {
    font-weight: bold;
    margin-bottom: 5px;
}

.magazine-issue {
    color: #666;
    font-size: 0.9em;
}

/* 잡지 상세 */
.magazine-detail {
    background: #faf9f6;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid #e4e3dc;
    box-shadow: 0 2px 6px rgba(0,0,0,0.05);
}

.magazine-header {
    padding: 20px;
    border-bottom: 1px solid #e4e3dc;
}

.back-btn {
    background: #e0ded6;
    color: #1f2933;
    border: 1px solid #d0ccc2;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    margin-bottom: 15px;
    transition: background 0.2s ease, border-color 0.2s ease;
}

.back-btn:hover {
    background: #d6d3c9;
    border-color: #c5c0b4;
}

.magazine-meta {
    color: #666;
    margin-top: 10px;
}

.magazine-meta p {
    margin: 5px 0;
}

/* 페이지 그리드 */
.pages-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 15px;
    padding: 20px;
    background: #faf9f6;
    border: 1px solid #e4e3dc;
    border-radius: 10px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.05);
}

.page-item {
    position: relative;
    text-align: center;
    cursor: pointer;
    border: 1px solid #e4e3dc;
    border-radius: 8px;
    padding: 10px;
    transition: all 0.2s ease;
    background: #faf9f6;
    overflow: visible; /* 뱃지가 잘리지 않도록 */
}

.page-item:hover {
    box-shadow: 0 4px 10px rgba(0,0,0,0.08);
    transform: translateY(-2px);
    border-color: #cfcbbf;
}


.page-thumbnail {
    width: 100%;
    aspect-ratio: 3/4; /* 잡지 표준 비율 */
    object-fit: cover;
    border-radius: 4px;
}

.page-number {
    margin-top: 8px;
    font-size: 14px;
    color: #666;
}

.page-number.page-number-badge {
    position: absolute;
    bottom: 8px;
    right: 8px;
    margin: 0;
    font-weight: 700;
    color: #3a3125;
    background: linear-gradient(135deg, #f7f6f2, #f0ebe2);
    border: 1px solid #dcd3c3;
    padding: 4px 9px;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    font-size: 12px;
}

/* 페이지 댓글 뱃지 */
.page-comment-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    background: #e67e22; /* 차분한 캐롯 오렌지 */
    color: white;
    border-radius: 12px;
    min-width: 22px;
    height: 22px;
    display: flex !important;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    border: 2px solid white;
    box-shadow: 0 2px 5px rgba(0,0,0,0.15);
    z-index: 999 !important;
    opacity: 1 !important;
    visibility: visible !important;
}

/* 페이지 카테고리 태그 */
.page-category-tag {
    position: absolute;
    bottom: 8px;
    left: 8px;
    background: linear-gradient(135deg, #f7f6f2, #f0ebe2);
    color: #3a3125;
    padding: 4px 9px;
    border-radius: 12px;
    font-size: 12px;
    border: 1px solid #dcd3c3;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-weight: 700;
}

/* 최신 댓글 페이지 스타일 */
.recent-comments-list {
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding: 20px 0;
}

.comment-card {
    background: #faf9f6;
    border-radius: 12px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.08);
    overflow: hidden;
    transition: all 0.3s ease;
    border: 1px solid #e4e3dc;
}

.comment-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.12);
    transform: translateY(-2px);
}

.comment-card-content {
    display: flex;
    gap: 16px;
    padding: 16px;
    cursor: pointer;
    background: linear-gradient(90deg, rgba(250,249,246,0.9), rgba(247,246,242,0.9));
}

.comment-card-thumbnail {
    position: relative;
    flex-shrink: 0;
    width: 80px;
    height: 107px; /* 3:4 비율 */
}

.comment-card-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 6px;
}

.comment-count-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    background: #e67e22; /* 차분한 캐롯 오렌지 */
    color: white;
    border-radius: 12px;
    min-width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.15);
}

.comment-card-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.comment-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.magazine-title {
    font-size: 16px;
    font-weight: bold;
    color: #333;
    margin: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

.page-info {
    font-size: 14px;
    color: #666;
    font-weight: 500;
    flex-shrink: 0;
}

.comment-card-meta {
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 13px;
    color: #666;
}

.comment-count {
    font-weight: 500;
}

.latest-date {
    color: #888;
}

.comment-previews {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.comment-preview {
    font-size: 13px;
    color: #1f2933;
    line-height: 1.4;
    padding: 6px 8px;
    background: #f4f3ef;
    border-radius: 6px;
    border-left: 3px solid #c5c0b4;
}

.comment-preview strong {
    color: #333;
}

.load-more-container {
    text-align: center;
    padding: 20px;
}

.no-results {
    text-align: center;
    padding: 60px 20px;
    color: #666;
}

.no-results p {
    margin: 8px 0;
    line-height: 1.6;
}

.no-results a {
    color: #3498db;
    text-decoration: none;
}

.no-results a:hover {
    text-decoration: underline;
}

/* 모바일 최적화 */
@media (max-width: 768px) {
    .comment-card-content {
        flex-direction: column;
        gap: 12px;
    }
    
    .comment-card-thumbnail {
        width: 60px;
        height: 80px;
        align-self: flex-start;
    }
    
    .magazine-title {
        font-size: 15px;
    }
    
    .comment-card-meta {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }
}

/* 로딩 및 에러 */
.loading {
    text-align: center;
    padding: 40px;
    color: #666;
}

.error {
    color: #e74c3c;
    background: #ffeaea;
    padding: 15px;
    border-radius: 4px;
    margin: 10px 0;
}

.success {
    color: #27ae60;
    background: #eafaf1;
    padding: 15px;
    border-radius: 4px;
    margin: 10px 0;
}

/* 버튼 스타일 */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    margin: 5px;
}

.btn-primary {
    background: #3498db;
    color: white;
}

.btn-success {
    background: #27ae60;
    color: white;
}

.btn-warning {
    background: #f39c12;
    color: white;
}

/* 커버 이미지 반쪽 자르기 (cover_page_number: "2left", "2right") */
.magazine-cover.cover-left {
    object-fit: cover;
    object-position: 0% center;
    /* 이미지를 왼쪽 정렬하여 왼쪽 절반만 보이도록 */
}

.magazine-cover.cover-right {
    object-fit: cover;
    object-position: 100% center;
    /* 이미지를 오른쪽 정렬하여 오른쪽 절반만 보이도록 */
}
