/**
 * GPY Embed - Front-end Styles
 *
 * Responsive embed container styles.
 *
 * @package GPY_Embed
 * @since 1.0.0
 */

/* Container - holds max-width and centering */
.gpy-embed-container {
    position: relative;
    margin: 1em auto;
    width: 100%;
}

/* Wrapper - creates responsive aspect ratio using padding-bottom */
.gpy-embed-wrapper {
    position: relative;
    width: 100%;
    height: 0;
    overflow: hidden;
    background-color: #000;
}

/* Iframe - fills the wrapper */
.gpy-embed-wrapper iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

/* ================================
   Google Photos Gallery Styles
   ================================ */

.gpy-embed-google-photos-gallery {
    max-width: 100%;
}

.gpy-embed-gallery-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding: 0 4px;
}

.gpy-embed-gallery-count {
    font-size: 14px;
    color: #5f6368;
    font-weight: 500;
}

.gpy-embed-gallery-link {
    font-size: 14px;
    color: #4285F4;
    text-decoration: none;
    font-weight: 500;
}

.gpy-embed-gallery-link:hover {
    text-decoration: underline;
}

.gpy-embed-gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 8px;
}

.gpy-embed-gallery-item {
    position: relative;
    display: block;
    aspect-ratio: 4 / 3;
    overflow: hidden;
    border-radius: 8px;
    background: #f1f3f4;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    cursor: pointer;
}

.gpy-embed-gallery-item:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1;
}

.gpy-embed-gallery-item:focus {
    outline: 3px solid #4285F4;
    outline-offset: 2px;
    transform: scale(1.02);
}

.gpy-embed-gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: opacity 0.3s ease;
}

.gpy-embed-gallery-item img[loading="lazy"] {
    opacity: 0;
}

.gpy-embed-gallery-item img.loaded,
.gpy-embed-gallery-item img:not([loading="lazy"]) {
    opacity: 1;
}

/* ================================
   Lightbox Styles
   ================================ */

.gpy-embed-lightbox {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 999999;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.gpy-embed-lightbox.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.gpy-embed-lightbox.visible {
    opacity: 1;
}

.gpy-embed-lightbox-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    cursor: pointer;
}

.gpy-embed-lightbox-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
}

.gpy-embed-lightbox-image {
    max-width: 90vw;
    max-height: 85vh;
    object-fit: contain;
    border-radius: 4px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.gpy-embed-lightbox-image.loaded {
    opacity: 1;
}

.gpy-embed-lightbox-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: #fff;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    transition: background 0.2s ease, transform 0.2s ease;
}

.gpy-embed-lightbox-close:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

.gpy-embed-lightbox-close:focus {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

.gpy-embed-lightbox-prev,
.gpy-embed-lightbox-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: #fff;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    transition: background 0.2s ease, transform 0.2s ease;
}

.gpy-embed-lightbox-prev {
    left: 16px;
}

.gpy-embed-lightbox-next {
    right: 16px;
}

.gpy-embed-lightbox-prev:hover,
.gpy-embed-lightbox-next:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: translateY(-50%) scale(1.1);
}

.gpy-embed-lightbox-prev:focus,
.gpy-embed-lightbox-next:focus {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

.gpy-embed-lightbox-counter {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255, 255, 255, 0.8);
    font-size: 14px;
    font-weight: 500;
    background: rgba(0, 0, 0, 0.5);
    padding: 8px 16px;
    border-radius: 20px;
    z-index: 10;
}

/* Mobile adjustments for lightbox */
@media (max-width: 768px) {
    .gpy-embed-lightbox-prev,
    .gpy-embed-lightbox-next {
        width: 44px;
        height: 44px;
    }
    
    .gpy-embed-lightbox-prev {
        left: 8px;
    }
    
    .gpy-embed-lightbox-next {
        right: 8px;
    }
    
    .gpy-embed-lightbox-close {
        top: 8px;
        right: 8px;
        width: 40px;
        height: 40px;
    }
    
    .gpy-embed-lightbox-image {
        max-width: 95vw;
        max-height: 80vh;
    }
}

/* Hide navigation buttons when only one photo */
.gpy-embed-lightbox.single-photo .gpy-embed-lightbox-prev,
.gpy-embed-lightbox.single-photo .gpy-embed-lightbox-next,
.gpy-embed-lightbox.single-photo .gpy-embed-lightbox-counter {
    display: none;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .gpy-embed-gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 6px;
    }
    
    .gpy-embed-gallery-item {
        border-radius: 6px;
    }
}

@media (max-width: 480px) {
    .gpy-embed-gallery-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 4px;
    }
    
    .gpy-embed-gallery-item {
        border-radius: 4px;
    }
    
    .gpy-embed-gallery-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
}

