/* Frontend Styles for Multi-Layer Image Viewer - Modern Design with Sidebar */

/* ===== 1. LAYOUT STABILITY - FIRST ===== */
.multilayer-viewer-container {
    max-width: 1400px;
    margin: 30px auto;
    padding: 0;
    background: #FFEEE1 !important; /* NEW: Changed to your color */
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.1); /* Lighter shadow to match new color */
    overflow: hidden;
    font-family: Arial, sans-serif;
    display: flex;
    flex-direction: row-reverse;
    /* Prevent layout shifts */
    min-height: 800px;
    position: relative; /* For notifications */
    border: none !important; /* NEW: Remove any borders */
}

.mliv-inner {
    background: #FFEEE1;
    margin: 3px;
    border-radius: 14px;
    padding: 25px;
    display: flex;
    flex: 1;
    gap: 20px;
    /* Prevent layout shifts */
    min-height: 780px;
    border: none; /* NEW: Remove borders */
}

.mliv-sidebar {
    width: 280px;
    min-width: 280px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    /* Prevent layout shifts */
    height: 100%;
    flex-shrink: 0;
}

.mliv-viewer-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    gap: 20px;
    /* Prevent layout shifts */
    height: 100%;
}

.mliv-viewer {
    border: 3px solid #e9ecef;
    border-radius: 12px;
    overflow: hidden;
    background: #000;
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    position: relative;
    flex: 1;
    min-height: 500px;
    /* Prevent layout shifts */
    height: 100%;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    pointer-events: auto;
}

/* Make sure opacity controls don't cause shifts when showing/hiding */
.mliv-opacity-controls-under {
    display: none;
    background: #f8f9fa;
    padding: 15px;
    border-radius: 12px;
    border: 2px solid #e9ecef;
    margin-top: 0;
    /* Prevent layout shifts */
    height: auto;
    min-height: 80px;
    flex-shrink: 0;
}

.mliv-opacity-controls-under.show {
    display: block;
}

/* Add this to disable transitions during layer changes */
.no-transitions * {
    transition: none !important;
    animation: none !important;
}

/* Disable all animations during layer changes to prevent shifts */
.mliv-viewer.loading * {
    transition: none !important;
    animation: none !important;
}

/* ===== 2. NOTIFICATION FIXES - SECOND ===== */
/* Fix notification layout shifting */
.mliv-notification {
    position: absolute !important;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10000;
    background: #5B3737 !important;
    color: #FBF8F6 !important;
    padding: 12px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(91, 55, 55, 0.4);
    font-weight: 600;
    font-size: 14px;
    border: none;
    min-width: 300px;
    text-align: center;
    pointer-events: none;
}

.mliv-notification-info {
    background: #5B3737 !important;
}

.mliv-notification-error {
    background: #dc3232 !important;
}

.mliv-notification-success {
    background: #46b450 !important;
}

/* ===== 3. FONTS & TYPOGRAPHY - THIRD ===== */
/* Load Quattrocento font if available */
@font-face {
    font-family: 'Quattrocento';
    font-style: normal;
    font-weight: 400;
    src: local('Quattrocento'), local('Quattrocento-Regular'),
         url('/wp-content/themes/your-theme/fonts/quattrocento.woff2') format('woff2'),
         url('/wp-content/themes/your-theme/fonts/quattrocento.woff') format('woff');
    font-display: swap;
}

@font-face {
    font-family: 'Quattrocento';
    font-style: normal;
    font-weight: 700;
    src: local('Quattrocento Bold'), local('Quattrocento-Bold'),
         url('/wp-content/themes/your-theme/fonts/quattrocento-bold.woff2') format('woff2'),
         url('/wp-content/themes/your-theme/fonts/quattrocento-bold.woff') format('woff');
    font-display: swap;
}

/* Apply Quattrocento if available, otherwise use Arial */
.multilayer-viewer-container {
    font-family: 'Quattrocento', Arial, serif;
}

/* ===== 4. ALL OTHER STYLES - FOURTH ===== */
.mliv-header {
    margin-bottom: 0;
    padding-bottom: 15px;
    border-bottom: 3px solid #f0f0f0;
    text-align: center;
    flex-shrink: 0;
}

.mliv-header h3 {
    margin: 0 0 10px 0;
    font-size: 32px;
    font-weight: 700;
    color: #1a1a1a;
    letter-spacing: -0.5px;
}

.mliv-header p {
    margin: 0;
    color: #666;
    font-size: 16px;
    line-height: 1.6;
}

