:root {
    --primary: #FF6B00; /* Clites Tech Orange */
    --primary-dark: #cc5500;
    --primary-light: rgba(255, 107, 0, 0.2);
    --bg-dark: #0a0a0c;
    --bg-card: #151518;
    --text-main: #f0f0f0;
    --text-muted: #888888;
    --glass-bg: rgba(20, 20, 22, 0.6);
    --glass-border: rgba(255, 255, 255, 0.05);
    --glow-shadow: 0 0 20px rgba(255, 107, 0, 0.3);
}

body {
    font-family: 'Inter', sans-serif;
    color: var(--text-main);
    background-color: #f3f4f6;
}

body.bg-light {
    color: #374151;
}

h1, h2, h3, h4, h5, h6, .brand-text {
    font-family: 'Outfit', sans-serif;
    color: #111827;
    letter-spacing: -0.02em;
}

/* Premium Typography Overrides */
.text-muted { color: var(--text-muted) !important; }
.text-white-50 { color: rgba(255, 255, 255, 0.85) !important; } /* Much higher contrast on dark backgrounds */
.lead { font-size: 1.15rem; font-weight: 500; color: #374151; }

/* Glassmorphism */
.glassmorphism {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--glass-border);
}

.glass-card {
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    padding: 2rem;
}

/* Gradients */
.text-gradient {
    background: linear-gradient(135deg, #FF6B00, #FFB84D);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Buttons */
.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border: none;
    color: white;
    font-weight: 600;
    padding: 0.75rem 2rem;
    border-radius: 8px;
    transition: all 0.3s ease;
    box-shadow: var(--glow-shadow);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 30px rgba(255, 107, 0, 0.5);
}

@keyframes helix {
    0% { transform: rotateY(0deg) rotateZ(0deg) scale(1); }
    50% { transform: rotateY(180deg) rotateZ(180deg) scale(1.1); }
    100% { transform: rotateY(360deg) rotateZ(360deg) scale(1); }
}

/* --- Multi-Page Report Styles --- */

/* The outer container for web viewing */
.report-document {
    background-color: #e9ecef;
    padding: 40px 0;
}

/* Physical page simulation */
.pdf-page {
    background: #ffffff;
    width: 100%;
    max-width: 850px;
    margin: 0 auto 50px auto;
    padding: 70px 60px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.08);
    border-radius: 8px;
    position: relative;
    display: flex;
    flex-direction: column;
}

