/**
 * Featured Image Manager Pro - Frontend Styles
 * 
 * @package Featured_Image_Manager_Pro
 */

/* ============================================
   CSS Variables (defaults, overridden by PHP)
   ============================================ */
:root {
    --fim-border-width: 0px;
    --fim-border-radius: 12px;
    --fim-border-color: #e5e7eb;
    --fim-shadow: 0 4px 20px rgba(0,0,0,0.12);
    --fim-animation-duration: 0.6s;
    --fim-featured-width: 1200px;
    --fim-featured-height: 675px;
    --fim-content-width: 800px;
    --fim-content-height: 600px;
    --fim-thumbnail-width: 400px;
    --fim-thumbnail-height: 300px;
}

/* ============================================
   Base Image Wrapper Styles
   ============================================ */
.fim-image-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 1.5rem auto;
    max-width: 100%;
}

.fim-featured-wrapper {
    max-width: var(--fim-featured-width);
}

.fim-content-wrapper {
    max-width: var(--fim-content-width);
}

.fim-single-image-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 2rem auto;
}

/* ============================================
   Base Image Styles
   ============================================ */
.fim-image {
    display: block;
    max-width: 100%;
    height: auto;
    border-width: var(--fim-border-width);
    border-style: solid;
    border-color: var(--fim-border-color);
    border-radius: var(--fim-border-radius);
    box-shadow: var(--fim-shadow);
    transition: all var(--fim-animation-duration) cubic-bezier(0.4, 0, 0.2, 1);
    will-change: transform, opacity, filter;
}

.fim-featured-image {
    width: 100%;
    max-width: var(--fim-featured-width);
    object-fit: cover;
}

.fim-content-image {
    max-width: var(--fim-content-width);
}

/* ============================================
   Border Style Variations
   ============================================ */

/* Modern Style */
.fim-border-modern {
    border-width: 0;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1), 0 1px 3px rgba(0, 0, 0, 0.08);
}

/* Classic Style */
.fim-border-classic {
    border-width: 3px;
    border-radius: 0;
    border-color: #333;
    box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.2);
}

/* Minimal Style */
.fim-border-minimal {
    border-width: 0;
    border-radius: 4px;
    box-shadow: none;
}

/* Bold Style */
.fim-border-bold {
    border-width: 5px;
    border-radius: 8px;
    border-color: #1a1a1a;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);
}