/* Controls Section - Updated for Sidebar */
.mliv-controls {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 0;
    height: 100%;
    overflow-y: auto;
    max-height: 70vh;
}

.mliv-control-group {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 12px;
    border: 2px solid #e9ecef;
    margin-bottom: 0;
}

.mliv-control-group label {
    display: block;
    margin-bottom: 10px;
    font-weight: 600;
    color: #2c3e50;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Layer Selection - Updated for Sidebar */
.mliv-layer-grid {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.mliv-layer-checkbox {
    position: relative;
}

.mliv-layer-checkbox input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.mliv-layer-label {
    display: block;
    padding: 8px 12px;
    background: #F8F3EF;
    border: 2px solid #dee2e6;
    border-radius: 6px;
    cursor: pointer;
    text-align: left;
    font-size: 13px;
    font-weight: 500;
    color: #0F172A;
    transition: all 0.2s ease;
    user-select: none;
    width: 100%;
}

.mliv-layer-checkbox input:checked + .mliv-layer-label,
.mliv-layer-label:hover {
    background: #5B3737;
    border-color: #5B3737;
    color: #FBF8F6;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(91, 55, 55, 0.4);
}

.mliv-layer-checkbox input:checked + .mliv-layer-label {
    box-shadow: 0 2px 8px rgba(91, 55, 55, 0.6);
}

.mliv-opacity-slider {
    width: 100%;
}

.mliv-opacity-slider-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.mliv-opacity-slider-label {
    font-size: 14px;
    color: #495057;
    font-weight: 600;
}

.mliv-opacity-value {
    font-size: 14px;
    font-weight: 700;
    color: #5B3737;
    min-width: 50px;
    text-align: right;
}

.mliv-slider {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: #e9ecef;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.mliv-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #5B3737 !important;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(91, 55, 55, 0.4);
    transition: transform 0.2s;
}

.mliv-slider::-webkit-slider-thumb:hover {
    transform: scale(1.15);
    background: #4A2C2C !important;
}

.mliv-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #5B3737 !important;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 6px rgba(91, 55, 55, 0.4);
    transition: transform 0.2s;
}

.mliv-slider::-moz-range-thumb:hover {
    transform: scale(1.15);
    background: #4A2C2C !important;
}

/* Quick Presets - Updated for Sidebar */
.mliv-presets {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px dashed #dee2e6;
}

.mliv-preset-btn {
    padding: 6px 10px;
    background: linear-gradient(135deg, #5B3737 0%, #8B5A5A 100%);
    border: none;
    border-radius: 4px;
    color: #FBF8F6;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 1px 4px rgba(91, 55, 55, 0.3);
    text-align: left;
    width: 100%;
}

.mliv-preset-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(91, 55, 55, 0.4);
    background: linear-gradient(135deg, #4A2C2C 0%, #7A4A4A 100%);
}

.mliv-preset-btn:active {
    transform: translateY(0);
}

/* Swap Button */
.mliv-swap-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 8px 16px;
    background: #5B3737;
    border: none;
    border-radius: 6px;
    color: #FBF8F6;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 1px 4px rgba(91, 55, 55, 0.3);
    margin-top: 8px;
}

.mliv-swap-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(91, 55, 55, 0.4);
    background: #5B3737;
    color: #FBF8F6;
}

.mliv-swap-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    background: #5B3737;
    color: #FBF8F6;
}

.mliv-swap-icon {
    display: inline-block;
    transition: transform 0.2s ease;
    font-size: 12px;
}

.mliv-swap-btn:hover .mliv-swap-icon {
    transform: rotate(180deg);
}

/* Disable right-click and drag on all images */
.mliv-viewer img {
    pointer-events: none;
    user-select: none;
    -webkit-user-drag: none;
    -khtml-user-drag: none;
    -moz-user-drag: none;
    -o-user-drag: none;
}

/* Zoom Controls Hint */
.mliv-hint {
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(0,0,0,0.7);
    color: #fff;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 11px;
    z-index: 1000;
    backdrop-filter: blur(10px);
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Loading State */
.mliv-viewer.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255,255,255,0.3);
    border-top-color: #5B3737;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    z-index: 1000;
}

