/**
 * SY Flyer Reader - Frontend Styles
 */

/* Screen Reader Only - Accessible but Hidden */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Focus styles for accessibility */
.sr-only:focus {
    position: static;
    width: auto;
    height: auto;
    margin: 0;
    overflow: visible;
    clip: auto;
    white-space: normal;
}

.sy-flyer-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: #2d6a4f;
    margin-bottom: 1.5rem;
    text-align: center;
}

/* Flyer Viewer */
.sy-flyer-viewer {
    background: transparent;
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    position: relative;
}

/* Unified Controls Toolbar */
.sy-flyer-controls-toolbar {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 1rem;
    padding: 0.75rem;
    background: rgba(45, 106, 79, 0.9);
    /* Dark Green background for toolbar */
    border-radius: 50px;
    color: white;
    backdrop-filter: blur(10px);
    position: absolute;
    bottom: 10px;
    z-index: 2;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: max-content;
}

.sy-flyer-nav-controls,
.sy-flyer-zoom-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sy-flyer-separator {
    width: 1px;
    height: 24px;
    background: rgba(255, 255, 255, 0.3);
    margin: 0 0.5rem;
}

.sy-flyer-btn {
    width: 24px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3) !important;
    color: white;
    font-size: 1rem !important;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    touch-action: manipulation;
    padding: 0px !important;
    width: 38px !important;
    height: 38px !important;
    border-color: transparent !important;

    span {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 100%;
        height: 100%;

        svg {
            width: 14px;
            height: 14px;
        }
    }
}

.sy-flyer-zoom-reset span svg {
    width: 16px;
    height: 16px;
}

.sy-flyer-btn:active:not(:disabled) {
    filter: opacity(.95);
}

.sy-flyer-btn:hover:not(:disabled) {
    filter: brightness(.8);
}

.sy-flyer-btn:disabled {
    background: rgba(0, 0, 0, 0.2);
    color: rgba(255, 255, 255, 0.3);
    cursor: not-allowed;
    border-color: transparent;
}

.sy-flyer-page-info,
.sy-flyer-zoom-level {
    font-size: 0.75rem;
    font-weight: 600;
    min-width: 50px;
    text-align: center;
}

.sy-flyer-zoom-out span svg {
    width: 18px;
    height: 18px;
}

/* Viewport */
.sy-flyer-viewport {
    position: relative;
    width: 100%;
    max-width: 100%;
    height: 100%;
    /* Default height */
    overflow: hidden;
    border-radius: 12px;
    touch-action: none;
    /* Important for custom pinch gestures */
    cursor: zoom-in;
    /* Default cursor for zoomable area */
}

/* When zoomed, show grab cursor */
.sy-flyer-viewport.is-zoomed {
    cursor: grab;
}

.sy-flyer-viewport.is-panning {
    cursor: grabbing;
}

/* Content Wrapper */
.sy-flyer-content-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    transform-origin: center center;
    transition: transform 0.1s ease-out;
    width: 100%;
    height: 100%;
    border-radius: 10px;
}

.sy-flyer-content-wrapper.is-panning {
    transition: none;
}

.sy-flyer-content-canvas,
.sy-flyer-content-image {
    max-width: 100%;
    min-height: 90vh;
    max-height: 750px;
    object-fit: contain;
    pointer-events: none;
    border-radius: 10px;
}

/* Error Message */
.sy-flyer-error {
    color: #d00000;
    padding: 1rem;
    background: #fff5f5;
    border: 1px solid #fed7d7;
    border-radius: 8px;
    text-align: center;
}

/* Fullscreen Modal Styles */
.sy-flyer-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 99999;
    align-items: center;
    justify-content: center;
}

.sy-flyer-modal.is-open {
    display: flex;
}

.sy-flyer-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(5px);
}

.sy-flyer-modal-content {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    z-index: 100;
}

.sy-flyer-modal-close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 44px !important;
    height: 44px !important;
    border-radius: 100% !important;
    background: #000000 !important;
    border: none;
    color: white;
    font-size: 2rem;
    line-height: 1;
    cursor: pointer;
    z-index: 101;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    padding: 0 !important;
    border-color: transparent !important;
}

.sy-flyer-modal-close:hover {
    background: rgba(255, 255, 255, 0.4);
    transform: scale(1.1);
}

.sy-flyer-modal-body {
    flex: 1;
    overflow: hidden;
    padding: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    width: 100%;
    height: 100%;
    background: #fff;
}

.sy-flyer-modal-body img,
.sy-flyer-modal-body canvas {
    max-width: 100%;
    height: 100%;
    object-fit: contain;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    margin: auto;
}

/* In fullscreen, we want the image to be large and legible. 
   But strictly 'full height/width' might mean filling viewport. 
   Usually 'fullscreen' viewing implies "fit to screen" OR "pixel perfect scrollable".
   Let's default to fitting width (max-width: 100%) so it doesn't overflow horizontally by default,
   but acts as a scrollable flyer. 
*/

/* Responsive */
@media (max-width: 768px) {
    .sy-flyer-controls-toolbar {
        padding: 0.5rem;
        gap: 0.5rem;
        border-radius: 50px;
    }

    .sy-flyer-btn {
        width: 32px !important;
        height: 32px !important;
    }

    .sy-flyer-viewport {
        height: 400px;
    }

    .sy-flyer-modal-body {
        padding: 0.5rem;
    }

    .sy-flyer-modal-content .sy-flyer-controls-toolbar {
        bottom: 40px;
    }
}