/* ===== ENHANCED REPORT VIEWER STYLES ===== */

/* ===== LOADING & ERROR STATES ===== */
.report-loading {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 60vh;
    text-align: center;
}

.report-loading .loading-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.report-loading .korean-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid #e2e8f0;
    border-top-color: #6B46C1;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.report-loading p {
    color: #64748b;
    font-size: 15px;
}

.report-error {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 60vh;
    text-align: center;
}

.report-error .error-content {
    max-width: 400px;
}

.report-error .error-icon {
    font-size: 48px;
    display: block;
    margin-bottom: 16px;
}

.report-error h2 {
    color: #1a1a2e;
    margin-bottom: 8px;
}

.report-error p {
    color: #64748b;
}

/* ===== DYNAMIC CONTENT ===== */
.section-body {
    line-height: 1.9;
    font-size: 15px;
    color: #2d2d3a;
}

.section-body h3 {
    color: #6B46C1;
    margin: 24px 0 12px;
    font-size: 18px;
}

.section-body h4 {
    color: #1a1a2e;
    margin: 16px 0 8px;
}

.section-body p {
    margin-bottom: 12px;
}

.section-body ul, .section-body ol {
    margin: 8px 0 16px 20px;
}

.section-body li {
    margin-bottom: 6px;
}

.section-body strong {
    color: #6B46C1;
}

.chapter-pages-badge {
    display: inline-block;
    background: #f1f5f9;
    color: #64748b;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.report-viewer {
    margin: 0;
    padding: 0;
    background: var(--gray-100);
    font-family: 'Noto Sans KR', sans-serif;
}

/* ===== REPORT HEADER ===== */
.report-header {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: var(--white);
    border-bottom: 1px solid var(--gray-200);
    box-shadow: var(--shadow-sm);
}

.header-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-md) var(--spacing-lg);
    max-width: 100%;
}

.header-left {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    flex: 1;
}

.back-link {
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--white);
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-md);
    font-weight: 600;
    color: var(--gray-700);
    text-decoration: none;
    transition: all var(--transition-base);
    white-space: nowrap;
}

.back-link:hover {
    border-color: var(--primary-purple);
    color: var(--primary-purple);
}

.report-main-title {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--gray-900);
}

.header-actions {
    display: flex;
    gap: var(--spacing-sm);
}

.action-btn {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--white);
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-md);
    font-weight: 600;
    color: var(--gray-700);
    cursor: pointer;
    transition: all var(--transition-base);
}

.action-btn:hover {
    border-color: var(--primary-purple);
    color: var(--primary-purple);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* ===== MAIN LAYOUT: SIDEBAR + CONTENT ===== */
.report-layout {
    display: flex;
    height: calc(100vh - 73px);
    overflow: hidden;
}

/* ===== TOC SIDEBAR ===== */
.toc-sidebar {
    width: 280px;
    background: var(--white);
    border-right: 1px solid var(--gray-200);
    overflow-y: auto;
    flex-shrink: 0;
}

.toc-header {
    padding: var(--spacing-lg);
    border-bottom: 2px solid var(--gray-200);
    position: sticky;
    top: 0;
    background: var(--white);
    z-index: 10;
}

.toc-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: var(--spacing-xs);
    color: var(--gray-900);
}

.total-pages {
    font-size: 0.875rem;
    color: var(--gray-600);
}

.toc-nav {
    padding: var(--spacing-md);
}

.toc-section {
    margin-bottom: 2px;
}