.pdf-page.cover-page {
    justify-content: center;
    align-items: center;
    text-align: center;
    background: linear-gradient(145deg, #ffffff 0%, #f0fdf4 100%); /* Subtle premium green/white tint */
    border-top: 8px solid var(--primary);
}

.pdf-page.back-cover {
    background: linear-gradient(135deg, #111827 0%, #000000 100%);
    color: white;
    justify-content: center;
    align-items: center;
    text-align: center;
    border-bottom: 8px solid var(--primary);
}

/* Page Breaks for HTML2PDF */
.html2pdf__page-break {
    height: 0;
    page-break-after: always;
    break-after: page;
}

/* Print Specific Rules & PDF Export Rules */
@media print {
    .report-document {
        padding: 0;
        background: transparent;
    }
    .pdf-page {
        margin: 0;
        padding: 40px;
        box-shadow: none;
        min-height: auto;
    }
}

/* Explicit overrides during PDF generation */
body.exporting-pdf .report-document {
    padding: 0 !important;
    background: transparent !important;
}
body.exporting-pdf .pdf-page {
    margin: 0 !important;
    box-shadow: none !important;
    border: none !important;
    width: 100% !important; /* Let html2canvas use the true width */
    min-height: 0 !important; /* Remove min-height so html2pdf can paginate naturally */
    padding: 0 !important; /* We rely on the 0.4in JS margin instead */
    border-radius: 0 !important;
    display: block !important; /* CRITICAL: Flexbox breaks html2pdf pagination */
    overflow: visible !important; /* CRITICAL: hidden overflow cuts off content */
}
/* Force strict page breaks between major sections */
body.exporting-pdf .html2pdf__page-break {
    display: none !important; /* We will use CSS page-break-before instead of empty divs to prevent bleeding */
}
body.exporting-pdf .pdf-page:not(:first-child) {
    page-break-before: always !important;
    break-before: page !important;
}
body.exporting-pdf .cover-page,
body.exporting-pdf .back-cover {
    display: block !important; /* CRITICAL: Remove flexbox during export */
    height: 9.5in !important; /* Extremely safe height to prevent overflow/cutoff */
    padding-top: 2.5in !important; /* Manually center content vertically */
}
body.exporting-pdf .back-cover {
    page-break-before: always !important; /* Ultimate safeguard against bleeding */
    break-before: page !important;
}

/* Interactivity (Hover states) & Print Rules */
.sitemap-node {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    page-break-inside: avoid !important; /* Native CSS protection */
    break-inside: avoid !important;
    margin-bottom: 20px;
}
.sitemap-node:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
}
.chart-box {
    transition: transform 0.3s ease;
    page-break-inside: avoid !important;
    break-inside: avoid !important;
}
.chart-box:hover {
    transform: scale(1.05);
}

/* Tree Map Styles */
.tree-wrapper {
    font-family: 'Inter', monospace;
    padding: 40px;
    background: #ffffff;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
    box-shadow: inset 0 2px 10px rgba(0,0,0,0.02);
    overflow-x: auto;
}
.tree-list {
    list-style-type: none;
    padding-left: 35px;
    border-left: 2px solid #cbd5e1;
    margin-left: 15px;
}
.tree-item {
    position: relative;
    padding: 12px 0 12px 30px;
    page-break-inside: avoid !important;
    break-inside: avoid !important;
}
.tree-item::before {
    content: '';
    position: absolute;
    top: 28px;
    left: 0;
    width: 25px;
    border-top: 2px solid #cbd5e1;
}
.tree-item-label {
    display: inline-flex;
    align-items: center;
    color: #1f2937;
    font-weight: 600;
    font-size: 1.05rem;
    background: #f8fafc;
    padding: 8px 16px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}
.tree-item-label i {
    margin-right: 12px;
    font-size: 1.1rem;
}

/* Terminal / Loading State */
.terminal-box {
    background: #000;
    border: 1px solid #333;
    border-radius: 8px;
    padding: 1rem;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.85rem;
    color: #0f0;
    height: 150px;
    overflow-y: auto;
    text-align: left;
    margin-top: 1rem;
    box-shadow: inset 0 0 10px rgba(0,0,0,0.8);
}
.terminal-line { margin: 0; padding: 2px 0; }
.terminal-line.error { color: #ff3333; }
.terminal-line.success { color: #00ff00; }
.terminal-line.info { color: #00ccff; }

/* Report Styles */
.report-container {
    background: #ffffff;
    color: #1a1a1a;
    padding: 4rem;
    border-radius: 12px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.4);
    margin-top: 2rem;
    margin-bottom: 2rem;
}

.report-header {
    border-bottom: 3px solid var(--primary);
    padding-bottom: 2rem;
    margin-bottom: 3rem;
}

.sitemap-node {
    margin-bottom: 2.5rem;
    padding: 1.5rem;
    background: #f8f9fa;
    border-radius: 12px;
    border: 1px solid #e9ecef;
    box-shadow: 0 4px 6px rgba(0,0,0,0.02);
    page-break-inside: avoid;
}

/* Specific styling for 'Same Page' anchor links */
.sitemap-node.same-page {
    margin-left: 3rem; /* Indent slightly to show hierarchy */
    border-left: 4px solid #FFB84D;
    background: #fffcf8;
}
.sitemap-node.separate-page {
    border-left: 4px solid var(--primary);
}

.screenshot-img {
    width: 100%;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.08);
    border: 1px solid #e0e0e0;
    margin-top: 1rem;
}

.badge-same-page { background-color: #FFB84D; color: #000; }
.badge-separate { background-color: var(--primary); }

@media print {
    .no-print { display: none !important; }
    .report-container { padding: 0; box-shadow: none; margin: 0; }
    body { background: white; }
    .sitemap-node { break-inside: avoid; }
}
