/* Selected Image Display Styling (Single Image Mode)
   This file contains all styles related to displaying a single image with 1-4 faces
   UPDATED: Fixed animation overlap with hover effects
*/

/* ==========================================================================
   Image Display Container
   ========================================================================== */

/* Main container for selected image */
.selected-images-container {
    padding: 15px;
    background-color: white;
    min-height: calc(100vh - 56px);
    perspective: 1000px; /* Add perspective for 3D effects */
}

/* Single image display container */
.selected-image-display {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    min-height: 400px;
}

/* ==========================================================================
   Image Card
   ========================================================================== */

/* Enhanced styling for selected image card with natural aspect ratio */
.selected-image-item {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.15),
    0 1px 3px rgba(0, 0, 0, 0.08);
    background: linear-gradient(135deg, #6200ee, #03dac6);
    padding: 3px; /* Padding for the gradient border */
    display: block;
    transform: scale(1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    transform-origin: center;
    will-change: transform, box-shadow;
    max-width: 800px; /* Limit maximum width for large screens */
    width: 100%;
    margin: 0 auto;
}

/* The image itself preserves aspect ratio */
.selected-image-item img {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 9px; /* Match the container minus padding */
    transition: filter 0.3s ease;
    background-color: white;
    cursor: pointer;
    object-fit: contain;
}

/* ==========================================================================
   Animations - UPDATED to prevent conflicts
   ========================================================================== */

/* Animation classes - These are temporary and removed after animation */
.card-enter {
    animation: cardFadeIn 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

.card-exit {
    animation: cardFadeOut 0.5s cubic-bezier(0.55, 0.085, 0.68, 0.53) forwards;
    pointer-events: none;
}

@keyframes cardFadeIn {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes cardFadeOut {
    from {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    to {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
}

/* Enhanced hover effects - ONLY apply when card-enter is NOT present */
@keyframes cardGlow {
    0% {
        box-shadow: 0 6px 15px rgba(0, 0, 0, 0.15),
        0 1px 3px rgba(0, 0, 0, 0.08);
    }
    50% {
        box-shadow: 0 8px 20px rgba(98, 0, 238, 0.3),
        0 4px 10px rgba(0, 0, 0, 0.1);
    }
    100% {
        box-shadow: 0 6px 15px rgba(0, 0, 0, 0.15),
        0 1px 3px rgba(0, 0, 0, 0.08);
    }
}

/* Hover effects - CRITICAL FIX: Only apply when card-enter class is NOT present */
.selected-image-item:not(.card-enter):not(.card-exit):hover {
    transform: scale(1.03);
    animation: cardGlow 2s infinite ease-in-out;
}

.selected-image-item:not(.card-enter):not(.card-exit):hover img {
    filter: brightness(1.05);
}

/* Prevent hover animation during entry/exit animations */
.selected-image-item.card-enter,
.selected-image-item.card-exit {
    pointer-events: auto; /* Allow clicks during animation */
}

.selected-image-item.card-enter:hover,
.selected-image-item.card-exit:hover {
    transform: none !important; /* Prevent hover transform during enter/exit */
    animation: none !important; /* Prevent hover animation during enter/exit */
}

/* ==========================================================================
   Card Elements - Remove Button & Face Indicator
   ========================================================================== */

/* Remove button styling */
.btn-remove-image {
    position: absolute;
    top: 8px;
    right: 8px;
    background-color: rgba(255, 255, 255, 0.9);
    color: #f44336;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    cursor: pointer;
    z-index: 10;
    transition: all 0.2s ease;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    transform: translateZ(0);
    backface-visibility: hidden;
}

.btn-remove-image:hover {
    background-color: #f44336;
    color: white;
    transform: scale(1.1);
    box-shadow: 0 3px 8px rgba(244, 67, 54, 0.4);
}

.btn-remove-image i {
    font-size: 1rem;
}

/* Face indicator styling */
.face-indicator {
    position: absolute;
    bottom: 8px;
    left: 8px;
    background: linear-gradient(135deg, #6200ee, #03dac6);
    color: white;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 5px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.15);
    transform: translateZ(0);
    backface-visibility: hidden;
}

.face-indicator i {
    font-size: 0.9rem;
}

/* ==========================================================================
   Empty State Styling
   ========================================================================== */

/* Enhanced empty state styling */
.no-images-message {
    text-align: center;
    padding: 30px;
    background: linear-gradient(135deg, rgba(98, 0, 238, 0.05), rgba(3, 218, 198, 0.05));
    border-radius: 12px;
    border: 2px dashed rgba(98, 0, 238, 0.2);
    margin: 20px 0;
    animation: fadeIn 0.5s ease-out, emptyStatePulse 3s infinite;
}

.no-images-message p {
    color: #666;
    margin-bottom: 10px;
}

.no-images-message p:first-child {
    font-weight: 500;
    color: #6200ee;
}

@keyframes emptyStatePulse {
    0% {
        border-color: rgba(98, 0, 238, 0.2);
    }
    50% {
        border-color: rgba(98, 0, 238, 0.5);
    }
    100% {
        border-color: rgba(98, 0, 238, 0.2);
    }
}

@keyframes fadeIn {
    from { opacity: 0; transform: scale(0.8); }
    to { opacity: 1; transform: scale(1); }
}

/* ==========================================================================
   Full Size Image Viewer 
   ========================================================================== */

/* Full-size image viewer */
.full-size-image-viewer {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(0, 0, 0, 0.9), rgba(20, 0, 40, 0.9));
    z-index: 2000;
    display: none;
    justify-content: center;
    align-items: center;
    transition: background-color 0.3s ease-out;
}

.full-size-image-viewer.visible {
    display: flex;
}

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

.full-size-image {
    max-width: 90vw;
    max-height: 90vh;
    object-fit: contain;
    border-radius: 4px;
    z-index: 2001;
    transition: transform 0.3s ease-out, opacity 0.3s ease-out;
}

.btn-close-fs-viewer {
    position: fixed;
    top: 20px;
    right: 20px;
    background-color: rgba(98, 0, 238, 0.6);
    color: white;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    z-index: 2002;
    opacity: 0;
    transition: all 0.2s ease;
    transform: scale(0.8);
}

.btn-close-fs-viewer.visible {
    opacity: 1;
    transform: scale(1);
}

.btn-close-fs-viewer:hover {
    background-color: rgba(98, 0, 238, 0.8);
    transform: scale(1.1);
}

.btn-close-fs-viewer i {
    font-size: 20px;
}

.face-count-badge {
    position: fixed;
    bottom: 20px;
    left: 20px;
    background-color: rgba(0, 0, 0, 0.5);
    color: white;
    border-radius: 20px;
    padding: 5px 12px;
    font-size: 14px;
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.3s ease;
    z-index: 2002;
}

.face-count-badge.visible {
    opacity: 1;
    transform: translateY(0);
}

.face-count-badge i {
    margin-right: 5px;
}

/* Add visual feedback for clickable images */
.selected-image-item:after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(98, 0, 238, 0);
    transition: background-color 0.2s ease;
    pointer-events: none;
    border-radius: 8px;
}

/* Only show overlay on hover when not animating */
.selected-image-item:not(.card-enter):not(.card-exit):hover:after {
    background-color: rgba(98, 0, 238, 0.05);
}

/* Prevent scrolling when viewer is open */
body.full-size-viewer-open {
    overflow: hidden;
    touch-action: none;
}

/* Fullscreen icon hint styles */
.fullscreen-icon-hint {
    position: absolute;
    top: 5px;
    left: 5px;
    background-color: rgba(255, 255, 255, 0.7);
    color: #6200ee;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5;
    animation: fadeIn 0.2s ease;
    pointer-events: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.fullscreen-icon-hint i {
    font-size: 16px;
}

/* Ensure permanent icons for touch devices have higher opacity */
.fullscreen-icon-hint.touch-permanent {
    opacity: 0.9;
}

/* ==========================================================================
   Responsive Styles
   ========================================================================== */

/* Mobile optimizations for the image card */
@media (max-width: 576px) {
    .selected-image-display {
        padding: 10px;
        min-height: 300px;
    }

    .selected-image-item {
        padding: 2px; /* Thinner border on mobile */
        max-width: 100%;
    }

    .btn-remove-image {
        width: 24px;
        height: 24px;
        top: 6px;
        right: 6px;
    }

    .face-indicator {
        padding: 2px 8px;
        font-size: 0.75rem;
        bottom: 6px;
        left: 6px;
    }
}

/* Very small screens */
@media (max-width: 359px) {
    .face-indicator {
        padding: 2px 6px;
        font-size: 0.7rem;
    }
}

/* Optimizations for landscape orientation on mobile */
@media (max-height: 500px) and (orientation: landscape) {
    .selected-image-display {
        min-height: 200px;
        padding: 5px;
    }

    .selected-image-item {
        padding: 2px;
        max-height: 70vh;
    }

    .btn-remove-image {
        width: 24px;
        height: 24px;
    }

    .face-indicator {
        padding: 2px 6px;
        font-size: 0.7rem;
    }
}

/* Tablet and desktop - larger display */
@media (min-width: 768px) {
    .selected-image-display {
        padding: 30px;
        min-height: 500px;
    }

    .selected-image-item {
        max-width: 600px;
    }
}

/* Large desktop - even larger display */
@media (min-width: 1200px) {
    .selected-image-display {
        padding: 40px;
        min-height: 600px;
    }

    .selected-image-item {
        max-width: 800px;
    }
}
