/* Print and PDF specific styles for unified PDF generation */

/* Print media query - triggers when printing or generating PDF */
@media print {
    /* Set page size with clean margins */
    @page {
        margin: 1.5cm;
        size: A4;
        
        /* Custom footers */
        @bottom-left {
            content: "Confidencial - Uso Profissional";
            font-size: 10px;
            color: #666;
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
        }
        
        @bottom-right {
            content: "Página " counter(page) " de " counter(pages);
            font-size: 10px;
            color: #666;
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
        }
    }
    
    /* HIDE the entire fixed navigation - it's designed for web, not print */
    .fixed-header {
        position: static !important;
        background: none !important;
        box-shadow: none !important;
        margin: 0 !important;
        padding: 0 !important;
        line-height: 1 !important;
    }
    
    /* Hide bottom navigation and mobile menu */
    .quick-actions,
    #mobile-menu {
        display: none !important;
    }
    
    /* Hide the site footer */
    footer {
        display: none !important;
    }
    
    /* Hide menu items and user info from top navigation, but keep logo */
    .menu-container,
    .user-container,
    .desktop-menu {
        display: none !important;
    }
    
    /* Ensure logo is visible and positioned correctly in print mode */
    .logo-container {
        display: block !important;
        margin-bottom: 1rem !important;
    }
    
    .logo-container img {
        display: block !important;
        max-height: 60px !important;
        width: auto !important;
        print-color-adjust: exact !important;
        -webkit-print-color-adjust: exact !important;
    }
    
    /* Make sure logo link doesn't break layout */
    .logo-container a {
        display: flex !important;
        align-items: center !important;
        text-decoration: none !important;
        pointer-events: none !important;
        cursor: default !important;
    }
    
    /* Remove any link styling */
    .logo-container a:hover,
    .logo-container a:focus,
    .logo-container a:active {
        text-decoration: none !important;
        color: inherit !important;
    }
    
    /* Ensure logo text is visible in print */
    .logo-container .flex.flex-col {
        display: flex !important;
        flex-direction: column !important;
    }
    
    .logo-container span {
        display: block !important;
        color: #333 !important;
    }
    
    /* Hide elements with no-print class and remove their margins */
    .no-print {
        display: none !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    
    /* Hide the "Resultado" title in print mode */
    h2.text-2xl.font-semibold {
        display: none !important;
    }
    
    /* Hide interactive elements */
    button[data-toggle-type="accordion"] {
        display: none !important;
    }
    
    /* Expand accordion content for print */
    #responsesContent,
    #escalaContent,
    [data-accordion-target] + *,
    .symptom-content {
        max-height: none !important;
        opacity: 1 !important;
        visibility: visible !important;
        display: block !important;
    }
    

    
    /* Layout adjustments for print */
    body {
        background: white !important;
        color: #333 !important;
        /* Remove body padding since @page now handles margins */
        margin: 0 !important;
        padding: 0 !important;
        box-sizing: border-box !important;
        min-height: 100vh !important;
        /* Use same font as frontend - exact Tailwind default */
        font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif !important;
        /* Scale down entire document to 90% with proper width compensation */
        transform: scale(0.90) !important;
        transform-origin: top left !important;
        width: 111.11% !important; /* Compensate for scale: 100% / 0.90 = 111.11% */
        height: 111.11% !important; /* Also compensate height to prevent border cutoff */
    }
    
    /* Ensure all text elements inherit proper font */
    body *, h1, h2, h3, h4, h5, h6, p, span, div, a, button, input, textarea, select, label {
        font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif !important;
    }
    
    /* Ensure SVG text elements (charts) use proper font */
    svg text, svg tspan {
        font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif !important;
    }
    
    /* Force background colors and images to print */
    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
        box-shadow: none !important;
    }
    
    /* Ensure all images (including logo) render properly */
    img {
        max-width: 100% !important;
        height: auto !important;
        display: block !important;
        print-color-adjust: exact !important;
        -webkit-print-color-adjust: exact !important;
    }
    
    /* Ensure content respects bottom padding */
    .flex-grow {
        padding-bottom: 0 !important;
        margin-bottom: 0 !important;
    }
    
    /* Make navigation containers transparent and minimal */
    nav .max-w-7xl {
        max-width: none !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    
    nav .flex.justify-between {
        height: auto !important;
        min-height: auto !important;
    }
    
    /* Remove the 100px height constraint that creates the big gap */
    nav .flex.justify-between[style*="height: 100px"] {
        height: auto !important;
    }
    
    /* Logo should be visible and flow naturally with minimal spacing */
    .print-header {
        margin-bottom: 0.25rem !important;
        page-break-after: avoid;
    }
    
    /* Remove the 110px top margin from main content - THIS IS THE BIG GAP! */
    main.flex-grow {
        margin-top: 0 !important;
        padding-top: 10px !important;
    }
    
    /* Remove all padding from content wrapper */
    .py-16 {
        padding: 0 !important;
    }
    

    
    /* Hide the gray background only for main content areas, but preserve it for specific sections */
    .bg-gray-50 {
        background: white !important;
    }
    
    /* Preserve question background colors in PDF output - only for question containers */
    #responsesContent .bg-gray-50,
    .space-y-4 .bg-gray-50 {
        background: #f9fafb !important;
    }
    
    /* Ensure proper page breaks */
    .page-break {
        page-break-before: always;
    }
    
    /* Form3 specific background fixes - must come after general bg-gray-50 rule */
    /* Target the segment analysis tables specifically */
    .grid .bg-gray-50.rounded-lg.p-4,
    .border-t.border-gray-200 .grid .bg-gray-50,
    .symptom-content .bg-gray-50.rounded-lg.p-3 {
        background: #f9fafb !important;
    }
    
    /* Form3 Segment Chart Print Styles - SVG with viewBox handles scaling automatically */
    .segments-svg {
        max-width: 100% !important;
        height: auto !important;
        /* Prevent the global body transform from affecting the segment chart */
        transform: none !important;
        transform-origin: initial !important;
    }

    /* Fix segment chart container to prevent text flipping */
    .segment-chart-container {
        transform: none !important;
        transform-origin: initial !important;
    }

    /* Fix segment flip cards to prevent text flipping - always show front (segment names) in print */
    .segment-flip-card,
    .segment-flip-card-inner {
        transform: none !important;
        transform-origin: initial !important;
    }

    /* Force flip card to always show front side in print */
    .segment-flip-card.flipped .segment-flip-card-inner {
        transform: none !important;
    }

    /* Ensure front is visible and back is hidden in print */
    .segment-flip-card-front {
        transform: none !important;
        position: relative !important;
        backface-visibility: visible !important;
    }

    .segment-flip-card-back {
        display: none !important;
    }

    /* Force segment text to maintain desktop font size in print */
    .segment-text {
        font-weight: 600 !important;
    }
    
    /* Remove shadows from Form3 segment chart in print */
    .segment-rect {
        filter: none !important;
    }
    
    /* Form1 Radar Chart Print Styles */
    .radar-chart-container {
        max-width: 100% !important;
        margin: 0 auto !important;
        padding: 20px !important;
        overflow: visible !important;
    }
    
    .radar-chart-svg {
        width: 100% !important;
        height: auto !important;
        max-width: 400px !important;
        margin: 0 auto !important;
        display: block !important;
    }
    
    /* Ensure radar chart data is visible in print */
    .data-polygon {
        opacity: 1 !important;
        transform: scale(1) !important;
        transition: none !important;
    }
    
    .data-point {
        opacity: 1 !important;
        transition: none !important;
    }
    
    /* Ensure axis labels are visible in print */
    .axis-label {
        font-size: 14px !important;
        fill: #374151 !important;
    }
    
    /* Fix main content container borders - ensure all borders are visible */
    .bg-white.rounded-xl.border {
        border: 1px solid #e5e7eb !important; /* Ensure consistent border on all sides */
        border-right: 1px solid #e5e7eb !important; /* Specifically fix right border */
        box-sizing: border-box !important; /* Ensure borders are included in element size */
        overflow: visible !important; /* Prevent border clipping */
    }
    
    /* Additional fix for max-width containers that might be cutting borders */
    .max-w-4xl {
        max-width: calc(100% - 2px) !important; /* Account for potential border space */
    }
    
    /* Remove shadows from gauge chart in print */
    .gauge-chart-container,
    .gauge-chart-svg,
    .gauge-chart,
    .gauge-progress-arc {
        box-shadow: none !important;
        filter: none !important;
    }
    
    /* Specifically remove drop-shadow from gauge progress arc */
    .gauge-progress-arc {
        filter: none !important;
    }
    
}