@keyframes spin {
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

/* ===== 5. MOBILE & TABLET FIXES - LAST ===== */

/* Tablet (768px - 1024px) */
@media (max-width: 1024px) {
    .multilayer-viewer-container {
        margin: 15px 10px;
        min-height: auto;
        flex-direction: column;
    }
    
    .mliv-inner {
        padding: 15px;
        flex-direction: column;
        gap: 20px;
        min-height: auto;
    }
    
    .mliv-sidebar {
        width: 100%;
        min-width: auto;
        order: 2;
        height: auto;
        max-height: 40vh;
        overflow-y: auto;
    }
    
    .mliv-viewer-container {
        order: 1;
        height: 50vh;
        min-height: 400px;
        gap: 15px;
    }
    
    .mliv-viewer {
        height: 100% !important;
        min-height: 350px;
        /* Ensure viewer is properly sized for mobile */
        width: 100% !important;
    }
    
    .mliv-controls {
        max-height: none;
        gap: 12px;
    }
    
    .mliv-layer-grid {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        gap: 8px;
    }
    
    .mliv-layer-label {
        width: auto;
        min-width: 140px;
        text-align: center;
        font-size: 12px;
    }
    
    .mliv-presets {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        gap: 6px;
    }
    
    .mliv-preset-btn {
        width: auto;
        font-size: 10px;
        text-align: center;
        flex: 1;
        min-width: 120px;
    }
    
    .mliv-opacity-controls-under {
        margin-top: 10px;
    }
    
    .mliv-control-group {
        margin-bottom: 0;
    }
}

/* Mobile (480px - 768px) */
@media (max-width: 768px) {
    .multilayer-viewer-container {
        margin: 10px 5px;
        border-radius: 8px;
    }
    
    .mliv-inner {
        padding: 12px;
        gap: 15px;
    }
    
    .mliv-viewer-container {
        height: 45vh;
        min-height: 350px;
    }
    
    .mliv-sidebar {
        max-height: 35vh;
    }
    
    .mliv-header h3 {
        font-size: 24px;
    }
    
    .mliv-header p {
        font-size: 14px;
    }
    
    .mliv-control-group {
        padding: 12px;
    }
    
    .mliv-layer-grid {
        gap: 6px;
    }
    
    .mliv-layer-label {
        min-width: 120px;
        font-size: 11px;
        padding: 6px 10px;
    }
    
    .mliv-preset-btn {
        min-width: 110px;
        font-size: 9px;
        padding: 5px 8px;
    }
}

/* Small Mobile (under 480px) */
@media (max-width: 480px) {
    .multilayer-viewer-container {
        margin: 8px 4px;
    }
    
    .mliv-inner {
        padding: 10px;
        gap: 12px;
    }
    
    .mliv-viewer-container {
        height: 40vh;
        min-height: 300px;
    }
    
    .mliv-sidebar {
        max-height: 30vh;
    }
    
    .mliv-viewer {
        min-height: 280px;
    }
    
    .mliv-layer-grid {
        flex-direction: column;
        gap: 5px;
    }
    
    .mliv-layer-label {
        width: 100%;
        text-align: left;
        min-width: auto;
    }
    
    .mliv-presets {
        flex-direction: column;
        gap: 4px;
    }
    
    .mliv-preset-btn {
        width: 100%;
        min-width: auto;
        text-align: left;
    }
    
    .mliv-hint {
        font-size: 10px;
        padding: 6px 10px;
        top: 10px;
        right: 10px;
    }
    
    .mliv-control-group label {
        font-size: 12px;
    }
    
    .mliv-opacity-controls-under {
        padding: 12px;
    }
    
    .mliv-opacity-slider-header {
        flex-direction: column;
        gap: 5px;
        align-items: flex-start;
    }
    
    .mliv-swap-btn {
        width: 100%;
        justify-content: center;
    }
}

/* Very small mobile (under 360px) */
@media (max-width: 360px) {
    .mliv-viewer-container {
        height: 35vh;
        min-height: 250px;
    }
    
    .mliv-sidebar {
        max-height: 25vh;
    }
    
    .mliv-header h3 {
        font-size: 20px;
    }
    
    .mliv-control-group {
        padding: 10px;
    }
    
    .mliv-layer-label {
        font-size: 10px;
        padding: 5px 8px;
    }
}

/* ===== 6. MOBILE IMAGE LOADING FIXES ===== */
/* Ensure OpenSeadragon viewer works on mobile */
.openseadragon-container {
    width: 100% !important;
    height: 100% !important;
}

/* Force the viewer to take full available space on mobile */
.mliv-viewer .openseadragon-canvas {
    width: 100% !important;
    height: 100% !important;
}

/* Mobile-specific viewer fixes */
@media (max-width: 1024px) {
    .mliv-viewer {
        /* Reset any transforms that might break mobile viewing */
        transform: none !important;
    }
    
    /* Ensure the OpenSeadragon container is properly sized */
    #openseadragon-viewer {
        width: 100% !important;
        height: 100% !important;
    }
}