/* =====================================================================
 * Coloring Page Studio — Global & Print Styles
 * ===================================================================== */

body {
    font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Spinners */
.spinner {
    border: 3px solid rgba(14, 165, 233, 0.2);
    border-left-color: #0284c7;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    animation: spin 0.8s linear infinite;
}

.spinner-white {
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-left-color: #ffffff;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Custom Scrollbars */
#historyContainer::-webkit-scrollbar {
    height: 6px;
}
#historyContainer::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 8px;
}
#historyContainer::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 8px;
}
#historyContainer::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Global Transitions */
.btn-press {
    transition: transform 0.1s ease, background-color 0.15s ease, box-shadow 0.15s ease;
}
.btn-press:active {
    transform: scale(0.98);
}

/* =====================================================================
 * PRINT MEDIA QUERY — Guaranteed Single-Sheet Printing (Letter & A4)
 * ---------------------------------------------------------------------
 * Strictly constrains total content height to <= 9.8 inches to eliminate
 * any 2nd page overflow across all printer drivers, Chrome, Safari & Firefox.
 * Includes a clean branding watermark at bottom.
/* Quick Sample Carousel at top of Studio */
.carousel-scroll {
    overflow-x: auto;
    overflow-y: hidden;
    scroll-behavior: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
    user-select: none;
    cursor: grab;
}
.carousel-scroll:active {
    cursor: grabbing;
}
.carousel-scroll::-webkit-scrollbar {
    display: none;
}

/* =====================================================================
 * PRINT MEDIA QUERY — Guaranteed Full-Sheet Printing (Letter & A4)
 * ---------------------------------------------------------------------
 * Maximizes artwork printable area with tight 0.2in margins while
 * keeping a clean single-line footer watermark to guarantee zero 2nd page spillover.
 * ===================================================================== */
@media print {
    @page {
        size: letter portrait;
        margin: 0.2in;
    }

    *, *:before, *:after {
        box-sizing: border-box !important;
    }

    html, body {
        width: 100% !important;
        height: 100% !important;
        max-height: 100% !important;
        overflow: hidden !important;
        margin: 0 !important;
        padding: 0 !important;
        background: white !important;
        color: black !important;
        page-break-after: avoid !important;
        page-break-inside: avoid !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    /* Completely eliminate non-printable UI elements */
    .no-print, header, nav, footer, #apiKeyModal, #affiliateBox, #actionButtons, #messageBox, #loadingBox, #emptyState, section, #coverCarouselSection {
        display: none !important;
        visibility: hidden !important;
        height: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    main {
        border: none !important;
        box-shadow: none !important;
        padding: 0 !important;
        margin: 0 auto !important;
        max-width: 100% !important;
        width: 100% !important;
        height: 100% !important;
        max-height: 10.6in !important;
        background: white !important;
        display: flex !important;
        flex-direction: column !important;
        justify-content: center !important;
        align-items: center !important;
        page-break-inside: avoid !important;
        page-break-after: avoid !important;
        page-break-before: avoid !important;
    }

    #printArea, #printablePage {
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: center !important;
        width: 100% !important;
        max-height: 10.5in !important;
        height: auto !important;
        border: none !important;
        box-shadow: none !important;
        padding: 0 !important;
        margin: 0 auto !important;
        background: white !important;
        page-break-inside: avoid !important;
        page-break-after: avoid !important;
    }

    #imageOutput, #printableImg {
        display: block !important;
        max-width: 100% !important;
        max-height: 10.1in !important; /* Full printable height */
        width: auto !important;
        height: auto !important;
        object-fit: contain !important;
        border: none !important;
        box-shadow: none !important;
        margin: 0 auto !important;
        page-break-inside: avoid !important;
        page-break-after: avoid !important;
    }

    /* Watermark at bottom of printed page */
    .print-watermark {
        display: block !important;
        font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif !important;
        font-size: 7.5pt !important;
        color: #94a3b8 !important;
        text-align: center !important;
        width: 100% !important;
        margin-top: 3pt !important;
        margin-bottom: 0 !important;
        padding: 0 !important;
        page-break-inside: avoid !important;
        page-break-after: avoid !important;
    }
}
