/* Instagram Feed Frontend - Modern Design */

.fi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    list-style: none;
    padding: 0;
    margin: 0;
    max-width: 1200px;
    margin: 0 auto;
}

.fi-grid-item {
    position: relative;
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 8px 25px rgba(0,0,0,0.1);
    transition: all 0.3s ease;
    background: white;
    aspect-ratio: 1;
}

.fi-grid-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 35px rgba(0,0,0,0.15);
}

.fi-grid-item a {
    display: block;
    width: 100%;
    height: 100%;
    text-decoration: none;
    position: relative;
    overflow: hidden;
}

.fi-grid-item img.overlay {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.fi-grid-item:hover img.overlay {
    transform: scale(1.05);
}

.fi-grid-item video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    background: #000;
}

/* Video controls styling */
.fi-grid-item video::-webkit-media-controls {
    background: rgba(0,0,0,0.5);
}

.fi-grid-item video::-webkit-media-controls-panel {
    background: rgba(0,0,0,0.7);
}

/* Loading state */
.fi-grid.loading {
    opacity: 0.7;
    pointer-events: none;
}

.fi-grid.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin: -20px 0 0 -20px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Instagram-like overlay */
.fi-grid-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        45deg,
        rgba(255,255,255,0.1) 0%,
        rgba(255,255,255,0) 50%,
        rgba(0,0,0,0.1) 100%
    );
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 1;
    pointer-events: none;
}

.fi-grid-item:hover::before {
    opacity: 1;
}

/* Instagram icon overlay */
.fi-grid-item::after {
    content: '📸';
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(0,0,0,0.7);
    color: white;
    padding: 8px;
    border-radius: 50%;
    font-size: 16px;
    opacity: 0;
    transform: scale(0.8);
    transition: all 0.3s ease;
    z-index: 2;
    pointer-events: none;
}

.fi-grid-item:hover::after {
    opacity: 1;
    transform: scale(1);
}

/* Responsive design */
@media (max-width: 768px) {
    .fi-grid {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
        gap: 15px;
        padding: 0 15px;
    }
    
    .fi-grid-item {
        border-radius: 12px;
    }
}

@media (max-width: 480px) {
    .fi-grid {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
        gap: 10px;
    }
    
    .fi-grid-item::after {
        top: 10px;
        right: 10px;
        padding: 6px;
        font-size: 14px;
    }
}

/* Masonry layout option */
.fi-grid.masonry {
    columns: 3;
    column-gap: 20px;
}

.fi-grid.masonry .fi-grid-item {
    break-inside: avoid;
    margin-bottom: 20px;
    display: block;
}

@media (max-width: 768px) {
    .fi-grid.masonry {
        columns: 2;
        column-gap: 15px;
    }
}

@media (max-width: 480px) {
    .fi-grid.masonry {
        columns: 1;
    }
}

/* Lightbox effect */
.fi-grid-item.lightbox {
    cursor: pointer;
}

.fi-grid-item.lightbox:hover {
    transform: scale(1.02);
}

/* Loading animation */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Fade in animation */
.fi-grid-item {
    animation: fadeInUp 0.6s ease forwards;
    opacity: 0;
    transform: translateY(20px);
}

.fi-grid-item:nth-child(1) { animation-delay: 0.1s; }
.fi-grid-item:nth-child(2) { animation-delay: 0.2s; }
.fi-grid-item:nth-child(3) { animation-delay: 0.3s; }
.fi-grid-item:nth-child(4) { animation-delay: 0.4s; }
.fi-grid-item:nth-child(5) { animation-delay: 0.5s; }
.fi-grid-item:nth-child(6) { animation-delay: 0.6s; }

@keyframes fadeInUp {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Error state */
.fi-grid.error {
    text-align: center;
    padding: 40px 20px;
    color: #666;
}

.fi-grid.error::before {
    content: '❌';
    font-size: 48px;
    display: block;
    margin-bottom: 20px;
}

/* Empty state */
.fi-grid.empty {
    text-align: center;
    padding: 60px 20px;
    color: #999;
}

.fi-grid.empty::before {
    content: '📸';
    font-size: 64px;
    display: block;
    margin-bottom: 20px;
    opacity: 0.5;
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .fi-grid-item {
        background: #2d2d2d;
        box-shadow: 0 8px 25px rgba(0,0,0,0.3);
    }
    
    .fi-grid-item:hover {
        box-shadow: 0 15px 35px rgba(0,0,0,0.4);
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    .fi-grid-item {
        border: 2px solid #000;
    }
    
    .fi-grid-item:hover {
        border-color: #667eea;
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .fi-grid-item,
    .fi-grid-item img.overlay,
    .fi-grid-item::before,
    .fi-grid-item::after {
        transition: none;
    }
    
    .fi-grid-item:hover {
        transform: none;
    }
    
    .fi-grid-item:hover img.overlay {
        transform: none;
    }
}