/* Polaroid Style */
.fim-border-polaroid {
    border-width: 0;
    border-radius: 4px;
    padding: 12px 12px 40px 12px;
    background: #fff;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15), 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Rounded Style */
.fim-border-rounded {
    border-width: 0;
    border-radius: 24px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
    overflow: hidden;
}

/* ============================================
   Animation Keyframes
   ============================================ */

/* Fade In */
@keyframes fim-fade-in {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Slide Up */
@keyframes fim-slide-up {
    from {
        opacity: 0;
        transform: translateY(40px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Zoom In */
@keyframes fim-zoom-in {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Rotate In */
@keyframes fim-rotate-in {
    from {
        opacity: 0;
        transform: rotate(-10deg) scale(0.9);
    }
    to {
        opacity: 1;
        transform: rotate(0) scale(1);
    }
}

/* Blur to Focus */
@keyframes fim-blur-focus {
    from {
        opacity: 0;
        filter: blur(20px);
    }
    to {
        opacity: 1;
        filter: blur(0);
    }
}

/* Elastic Bounce */
@keyframes fim-elastic {
    0% {
        opacity: 0;
        transform: scale(0.5);
    }
    50% {
        transform: scale(1.05);
    }
    70% {
        transform: scale(0.95);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

/* ============================================
   Animation Classes (Initial State)
   ============================================ */
.fim-animate {
    opacity: 0;
}

.fim-animate.fim-animated {
    opacity: 1;
}

/* Animation Type Classes */
.fim-animation-fade-in.fim-animated {
    animation: fim-fade-in var(--fim-animation-duration) ease-out forwards;
}

.fim-animation-slide-up.fim-animated {
    animation: fim-slide-up var(--fim-animation-duration) ease-out forwards;
}

.fim-animation-zoom-in.fim-animated {
    animation: fim-zoom-in var(--fim-animation-duration) ease-out forwards;
}

.fim-animation-rotate-in.fim-animated {
    animation: fim-rotate-in var(--fim-animation-duration) ease-out forwards;
}

.fim-animation-blur-focus.fim-animated {
    animation: fim-blur-focus var(--fim-animation-duration) ease-out forwards;
}

.fim-animation-elastic.fim-animated {
    animation: fim-elastic calc(var(--fim-animation-duration) * 1.5) cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards;
}

/* ============================================
   Hover Effects
   ============================================ */

/* Lift Effect */
.fim-hover-lift:hover {
    transform: translateY(-8px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
}

/* Grow Effect */
.fim-hover-grow:hover {
    transform: scale(1.05);
}

/* Glow Effect */
.fim-hover-glow:hover {
    box-shadow: 0 0 30px rgba(59, 130, 246, 0.5), 0 0 60px rgba(59, 130, 246, 0.3);
}

/* Tilt Effect */
.fim-hover-tilt:hover {
    transform: perspective(1000px) rotateX(5deg) rotateY(-5deg);
}

/* Shine Effect */
.fim-hover-shine {
    position: relative;
    overflow: hidden;
}

.fim-hover-shine::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.4),
        transparent
    );
    transition: left 0.6s ease;
    pointer-events: none;
    z-index: 10;
}

.fim-hover-shine:hover::before {
    left: 100%;
}

/* ============================================
   Gallery Styles
   ============================================ */
.fim-gallery {
    display: grid;
    gap: 24px;
    margin: 2rem auto;
    max-width: 1400px;
    padding: 0 1rem;
}

.fim-columns-1 {
    grid-template-columns: 1fr;
}

.fim-columns-2 {
    grid-template-columns: repeat(2, 1fr);
}

.fim-columns-3 {
    grid-template-columns: repeat(3, 1fr);
}

.fim-columns-4 {
    grid-template-columns: repeat(4, 1fr);
}

.fim-columns-5 {
    grid-template-columns: repeat(5, 1fr);
}

.fim-columns-6 {
    grid-template-columns: repeat(6, 1fr);
}

/* Gallery Item */
.fim-gallery-item {
    position: relative;
    overflow: hidden;
}

.fim-gallery-link {
    display: block;
    text-decoration: none;
    color: inherit;
}

.fim-gallery-item .fim-image-wrapper {
    margin: 0;
    overflow: hidden;
    border-radius: var(--fim-border-radius);
}

.fim-gallery-item .fim-image {
    width: 100%;
    aspect-ratio: 4/3;
    object-fit: cover;
    margin: 0;
}

/* Gallery Caption */
.fim-gallery-caption {
    padding: 1rem 0.5rem;
    text-align: center;
}

.fim-gallery-caption h4 {
    margin: 0 0 0.25rem 0;
    font-size: 1rem;
    font-weight: 600;
    color: #1a1a1a;
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.fim-gallery-caption .fim-post-type {
    font-size: 0.75rem;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Image Caption */
.fim-image-caption {
    padding: 0.75rem;
    text-align: center;
    font-size: 0.875rem;
    color: #666;
    font-style: italic;
}

/* No Images Message */
.fim-no-images {
    text-align: center;
    padding: 3rem;
    color: #666;
    font-size: 1rem;
    background: #f9fafb;
    border-radius: 8px;
    margin: 2rem auto;
    max-width: 600px;
}

/* ============================================
   Lightbox Styles
   ============================================ */
.fim-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 999999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.fim-lightbox.active {
    opacity: 1;
    visibility: visible;
}

.fim-lightbox-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    animation: fim-zoom-in 0.3s ease forwards;
}

.fim-lightbox-content img {
    max-width: 100%;
    max-height: 90vh;
    object-fit: contain;
    border-radius: 4px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.fim-lightbox-close {
    position: absolute;
    top: -40px;
    right: 0;
    width: 36px;
    height: 36px;
    background: transparent;
    border: 2px solid rgba(255, 255, 255, 0.5);
    border-radius: 50%;
    color: #fff;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.2s ease;
    line-height: 1;
}

.fim-lightbox-close:hover {
    background: #fff;
    color: #000;
    border-color: #fff;
}

.fim-lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 50px;
    height: 50px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 50%;
    color: #fff;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.2s ease;
}

.fim-lightbox-nav:hover {
    background: rgba(255, 255, 255, 0.2);
}

.fim-lightbox-prev {
    left: 20px;
}

.fim-lightbox-next {
    right: 20px;
}

.fim-lightbox-caption {
    position: absolute;
    bottom: -50px;
    left: 0;
    right: 0;
    text-align: center;
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.875rem;
}

/* ============================================
   Responsive Styles
   ============================================ */
@media (max-width: 1200px) {
    .fim-columns-6 {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .fim-columns-5 {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (max-width: 992px) {
    .fim-columns-6,
    .fim-columns-5,
    .fim-columns-4 {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    .fim-gallery {
        gap: 16px;
    }
    
    .fim-columns-6,
    .fim-columns-5,
    .fim-columns-4,
    .fim-columns-3 {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .fim-gallery-caption h4 {
        font-size: 0.875rem;
    }
    
    .fim-lightbox-nav {
        width: 40px;
        height: 40px;
        font-size: 20px;
    }
    
    .fim-lightbox-prev {
        left: 10px;
    }
    
    .fim-lightbox-next {
        right: 10px;
    }
}

@media (max-width: 480px) {
    .fim-columns-6,
    .fim-columns-5,
    .fim-columns-4,
    .fim-columns-3,
    .fim-columns-2 {
        grid-template-columns: 1fr;
    }
    
    .fim-gallery {
        gap: 20px;
    }
}

/* ============================================
   Print Styles
   ============================================ */
@media print {
    .fim-image {
        box-shadow: none !important;
        border: 1px solid #ddd !important;
    }
    
    .fim-lightbox {
        display: none !important;
    }
    
    .fim-animate {
        opacity: 1 !important;
        animation: none !important;
    }
}

/* ============================================
   Accessibility
   ============================================ */
@media (prefers-reduced-motion: reduce) {
    .fim-image,
    .fim-animate,
    .fim-lightbox,
    .fim-lightbox-content {
        animation: none !important;
        transition: none !important;
    }
    
    .fim-animate {
        opacity: 1 !important;
    }
}

/* Focus States */
.fim-gallery-link:focus,
.fim-lightbox-close:focus,
.fim-lightbox-nav:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

.fim-gallery-link:focus-visible {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}
