/* =============================================================================
 * Tử Vi Số · Universal Print Stylesheet v0.25
 * 
 * Áp dụng khi user bấm "In / Lưu PDF" trong các view:
 * - chart-view (Tử Vi)
 * - bazi-view (Bát Tự)
 * - numerology-view (Thần Số)
 * - face-view (Nhân Tướng)
 * - palm-view (Chỉ Tay)
 * - compat-view (Tương hợp)
 * - holistic-view (AI Hợp Nhất)
 * - personal-view (Trạch Cát · Số học · Phong Thuỷ · Sức Khoẻ · Đặt tên)
 *
 * Nguyên tắc:
 * - Body: nền TRẮNG, chữ ĐEN, font dễ đọc
 * - Tiêu đề lớn nhất: đen đậm
 * - Ngũ hành: dùng đủ 5 màu chính (Kim trắng-xám, Mộc xanh lá, Thuỷ xanh dương, Hoả đỏ, Thổ vàng-cam-nâu)
 * - Header section: vàng thổ (hoặc tuỳ ngũ hành section)
 * - Bỏ tất cả nút, link, action
 * =============================================================================
 */

@media print {
    /* ===== RESET ===== */
    * {
        background: transparent !important;
        color: #000 !important;
        box-shadow: none !important;
        text-shadow: none !important;
    }

    html, body {
        background: #fff !important;
        color: #1a1a1a !important;
        font-family: 'Times New Roman', 'Georgia', serif !important;
        font-size: 11pt !important;
        line-height: 1.5 !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    @page {
        size: A4;
        margin: 18mm 15mm 18mm 15mm;
    }

    /* ===== HIDE ELEMENTS ===== */
    nav,
    .navbar,
    .dashboard-nav,
    .nav-sidebar,
    .nav-mobile,
    .chart-actions,
    .compat-actions,
    .feature-actions,
    .action-bar,
    button,
    .btn-primary,
    .btn-secondary,
    .btn-mini,
    .btn-copy,
    .btn-large,
    .text-xs.font-mono.text-dim,  /* breadcrumb */
    .ai-loading,
    .alert,
    footer,
    .footer,
    .site-footer,
    .zalo-float,
    .float-cta,
    form[method="post"],
    .compose-btn,
    a.btn-primary,
    a.btn-secondary,
    .holistic-source-badge[onclick],
    [onclick],
    iframe,
    video,
    audio,
    .no-print {
        display: none !important;
    }

    a {
        color: #000 !important;
        text-decoration: none !important;
    }
    a[href]:after { content: '' !important; }

    /* ===== TYPOGRAPHY ===== */
    h1, h2, h3, h4, h5, h6 {
        font-family: 'Georgia', 'Times New Roman', serif !important;
        color: #1a1a1a !important;
        page-break-after: avoid;
        margin-top: 14pt;
        margin-bottom: 6pt;
        font-weight: 700;
    }
    h1 {
        font-size: 22pt !important;
        color: #1a1a1a !important;
        border-bottom: 2pt solid #b8860b !important;  /* gold underline */
        padding-bottom: 6pt;
        margin-top: 0 !important;
    }
    h1 em, h1 i {
        font-style: italic;
        color: #1a1a1a !important;
    }
    h2 {
        font-size: 16pt !important;
        color: #b8860b !important;  /* gold - dễ đọc trên trắng */
    }
    h3 {
        font-size: 13pt !important;
        color: #1a1a1a !important;
        border-bottom: 1pt dashed #888 !important;
        padding-bottom: 3pt;
    }
    h4 {
        font-size: 11.5pt !important;
        color: #2c1810 !important;
    }
    p, li, td, th, div, span {
        color: #1a1a1a !important;
        font-size: 11pt !important;
        line-height: 1.55 !important;
    }
    strong, b {
        color: #000 !important;
        font-weight: 700;
    }
    em, i {
        color: #2c1810 !important;
        font-style: italic;
    }
    small {
        font-size: 9.5pt !important;
        color: #444 !important;
    }
    code {
        font-family: 'Courier New', monospace !important;
        color: #1a1a1a !important;
        background: #f5f5f5 !important;
        padding: 1pt 4pt !important;
        font-size: 10pt !important;
        border: 0.5pt solid #ccc !important;
    }

    /* ===== HEADER ===== */
    .dashboard-header {
        margin-bottom: 18pt;
        padding-bottom: 10pt;
        border-bottom: 2pt solid #b8860b !important;
    }
    .label-mono {
        font-family: 'Courier New', monospace !important;
        font-size: 9pt !important;
        color: #b8860b !important;
        letter-spacing: 0.5pt;
        text-transform: uppercase;
        margin-bottom: 4pt !important;
    }
    .dashboard-header h1 { border-bottom: none !important; }

    /* ===== SECTIONS / CARDS ===== */
    .section,
    .lucky-section,
    .holistic-section,
    .card,
    .ai-result-box {
        background: #fff !important;
        border: 1pt solid #ccc !important;
        border-left: 3pt solid #b8860b !important;
        padding: 10pt !important;
        margin-bottom: 10pt !important;
        page-break-inside: avoid;
    }
    .lucky-section-title,
    .holistic-section-title,
    .section-title {
        color: #b8860b !important;  /* gold theo Thổ */
        font-family: 'Georgia', serif !important;
        font-size: 13pt !important;
        margin: 0 0 8pt !important;
        padding-bottom: 4pt !important;
        border-bottom: 1pt dashed #b8860b !important;
        font-weight: 700;
    }

    /* ===== AVOID / WARN SECTIONS ===== */
    .avoid-section,
    .csection-warning,
    .health-disclaimer {
        border-left-color: #c44536 !important;
        background: #fdf5f4 !important;
    }
    .avoid-section .lucky-section-title { color: #c44536 !important; border-bottom-color: #c44536 !important; }
    .csection-warning strong,
    .health-disclaimer strong { color: #c44536 !important; }

    /* ===== NGŨ HÀNH MÀU - đủ 5 màu trên nền trắng ===== */
    /* Kim 金 - bạc xám */
    .energy-cell[style*="c0c0c0"],
    .health-el[style*="c0c0c0"],
    .cs-an-bazi[style*="c0c0c0"] {
        border-left-color: #6b6b6b !important;
    }
    
    /* Mộc 木 - xanh lá */
    .energy-cell[style*="4a7c59"],
    .health-el[style*="4a7c59"] {
        border-left-color: #2d5f3f !important;
    }
    
    /* Thuỷ 水 - xanh dương */
    .energy-cell[style*="3a6b8c"],
    .health-el[style*="3a6b8c"],
    .cs-an-bazi {
        border-left-color: #1e4d6b !important;
    }
    
    /* Hoả 火 - đỏ */
    .energy-cell[style*="c44536"],
    .health-el[style*="c44536"] {
        border-left-color: #a33020 !important;
    }
    
    /* Thổ 土 - vàng nâu */
    .energy-cell[style*="a0826d"],
    .health-el[style*="a0826d"] {
        border-left-color: #8b6b4a !important;
    }

    /* Ngũ hành labels - giữ màu */
    .energy-label[style*="c0c0c0"] { color: #6b6b6b !important; font-weight: 700; }
    .energy-label[style*="4a7c59"] { color: #2d5f3f !important; font-weight: 700; }
    .energy-label[style*="3a6b8c"] { color: #1e4d6b !important; font-weight: 700; }
    .energy-label[style*="c44536"] { color: #a33020 !important; font-weight: 700; }
    .energy-label[style*="a0826d"] { color: #8b6b4a !important; font-weight: 700; }

    /* ===== GRIDS ===== */
    .energy-grid {
        display: grid !important;
        grid-template-columns: repeat(5, 1fr) !important;
        gap: 6pt !important;
    }
    .energy-cell {
        border: 1pt solid #888 !important;
        padding: 6pt !important;
        text-align: center;
    }
    .energy-val { font-size: 18pt !important; font-weight: 700; }

    .directions-grid,
    .organ-grid,
    .pairs-grid,
    .name-grid {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 8pt !important;
    }
    .direction-card,
    .organ-card,
    .pair-card,
    .name-card {
        border: 1pt solid #999 !important;
        padding: 8pt !important;
        page-break-inside: avoid;
    }

    /* ===== TABLES ===== */
    table {
        width: 100% !important;
        border-collapse: collapse !important;
        margin: 8pt 0 !important;
    }
    th, td {
        border: 0.5pt solid #999 !important;
        padding: 5pt 8pt !important;
        color: #1a1a1a !important;
    }
    th {
        background: #f5f0e6 !important;  /* nền vàng nhạt cho header */
        color: #5c4416 !important;
        font-weight: 700;
        font-size: 10pt !important;
    }

    /* ===== ADVICE CARDS ===== */
    .advice-card {
        display: block !important;
        border: 1pt solid #999 !important;
        border-left: 3pt solid #b8860b !important;
        padding: 8pt !important;
        margin-bottom: 8pt !important;
        page-break-inside: avoid;
    }
    .advice-num {
        display: inline-block !important;
        font-size: 18pt !important;
        font-weight: 700;
        color: #b8860b !important;
        margin-right: 8pt;
        vertical-align: top;
        width: auto !important;
    }
    .advice-body { display: inline-block !important; width: calc(100% - 40pt); vertical-align: top; }

    /* ===== SCORE / HEADER BOXES ===== */
    .personal-header,
    .holistic-header,
    .ming-gua-box,
    .business-pyt-box,
    .business-kd-box,
    .longevity-box {
        border: 1.5pt solid #b8860b !important;
        background: #fdf9f0 !important;
        padding: 12pt !important;
        margin-bottom: 12pt !important;
        page-break-inside: avoid;
        display: block !important;
    }
    .personal-score,
    .holistic-score,
    .pyt-number,
    .longevity-score {
        font-family: 'Georgia', serif !important;
        font-size: 32pt !important;
        font-weight: 700;
        color: #1a1a1a !important;
        display: inline-block;
        margin-right: 10pt;
    }
    .personal-title,
    .holistic-archetype {
        font-size: 16pt !important;
        color: #b8860b !important;
        font-weight: 700;
    }
    .personal-summary,
    .holistic-summary {
        color: #1a1a1a !important;
        font-size: 11pt !important;
        margin-top: 6pt !important;
    }
    .personal-icon { font-size: 24pt !important; margin-right: 8pt; }
    .personal-score-max { font-size: 11pt !important; color: #666 !important; }

    /* ===== HOLISTIC CONCLUSION ===== */
    .holistic-conclusion {
        border: 1.5pt solid #b8860b !important;
        background: #fdf9f0 !important;
        padding: 14pt !important;
        text-align: center;
        margin-top: 16pt !important;
        page-break-inside: avoid;
    }
    .conclusion-icon { font-size: 18pt !important; color: #b8860b !important; }
    .holistic-conclusion p { font-style: italic; line-height: 1.7 !important; }

    /* ===== DATE / TIMING CARDS ===== */
    .date-card,
    .csection-card {
        border: 1pt solid #999 !important;
        border-left: 3pt solid #b8860b !important;
        padding: 10pt !important;
        margin-bottom: 8pt !important;
        page-break-inside: avoid;
        display: block !important;
    }
    .date-rank,
    .csection-rank {
        display: inline-block !important;
        width: 24pt !important;
        height: 24pt !important;
        line-height: 24pt !important;
        background: #b8860b !important;
        color: #fff !important;
        text-align: center;
        font-weight: 700;
        margin-right: 8pt;
        vertical-align: middle;
        border-radius: 50%;
    }
    .date-rank, .csection-rank { background: #b8860b !important; }
    .csection-3analysis {
        display: grid !important;
        grid-template-columns: 1fr 1fr 1fr !important;
        gap: 6pt !important;
    }
    .cs-an {
        border: 1pt solid #ccc !important;
        padding: 6pt !important;
    }
    .cs-an-bazi { border-top: 2pt solid #1e4d6b !important; }
    .cs-an-bazi h4 { color: #1e4d6b !important; }
    .cs-an-tuvi { border-top: 2pt solid #6a4c93 !important; }
    .cs-an-tuvi h4 { color: #6a4c93 !important; }
    .cs-an-num { border-top: 2pt solid #2d5f3f !important; }
    .cs-an-num h4 { color: #2d5f3f !important; }

    /* ===== STRENGTHS / WEAKNESSES ===== */
    .sw-grid {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 10pt !important;
    }
    .sw-strength { border-left: 3pt solid #2d5f3f !important; padding-left: 8pt !important; }
    .sw-strength h4 { color: #2d5f3f !important; }
    .sw-weakness { border-left: 3pt solid #c44536 !important; padding-left: 8pt !important; }
    .sw-weakness h4 { color: #c44536 !important; }

    /* ===== HEALTH ORGAN ===== */
    .organ-card { border-top: 2pt solid #b8860b !important; }
    .organ-risk {
        font-size: 8.5pt !important;
        padding: 1pt 6pt !important;
        border: 0.5pt solid !important;
        font-weight: 700;
    }
    .consensus-warn {
        border-left: 3pt solid #c44536 !important;
        background: #fdf5f4 !important;
        padding: 8pt !important;
        margin-bottom: 8pt !important;
        page-break-inside: avoid;
    }
    .consensus-badge {
        background: #c44536 !important;
        color: #fff !important;
        padding: 1pt 6pt !important;
        font-size: 8.5pt !important;
    }

    /* ===== UTILITY ===== */
    ul, ol {
        margin: 6pt 0 6pt 18pt !important;
        padding: 0 !important;
    }
    li { margin: 2pt 0 !important; }
    .rec-item,
    .consensus-item,
    .divergence-item,
    .phase-item {
        padding: 5pt 8pt !important;
        margin: 4pt 0 !important;
        border-left: 2pt solid #b8860b !important;
        background: #fafafa !important;
    }
    .rec-warn { border-left-color: #c44536 !important; background: #fdf5f4 !important; }

    /* ===== PAGE BREAKS ===== */
    .lucky-section,
    .holistic-section,
    .csection-card,
    .organ-card,
    .name-card,
    .advice-card {
        page-break-inside: avoid;
    }

    /* Bỏ icon emoji không cần in (giảm rendering issues) */
    /* Giữ lại để user vẫn nhận diện được section */

    /* Hộp QR */
    .qr-image { display: none !important; }
}
