/* Analytics Layout Custom Styles */

body {
    font-family: 'Poppins', system-ui, -apple-system, sans-serif;
    background: white;
    color: #000;
    overflow: auto;
}

/* Typography with Poppins - only non-Tailwind customizations */
h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: 'Poppins', sans-serif;
    /* Tailwind already handles font-weight via utility classes */
}

/* Chart container styles */
.chart-container {
    position: relative;
    height: 16rem;
    width: 100%;
}

/* Custom scrollbar for tables */
.table-scroll::-webkit-scrollbar {
    height: 8px;
}

.table-scroll::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.table-scroll::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

.table-scroll::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Animation for loading state */
@keyframes pulse {
    0%,
    100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.loading-pulse {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* Ensure charts are responsive */
canvas {
    max-width: 100% !important;
    height: auto !important;
}

/* Stats card hover effect */
.stats-card {
    transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
}

.stats-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}

/* Table row hover */
tbody tr:hover {
    background-color: #f9fafb;
}

/* Thumbnail image aspect ratio */
.thumbnail-container {
    aspect-ratio: 16 / 9;
    overflow: hidden;
}

/** Total Cards **/
.total-card {
    position: relative;
}

.trend-chart {
    position: absolute;
    right: 20px;
    width: 120px;
    top: 20px;
}

/* Print button styles */
.print-button {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
}

/* Responsive typography adjustments */
@media (max-width: 640px) {
    h1 {
        font-size: 1.5rem;
    }

    .stats-value {
        font-size: 1.875rem;
    }

    table {
        font-size: 0.875rem;
    }
}

/* Dark mode support (optional) */
@media (prefers-color-scheme: dark) {
    /* Add dark mode styles here if needed */
}

/* Print Styles for US Letter (8.5" x 11") and A4 - Optimized for single page */
@media print {
    /* Page setup - LANDSCAPE orientation */
    @page {
        size: letter landscape; /* or A4 landscape */
        margin: 0.4in; /* Reduced margins for more content space */
    }

    /* Reset backgrounds and colors for print */
    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
        color-adjust: exact !important;
        overflow: visible !important; /* Prevent all scrollbars in print */
    }

    /* Body and container adjustments */
    body {
        margin: 0;
        padding: 0;
        font-family: 'Poppins', sans-serif;
        font-size: 9pt; /* Reduced from 11pt */
        line-height: 1.2; /* Tighter line height */
        overflow: visible !important; /* Prevent body scrollbars */
    }

    .min-h-screen {
        min-height: auto !important;
    }

    main {
        max-width: 100% !important;
        padding: 0 !important;
        overflow: visible !important; /* Prevent main container scrollbars */
    }

    /* Hide elements not needed for print */
    .no-print,
    .print-button,
    script,
    .auto-refresh-notice {
        display: none !important;
    }

    /* Prevent scrollbars on common Tailwind containers */
    .overflow-auto,
    .overflow-x-auto,
    .overflow-y-auto,
    .overflow-scroll,
    .overflow-x-scroll,
    .overflow-y-scroll {
        overflow: visible !important;
    }

    /* Ensure divs and containers don't create scrollbars */
    div {
        overflow: visible !important;
    }

    /* Moderate spacing reduction for single page - maintaining readability */
    .mb-12 {
        margin-bottom: 0.75rem !important; /* Moderate reduction */
    }

    .mb-8 {
        margin-bottom: 0.5rem !important;
    }

    .mb-4 {
        margin-bottom: 0.4rem !important;
    }

    .mt-6 {
        margin-top: 0.5rem !important;
    }

    .mt-4 {
        margin-top: 0.3rem !important;
    }

    .mt-2 {
        margin-top: 0.2rem !important;
    }

    section {
        page-break-inside: avoid;
        break-inside: avoid;
        margin-bottom: 0.4rem !important;
        overflow: visible !important; /* Prevent section scrollbars */
    }

    /* Header section - more compact */
    section[aria-label='Cover lead'] {
        margin-bottom: 0.3rem !important;
    }

    section[aria-label='Cover lead'] > div {
        margin-bottom: 0.2rem !important;
    }

    /* Thumbnail adjustments - smaller */
    figure {
        max-width: 1.5in !important; /* Reduced from 2in */
        height: 1in !important;
        display: none !important; /* Hide thumbnail for more space */
    }

    /* Header text adjustments */
    h1 {
        font-size: 14pt !important; /* Reduced from 18pt */
        margin-bottom: 0.2rem !important;
        margin-top: 0 !important;
    }

    h2 {
        font-size: 11pt !important; /* Reduced from 14pt */
        margin-bottom: 0.2rem !important;
        margin-top: 0.2rem !important;
    }

    /* Filename box - balanced compact */
    .inline-flex.items-center.rounded-lg {
        padding: 0.25rem 0.4rem !important;
        margin-top: 0.3rem !important;
    }

    /* Stats cards - optimized for landscape with more horizontal space */
    .grid.md\:grid-cols-3 {
        display: flex !important;
        gap: 0.6rem !important; /* Slightly more gap in landscape */
        margin-bottom: 0.5rem !important;
    }

    .grid.md\:grid-cols-3 > div {
        flex: 1 !important;
        padding: 0.5rem 0.8rem !important; /* More horizontal padding in landscape */
        border: 1px solid #ddd !important;
    }

    .grid.md\:grid-cols-3 p.text-3xl {
        font-size: 12pt !important; /* Smaller stat numbers */
        margin: 0 !important;
    }

    /* Single combined chart section */
    section[aria-label='Performance chart'] > div {
        padding: 0.5rem !important;
    }

    /* Chart container - optimized height for combined chart - adjusted for landscape */
    .h-80 {
        height: 140px !important; /* Increased height for landscape mode */
        overflow: visible !important; /* Prevent chart container scrollbars */
    }

    .h-64 {
        height: 100px !important;
        overflow: visible !important;
    }

    /* Specifically target the chart div to prevent scrollbars */
    #combinedChart {
        overflow: visible !important;
    }

    canvas {
        max-height: 140px !important; /* Increased for landscape orientation */
        width: auto !important;
    }

    /* All Locations section - more compact in print */
    section[aria-label='All locations'] .space-y-4 > div {
        padding: 0.2rem 0.3rem !important;
        margin-bottom: 0.15rem !important;
    }

    section[aria-label='All locations'] .text-2xl {
        font-size: 10pt !important;
    }

    section[aria-label='All locations'] .text-sm {
        font-size: 8pt !important;
    }

    section[aria-label='All locations'] .text-xs {
        font-size: 7pt !important;
    }

    /* Hide legend in print to save space */
    .chartjs-legend {
        display: none !important;
    }

    /* Top locations - balanced compact */
    section[aria-label='Top performing locations'] > div {
        padding: 0.5rem !important;
    }

    .space-y-4 {
        space-y: 0 !important;
    }

    .space-y-4 > div {
        padding: 0.3rem 0.5rem !important; /* Reasonable padding */
        margin-bottom: 0.2rem !important; /* Readable margin */
        border: 0.5px solid #e5e7eb !important;
        background-color: #f9fafb !important;
    }

    /* Text size adjustments - all smaller */
    .text-3xl {
        font-size: 11pt !important; /* Reduced */
    }

    .text-2xl {
        font-size: 10pt !important; /* Reduced */
    }

    .text-lg {
        font-size: 9pt !important; /* Reduced */
    }

    .text-base,
    .text-sm {
        font-size: 8pt !important; /* Reduced */
    }

    .text-xs {
        font-size: 7pt !important; /* Reduced */
    }

    /* Padding adjustments - maintain readability */
    .p-6 {
        padding: 0.5rem !important;
    }

    .p-4 {
        padding: 0.4rem !important;
    }

    .px-6 {
        padding-left: 0.5rem !important;
        padding-right: 0.5rem !important;
    }

    .py-12 {
        padding-top: 0 !important;
        padding-bottom: 0 !important;
    }

    /* Ensure borders and backgrounds print */
    .border,
    .border-gray-200 {
        border-color: #d1d5db !important;
    }

    .bg-gray-50 {
        background-color: #f9fafb !important;
    }

    .bg-blue-50 {
        background-color: #eff6ff !important;
    }

    /* Page breaks */
    .page-break-before {
        page-break-before: always;
    }

    .page-break-after {
        page-break-after: always;
    }

    /* Ensure content fits on page */
    .overflow-hidden {
        overflow: visible !important;
    }

    /* Table adjustments if shown */
    table {
        font-size: 9pt !important;
        width: 100% !important;
    }

    th,
    td {
        padding: 0.25rem !important;
    }
}