.toc-chapter {
    display: block;
    padding: 7px 14px;
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: var(--gray-700);
    font-size: 0.78rem;
    line-height: 1.3;
    transition: all var(--transition-base);
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.toc-chapter:hover {
    background: var(--gray-100);
    color: var(--gray-900);
}

.toc-chapter.active {
    background: var(--gradient-card);
    color: var(--primary-purple);
    font-weight: 700;
    border-left: 3px solid var(--primary-purple);
}

.chapter-num {
    font-weight: 700;
    color: var(--primary-purple);
    margin-right: 4px;
}

.chapter-title {
    font-weight: 500;
}

.chapter-page {
    font-size: 0.75rem;
    color: var(--gray-500);
    white-space: nowrap;
}

.toc-subsections {
    margin-left: var(--spacing-md);
    margin-top: var(--spacing-xs);
    display: none;
}

.toc-section:hover .toc-subsections,
.toc-chapter.active+.toc-subsections {
    display: block;
}

.toc-subsection {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: var(--spacing-xs);
    align-items: center;
    padding: var(--spacing-xs) var(--spacing-sm);
    font-size: 0.8125rem;
    color: var(--gray-700);
    text-decoration: none;
    border-radius: var(--radius-sm);
    transition: all var(--transition-base);
}

.toc-subsection:hover {
    background: var(--gray-100);
    color: var(--primary-purple);
}

.toc-subsection .dots {
    border-bottom: 1px dotted var(--gray-300);
    flex: 1;
    min-width: 20px;
}

/* ===== REPORT MAIN CONTENT ===== */
.report-main {
    flex: 1;
    overflow-y: auto;
    background: var(--gray-100);
}

.report-pages {
    max-width: 900px;
    margin: 0 auto;
    padding: var(--spacing-xl);
}

.report-page {
    background: var(--white);
    padding: var(--spacing-3xl);
    margin-bottom: var(--spacing-xl);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    position: relative;
    min-height: 800px;
}

.page-number {
    position: absolute;
    top: var(--spacing-md);
    right: var(--spacing-md);
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--gray-400);
}

/* ===== COVER PAGE ===== */
.cover-page {
    background: linear-gradient(135deg, #1E1B4B 0%, #4C1D95 100%);
    color: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    min-height: 1000px;
}

.cover-pattern {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><circle cx="50" cy="50" r="40" fill="none" stroke="rgba(255,255,255,0.1)" stroke-width="1"/><path d="M50 10 L50 90 M10 50 L90 50" stroke="rgba(255,255,255,0.1)" stroke-width="1"/></svg>');
    opacity: 0.3;
}

.cover-content {
    position: relative;
    z-index: 1;
    text-align: center;
}

.cover-ornament-top {
    width: 150px;
    height: 3px;
    background: linear-gradient(90deg, transparent, #FFD700, transparent);
    margin: 0 auto var(--spacing-xl);
}

.cover-name {
    font-family: 'Noto Serif KR', serif;
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: var(--spacing-lg);
}

.cover-year {
    font-family: 'Noto Serif KR', serif;
    font-size: 3rem;
    font-weight: 900;
    margin-bottom: var(--spacing-md);
    letter-spacing: 2px;
}

.cover-type {
    font-family: 'Noto Serif KR', serif;
    font-size: 2.5rem;
    font-weight: 700;
    color: #FFD700;
    margin-bottom: var(--spacing-xl);
}

.cover-divider {
    width: 200px;
    height: 3px;
    background: linear-gradient(90deg, transparent, #FFD700, transparent);
    margin: var(--spacing-xl) auto;
}

.cover-info {
    margin-bottom: var(--spacing-2xl);
}

.info-item {
    font-size: 1.125rem;
    margin-bottom: var(--spacing-sm);
    color: rgba(255, 255, 255, 0.9);
}

.cover-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
    font-size: 1.25rem;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.7);
}

.logo-icon {
    font-size: 1.5rem;
}

/* ===== CONTENT PAGES ===== */
.content-page {
    background: var(--white);
}

.chapter-title {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: var(--spacing-lg);
    color: var(--gray-900);
    border-bottom: 3px solid var(--primary-purple);
    padding-bottom: var(--spacing-md);
}

.chapter-intro {
    font-size: 1.125rem;
    line-height: 1.8;
    color: var(--gray-700);
    margin-bottom: var(--spacing-xl);
}

.section-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: var(--spacing-lg);
    color: var(--gray-900);
    border-left: 4px solid var(--primary-purple);
    padding-left: var(--spacing-md);
}