/* ================================
   Google Photos Card Styles (Fallback)
   ================================ */

.gpy-embed-gp-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px 24px;
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    text-decoration: none;
    color: inherit;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.gpy-embed-gp-card:hover,
.gpy-embed-gp-card:focus {
    border-color: #4285F4;
    box-shadow: 0 4px 16px rgba(66, 133, 244, 0.2);
    transform: translateY(-2px);
    text-decoration: none;
}

.gpy-embed-gp-card:focus {
    outline: 2px solid #4285F4;
    outline-offset: 2px;
}

.gpy-embed-gp-icon {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 64px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.gpy-embed-gp-icon svg {
    width: 40px;
    height: 40px;
}

.gpy-embed-gp-content {
    flex: 1;
    min-width: 0;
}

.gpy-embed-gp-title {
    display: block;
    font-size: 18px;
    font-weight: 600;
    color: #202124;
    margin-bottom: 4px;
}

.gpy-embed-gp-subtitle {
    display: block;
    font-size: 14px;
    color: #5f6368;
}

.gpy-embed-gp-arrow {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: #f1f3f4;
    border-radius: 50%;
    color: #5f6368;
    transition: all 0.2s ease;
}

.gpy-embed-gp-card:hover .gpy-embed-gp-arrow {
    background: #4285F4;
    color: #fff;
}

/* Responsive adjustments for Google Photos card */
@media (max-width: 480px) {
    .gpy-embed-gp-card {
        padding: 16px;
        gap: 12px;
    }
    
    .gpy-embed-gp-icon {
        width: 48px;
        height: 48px;
    }
    
    .gpy-embed-gp-icon svg {
        width: 32px;
        height: 32px;
    }
    
    .gpy-embed-gp-title {
        font-size: 16px;
    }
    
    .gpy-embed-gp-subtitle {
        font-size: 13px;
    }
    
    .gpy-embed-gp-arrow {
        width: 32px;
        height: 32px;
    }
}

/* ================================
   Error & Fallback Styles
   ================================ */

.gpy-embed-fallback {
    display: none;
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.8);
    color: #fff;
    padding: 15px;
    text-align: center;
    font-size: 14px;
}

.gpy-embed-fallback p {
    margin: 0 0 10px;
}

.gpy-embed-fallback a {
    color: #4db6ff;
    text-decoration: underline;
}

.gpy-embed-fallback a:hover,
.gpy-embed-fallback a:focus {
    color: #80caff;
}

/* Error message styling */
.gpy-embed-error {
    background-color: #fff3cd;
    border: 1px solid #ffc107;
    color: #856404;
    padding: 15px;
    border-radius: 4px;
    text-align: center;
    margin: 1em auto;
    max-width: 600px;
}

.gpy-embed-error p {
    margin: 0;
}

/* YouTube-specific styling */
.gpy-embed-youtube .gpy-embed-wrapper {
    background-color: #000;
}

/* Alignment support */
.alignwide .gpy-embed-container,
.alignfull .gpy-embed-container {
    max-width: none;
}

.aligncenter .gpy-embed-container {
    margin-left: auto;
    margin-right: auto;
}

/* Focus styles for accessibility */
.gpy-embed-wrapper iframe:focus {
    outline: 2px solid #007bff;
    outline-offset: 2px;
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .gpy-embed-container,
    .gpy-embed-wrapper,
    .gpy-embed-wrapper iframe,
    .gpy-embed-gp-card,
    .gpy-embed-gp-arrow {
        transition: none;
    }
    
    .gpy-embed-gp-card:hover {
        transform: none;
    }
}

/* Print styles - show link instead of embed */
@media print {
    .gpy-embed-wrapper iframe {
        display: none;
    }
    
    .gpy-embed-fallback {
        display: block !important;
        position: static;
        background: transparent;
        color: #000;
        padding: 10px 0;
    }
    
    .gpy-embed-fallback a {
        color: #000;
    }
    
    .gpy-embed-gp-card {
        box-shadow: none;
        border: 1px solid #000;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .gpy-embed-gp-card {
        background: linear-gradient(135deg, #2d2d2d 0%, #1f1f1f 100%);
        border-color: #404040;
    }
    
    .gpy-embed-gp-icon {
        background: #3d3d3d;
    }
    
    .gpy-embed-gp-title {
        color: #e8eaed;
    }
    
    .gpy-embed-gp-subtitle {
        color: #9aa0a6;
    }
    
    .gpy-embed-gp-arrow {
        background: #3d3d3d;
        color: #9aa0a6;
    }
}
