/* Shared View Image Modal Styles */
/* This file provides consistent styling for the image viewing modal across all pages */

.image-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.image-modal.show {
    opacity: 1;
    visibility: visible;
}

.image-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
}

.image-modal-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    background: #000;
}

/* Filter Sidebar */
.image-filter-sidebar {
    width: 200px;
    background: #2a2a2a;
    border-right: 1px solid #444;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.filter-buttons {
    display: flex;
    flex-direction: column;
    padding: 15px 10px;
    gap: 10px;
}

.filter-btn {
    display: flex;
    flex-direction: row;
    align-items: center;
    padding: 10px;
    background: transparent;
    border: 2px solid #fff;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    gap: 12px;
}

.filter-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateX(4px);
}

.filter-btn.active {
    background: rgba(0, 123, 255, 0.3);
    border-color: #007bff;
}

.filter-btn img {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.filter-btn span {
    font-size: 13px;
    color: #fff;
    font-weight: 500;
    text-align: left;
    flex: 1;
}

/* Main Image View */
.image-main-view {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.image-content {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.modal-image {
    max-width: 85%;
    max-height: 85%;
    width: auto;
    height: auto;
    object-fit: contain;
    transform-origin: center center;
    transition: opacity 0.3s;
    /* Ensure aspect ratio is preserved at all resolutions */
    aspect-ratio: attr(width) / attr(height);
}

/* Stitched images: Slightly oval to prevent pointy edges */
.modal-image[data-is-stitch="true"] {
    max-width: 88%;
    max-height: 65%;
    border-radius: 48% / 46%; /* Gentle oval shape to prevent sharp pointy edges */
    object-fit: cover;
}

.image-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #999;
    font-size: 18px;
}

.image-error i {
    font-size: 48px;
    margin-bottom: 10px;
}

/* Info Panel */
.image-info-panel {
    width: 280px;
    background: #1a1a1a;
    border-left: 1px solid #333;
    display: flex;
    flex-direction: column;
}

.image-info-content {
    padding: 20px;
    color: #fff;
}

.info-item {
    margin-bottom: 15px;
}

.info-item label {
    color: #ccc;
    font-size: 14px;
    word-wrap: break-word;
}

.control-section {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #333;
}

.control-item {
    margin-bottom: 15px;
}

.control-item label {
    display: block;
    margin-bottom: 5px;
    color: #ccc;
    font-size: 13px;
}

.control-item input[type="range"] {
    width: 100%;
    height: 5px;
    background: #444;
    border-radius: 5px;
    outline: none;
    -webkit-appearance: none;
}

.control-item input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 15px;
    height: 15px;
    background: #007bff;
    border-radius: 50%;
    cursor: pointer;
}

.control-item input[type="range"]::-moz-range-thumb {
    width: 15px;
    height: 15px;
    background: #007bff;
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

.control-btn {
    width: 100%;
    padding: 10px;
    margin-bottom: 10px;
    background: #007bff;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.2s;
}

.control-btn:hover {
    background: #0056b3;
}

.reset-btn {
    background: #28a745;
}

.reset-btn:hover {
    background: #218838;
}

.back-btn {
    background: #6c757d;
}

.back-btn:hover {
    background: #5a6268;
}

.magnify-btn {
    background: #17a2b8;
}

.magnify-btn:hover {
    background: #138496;
}

.magnify-btn.active {
    background: #0c7c8c;
    border: 2px solid #ffc107;
}

/* Magnifying Glass Styles */
.magnifying-glass {
    position: absolute;
    border-radius: 50%;
    overflow: hidden;
    pointer-events: none;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5),
                0 0 10px rgba(0, 123, 255, 0.3);
    background: #000;
}

.magnifying-glass canvas {
    width: 100%;
    height: 100%;
    border-radius: 50%;
}

.magnify-label {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    color: #ffc107;
    background: rgba(0, 0, 0, 0.7);
    padding: 8px 16px;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    z-index: 10001;
    pointer-events: none;
}

/* Responsive adjustments */
/* 4K resolution (3840×2160) */
@media (min-width: 3840px) {
    .image-content {
        padding: 60px;
    }

    .modal-image {
        max-width: 75%;
        max-height: 75%;
        object-fit: contain;
        object-position: center;
    }

    .modal-image[data-is-stitch="true"] {
        max-width: 88%;
        max-height: 72%;
        border-radius: 48% / 46%; /* Gentle oval shape for 4K */
        object-fit: cover;
    }

    .image-filter-sidebar {
        width: 160px;
    }

    .filter-btn {
        padding: 16px 14px;
    }

    .filter-btn img {
        width: 75px;
        height: 75px;
    }

    .image-info-panel {
        width: 340px;
    }
}

/* Tablet - iPad Pro 12.9" - 2732×2048 */
@media (min-width: 2732px) and (max-width: 3839px) and (min-height: 2048px) and (max-height: 2159px) {
    .image-content {
        padding: 45px;
    }

    .modal-image {
        max-width: 82%;
        max-height: 82%;
        object-fit: contain;
        object-position: center;
    }

    .modal-image[data-is-stitch="true"] {
        max-width: 90%;
        max-height: 70%;
        border-radius: 48% / 46%; /* Gentle oval shape */
        object-fit: cover;
    }

    .image-filter-sidebar {
        width: 150px;
    }

    .filter-btn img {
        width: 68px;
        height: 68px;
    }

    .image-info-panel {
        width: 310px;
    }
}

/* High resolution fixes (2560×1440, 2560×1600) and Tablet - iPad Pro 11" - 2048×1536 */
@media (min-width: 2048px) and (max-width: 2731px) {
    .image-content {
        padding: 40px;
    }

    .modal-image {
        max-width: 80%;
        max-height: 80%;
        /* Ensure circular images stay circular, not elliptical */
        object-fit: contain;
        object-position: center;
    }

    /* For stitch images (wide panoramic images), allow more width and make oval */
    .modal-image[data-is-stitch="true"] {
        max-width: 88%;
        max-height: 72%;
        border-radius: 48% / 46%; /* Gentle oval shape */
        object-fit: cover;
    }

    .image-filter-sidebar {
        width: 140px;
    }

    .filter-btn {
        padding: 14px 12px;
    }

    .filter-btn img {
        width: 70px;
        height: 70px;
    }

    .image-info-panel {
        width: 320px;
    }
}

/* QHD/Tablet resolution specific (2560×1440) */
@media (min-width: 2560px) and (max-width: 2560px) and (min-height: 1440px) and (max-height: 1440px) {
    .modal-image {
        max-width: 82%;
        max-height: 82%;
    }
}

/* Tablet - 1920×1080 (Full HD tablets) */
@media (min-width: 1920px) and (max-width: 2047px) and (min-height: 1080px) {
    .image-content {
        padding: 35px;
    }

    .modal-image {
        max-width: 82%;
        max-height: 82%;
        object-fit: contain;
        object-position: center;
    }

    .modal-image[data-is-stitch="true"] {
        max-width: 90%;
        max-height: 70%;
        border-radius: 48% / 46%; /* Gentle oval shape */
        object-fit: cover;
    }

    .image-filter-sidebar {
        width: 130px;
    }

    .filter-btn img {
        width: 65px;
        height: 65px;
    }

    .image-info-panel {
        width: 300px;
    }
}

/* Tablet - 1280×800 (common Android tablet resolution) */
@media (min-width: 1280px) and (max-width: 1439px) and (min-height: 800px) and (max-height: 1079px) {
    .image-filter-sidebar {
        width: 110px;
    }

    .filter-btn {
        flex-direction: column;
        padding: 9px;
        gap: 7px;
    }

    .filter-btn img {
        width: 55px;
        height: 55px;
    }

    .filter-btn span {
        font-size: 11px;
        text-align: center;
    }

    .image-info-panel {
        width: 260px;
    }

    .image-content {
        padding: 25px;
    }

    .modal-image {
        max-width: 83%;
        max-height: 83%;
        object-fit: contain;
    }
}

/* Low resolution fixes (1366x768, 1280x720) */
@media (max-width: 1440px) and (max-height: 799px) {
    .image-filter-sidebar {
        width: 100px;
    }

    .filter-btn {
        flex-direction: column;
        padding: 8px;
        gap: 6px;
        min-height: auto;
    }

    .filter-btn img {
        width: 50px;
        height: 50px;
    }

    .filter-btn span {
        font-size: 10px;
        text-align: center;
        word-wrap: break-word;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 100%;
        line-height: 1.2;
    }

    .filter-buttons {
        padding: 10px 5px;
        gap: 8px;
    }

    .image-info-panel {
        width: 240px;
    }

    /* Ensure image is properly centered and not cut off */
    .image-content {
        padding: 20px;
    }

    .modal-image {
        max-width: calc(100% - 40px);
        max-height: calc(100% - 40px);
        object-fit: contain;
    }
}

@media (max-width: 1024px) {
    .image-filter-sidebar {
        width: 90px;
    }

    .filter-btn img {
        width: 45px;
        height: 45px;
    }

    .filter-btn span {
        font-size: 9px;
    }

    .image-info-panel {
        width: 200px;
    }
}

@media (max-width: 768px) {
    .image-modal-container {
        flex-direction: column;
    }

    .image-filter-sidebar {
        width: 100%;
        height: auto;
        max-height: 150px;
        border-right: none;
        border-bottom: 1px solid #444;
        overflow-y: auto;
    }

    .filter-buttons {
        flex-direction: row;
        overflow-x: auto;
        padding: 10px;
    }

    .filter-btn {
        flex-direction: column;
        min-width: 80px;
    }

    .image-info-panel {
        width: 100%;
        height: auto;
        max-height: 200px;
        border-left: none;
        border-top: 1px solid #444;
        overflow-y: auto;
    }
}