/* ===== SAJU TABLE ===== */
.saju-table-container {
    margin: var(--spacing-xl) 0;
    background: var(--gradient-card);
    padding: var(--spacing-xl);
    border-radius: var(--radius-lg);
}

.saju-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--white);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.saju-table th,
.saju-table td {
    padding: var(--spacing-md);
    text-align: center;
    border: 1px solid var(--gray-200);
}

.saju-table th {
    background: var(--gradient-primary);
    color: var(--white);
    font-weight: 700;
}

.saju-table .label {
    background: var(--gray-100);
    font-weight: 600;
}

.saju-table .hanja {
    font-family: 'Noto Serif KR', serif;
    font-size: 2rem;
    font-weight: 700;
    padding: var(--spacing-lg);
}

.saju-table .small {
    display: block;
    font-size: 0.75rem;
    font-weight: 400;
    margin-top: var(--spacing-xs);
    font-family: 'Noto Sans KR', sans-serif;
}

.saju-table .wood {
    color: #10B981;
}

.saju-table .fire {
    color: #EF4444;
}

.saju-table .earth {
    color: #F59E0B;
}

.saju-table .metal {
    color: #6B7280;
}

.saju-table .water {
    color: #3B82F6;
}

/* ===== ELEMENT LEGEND ===== */
.element-legend {
    display: flex;
    justify-content: center;
    gap: var(--spacing-md);
    margin: var(--spacing-lg) 0;
    flex-wrap: wrap;
}

.element-legend .element {
    padding: var(--spacing-xs) var(--spacing-md);
    background: var(--gray-100);
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 600;
}

/* ===== CHARACTERISTICS ===== */
.characteristics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: var(--spacing-lg);
    margin-top: var(--spacing-xl);
}

.char-section h4 {
    font-size: 1.125rem;
    font-weight: 700;
    margin-bottom: var(--spacing-md);
    color: var(--gray-900);
}

.char-section ul {
    list-style: none;
    padding: 0;
}

.char-section li {
    padding: var(--spacing-sm) 0;
    border-bottom: 1px solid var(--gray-200);
    line-height: 1.6;
}

.char-section li:last-child {
    border-bottom: none;
}

/* ===== ELEMENT ANALYSIS ===== */
.element-analysis {
    margin-top: var(--spacing-xl);
}

.element-bars {
    margin-bottom: var(--spacing-xl);
}

.element-bar-item {
    display: grid;
    grid-template-columns: 80px 1fr 120px;
    align-items: center;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-md);
}

.element-bar-item.highlight {
    background: var(--gray-50);
    padding: var(--spacing-sm);
    border-radius: var(--radius-md);
}

.bar-label {
    font-weight: 600;
    color: var(--gray-700);
}

.bar-track {
    height: 30px;
    background: var(--gray-200);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.bar-fill {
    height: 100%;
    transition: width 1s ease-out;
}

.bar-fill.wood {
    background: linear-gradient(90deg, #10B981, #059669);
}

.bar-fill.fire {
    background: linear-gradient(90deg, #EF4444, #DC2626);
}

.bar-fill.earth {
    background: linear-gradient(90deg, #F59E0B, #D97706);
}

.bar-fill.metal {
    background: linear-gradient(90deg, #6B7280, #4B5563);
}

.bar-fill.water {
    background: linear-gradient(90deg, #3B82F6, #2563EB);
}

.bar-value {
    font-weight: 700;
    color: var(--gray-700);
    text-align: right;
}

/* ===== RECOMMENDATIONS ===== */
.element-recommendations {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

.recommendation-card {
    display: flex;
    gap: var(--spacing-md);
    padding: var(--spacing-md);
    border-radius: var(--radius-lg);
    border-left: 4px solid;
}

.recommendation-card.good {
    background: rgba(16, 185, 129, 0.1);
    border-color: #10B981;
}

.recommendation-card.neutral {
    background: rgba(245, 158, 11, 0.1);
    border-color: #F59E0B;
}

.recommendation-card.bad {
    background: rgba(239, 68, 68, 0.1);
    border-color: #EF4444;
}

.rec-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.rec-content h4 {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: var(--spacing-xs);
    color: var(--gray-900);
}

.rec-content p {
    font-size: 0.875rem;
    color: var(--gray-600);
    line-height: 1.6;
}

/* ===== OVERALL SCORE ===== */
.overall-score {
    text-align: center;
    margin: var(--spacing-2xl) 0;
}

.score-circle {
    width: 200px;
    height: 200px;
    margin: 0 auto var(--spacing-md);
    background: var(--gradient-card);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 8px solid var(--primary-purple);
    box-shadow: var(--shadow-xl);
}

.circle-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.score-number {
    font-size: 4rem;
    font-weight: 900;
    color: var(--primary-purple);
    line-height: 1;
}

.score-label {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--gray-700);
}

.score-desc {
    font-size: 1rem;
    color: var(--gray-600);
}

/* ===== CATEGORY SCORES ===== */
.category-scores {
    margin: var(--spacing-xl) 0;
}

.category-score-item {
    display: grid;
    grid-template-columns: auto auto 1fr auto;
    align-items: center;
    gap: var(--spacing-md);
    padding: var(--spacing-md);
    background: var(--white);
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-lg);
    margin-bottom: var(--spacing-sm);
}

.cat-icon {
    font-size: 1.5rem;
}

.cat-name {
    font-weight: 600;
    color: var(--gray-700);
    min-width: 80px;
}

.cat-bar-track {
    height: 20px;
    background: var(--gray-200);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.cat-bar-fill {
    height: 100%;
    background: var(--gradient-primary);
    transition: width 1s ease-out;
}

.cat-score {
    font-weight: 700;
    color: var(--primary-purple);
    min-width: 50px;
    text-align: right;
}

/* ===== OVERALL ASSESSMENT ===== */
.overall-assessment {
    background: var(--gradient-card);
    padding: var(--spacing-lg);
    border-radius: var(--radius-lg);
    border-left: 4px solid var(--primary-purple);
}

.overall-assessment h4 {
    font-size: 1.125rem;
    font-weight: 700;
    margin-bottom: var(--spacing-sm);
    color: var(--gray-900);
}

.overall-assessment p {
    font-size: 1rem;
    line-height: 1.8;
    color: var(--gray-700);
}

/* ===== PAGE NAVIGATION ===== */
.page-navigation-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-lg);
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    margin-top: var(--spacing-xl);
}

.nav-btn {
    padding: var(--spacing-sm) var(--spacing-lg);
    background: var(--gradient-button);
    color: var(--white);
    border: none;
    border-radius: var(--radius-md);
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-base);
}

.nav-btn:hover {
    background: var(--gradient-button-hover);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.nav-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.page-indicator {
    font-weight: 600;
    color: var(--gray-700);
}

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 1024px) {
    .toc-sidebar {
        position: fixed;
        left: -280px;
        top: 73px;
        bottom: 0;
        z-index: 999;
        transition: left var(--transition-base);
        box-shadow: var(--shadow-xl);
    }

    .toc-sidebar.open {
        left: 0;
    }

    .report-layout {
        display: block;
    }
}

@media (max-width: 768px) {
    .report-main-title {
        font-size: 0.875rem;
    }

    .action-btn .btn-text {
        display: none;
    }

    .report-page {
        padding: var(--spacing-xl);
    }

    .cover-year {
        font-size: 2rem;
    }

    .cover-type {
        font-size: 1.75rem;
    }

    .saju-table .hanja {
        font-size: 1.5rem;
    }

    .characteristics {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .report-pages {
        padding: var(--spacing-md);
    }

    .report-page {
        padding: var(--spacing-md);
        min-height: auto;
    }
}

/* ===== PRINT STYLES ===== */
@media print {

    .report-header,
    .toc-sidebar,
    .page-navigation-bottom {
        display: none;
    }

    .report-layout {
        display: block;
    }

    .report-main {
        overflow: visible;
    }

    .report-page {
        page-break-after: always;
        box-shadow: none;
        margin: 0;
        border-radius: 0;
    }

    .page-number {
        display: block;
    }
}