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

/* Overlay */
.coloring-lightbox {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(10px);
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-normal);
}

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

/* Content Container */
.lightbox-container {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    transform: scale(0.9);
    transition: transform var(--transition-normal);
    /* Ensure dropdowns can be seen even if they extend outside */
    overflow: visible; 
}

.coloring-lightbox.active .lightbox-container {
    transform: scale(1);
}

/* Close Button */
.lightbox-close {
    position: absolute;
    top: -50px;
    right: 0;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: white;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: all var(--transition-normal);
}

.lightbox-close:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: rotate(90deg);
}

/* Image */
.lightbox-image {
    max-width: 100%;
    max-height: 70vh;
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    object-fit: contain;
}

/* Caption & Info */
.lightbox-info {
    margin-top: var(--space-lg);
    text-align: center;
    width: 100%;
}

.lightbox-title {
    font-size: 1.25rem;
    font-weight: 500;
    color: white;
    margin: 0 0 var(--space-md);
}

/* Lightbox Action Buttons - Container */
.lightbox-buttons {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    position: relative;
    z-index: 10;
}

/* 
 * ==========================================================================
 * SHARED BUTTON STYLES (Copied from single.css to ensure 1:1 match)
 * ==========================================================================
 */

.lightbox-buttons .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 18px; /* Slightly larger padding for lightbox context */
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    white-space: nowrap;
    color: white;
}

.lightbox-buttons .btn .btn-icon {
    font-size: 1.1em;
    line-height: 1;
}

/* Color Button - Primary Gradient (Purple) */
/* Override plugin CSS with !important just like single.css */
.lightbox-buttons .btn-color.coloring-popup-trigger,
.lightbox-buttons .coloring-popup-trigger, 
.lightbox-buttons .btn-color {
    /* Reset plugin styles */
    opacity: 1 !important;
    visibility: visible !important;
    position: static !important;
    pointer-events: auto !important;
    
    /* Layout stats */
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: auto !important;
    height: auto !important;
    min-width: 0 !important;
    min-height: 0 !important;
    max-width: none !important;
    
    /* Styling */
    padding: 10px 18px !important;
    font-size: 0.85rem !important;
    font-weight: 600 !important;
    border-radius: 8px !important;
    border: none !important;
    color: white !important;
    
    /* Gradient */
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
    background-image: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
    
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4) !important;
    transform: none !important;
    clip: auto !important;
    clip-path: none !important;
}

.lightbox-buttons .btn-color:hover,
.lightbox-buttons .coloring-popup-trigger:hover {
    background: linear-gradient(135deg, #5a6fd6 0%, #6a4190 100%) !important;
    transform: translateY(-2px) !important;
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.5) !important;
}

/* Download Button - Green Gradient */
.lightbox-buttons .btn-download {
     width: 100%;
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(17, 153, 142, 0.4);
    position: relative;
    /* Force same styling as Color button */
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 6px !important;
    padding: 10px 12px !important;
    font-size: 0.75rem !important;
    font-weight: 600 !important;
    border-radius: 8px !important;
    border: none !important;
}

.lightbox-buttons .btn-download:hover {
    background: linear-gradient(135deg, #0e8a7f 0%, #32d970 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(17, 153, 142, 0.5);
}

/* Fallback buttons if needed */
.lightbox-buttons .btn-pdf {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    box-shadow: 0 4px 15px rgba(245, 87, 108, 0.3);
}
.lightbox-buttons .btn-image {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    box-shadow: 0 4px 15px rgba(79, 172, 254, 0.3);
}

/* 
 * ==========================================================================
 * Dropdown Styles for Lightbox
 * ==========================================================================
 */
.lightbox-buttons .download-dropdown {
    position: relative;
    /* Ensure no weirdness from plugins */
    display: inline-block;
}

.lightbox-buttons .dropdown-menu {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(10px);
    margin-bottom: 12px;
    min-width: 180px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s cubic-bezier(0.165, 0.84, 0.44, 1);
    z-index: 10000;
    padding: 6px;
    display: block; /* Ensure it's not hidden by flex parent quirks */
}

.lightbox-buttons .download-dropdown.open .dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

/* Dropdown arrow connector */
.lightbox-buttons .dropdown-menu::after {
    content: '';
    position: absolute;
    bottom: -6px;
    left: 50%;
    transform: translateX(-50%) rotate(45deg);
    width: 12px;
    height: 12px;
    background: white;
    z-index: -1;
}

/* Dropdown items */
.lightbox-buttons .dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 14px;
    font-size: 0.9rem;
    font-weight: 600;
    color: #444; 
    background: transparent;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
    text-decoration: none;
    position: relative;
    overflow: hidden;
}

.lightbox-buttons .dropdown-item:not(:last-child) {
    border-bottom: 1px solid #f0f0f0;
}

/* Item Hover Effect */
.lightbox-buttons .dropdown-item:hover {
    color: #11998e;
    background: #f8f9fa; /* Simple fallback if gradient doesn't show */
    padding-left: 18px;
}

/* Icons in Dropdown - reuse gradient logic but simplify */
.lightbox-buttons .dropdown-item .format-icon {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    font-size: 1em;
    flex-shrink: 0;
}

.lightbox-buttons .dropdown-item[data-format="pdf"] .format-icon {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a5a 100%);
    color: white;
}
.lightbox-buttons .dropdown-item[data-format="png"] .format-icon {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}
.lightbox-buttons .dropdown-item[data-format="jpg"] .format-icon {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
}
.lightbox-buttons .dropdown-item[data-format="webp"] .format-icon {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    color: white;
}

/* Navigation Arrows */
.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: white;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: all var(--transition-normal);
    z-index: 20;
}

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

.lightbox-prev {
    left: -80px;
}

.lightbox-next {
    right: -80px;
}

/* Hide nav on mobile */
@media (max-width: 768px) {
    .lightbox-nav {
        display: none;
    }
    
    .lightbox-container {
        max-width: 95vw;
    }
    
    .lightbox-close {
        top: -40px;
        right: 0;
    }
    
    .lightbox-buttons .btn {
        padding: 10px 14px;
        font-size: 0.8rem;
    }
}

/* Loading State */
.lightbox-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.2);
    border-top-color: white;
    border-radius: 50%;
    animation: lightbox-spin 0.8s linear infinite;
    z-index: 5;
}

@keyframes lightbox-spin {
    to {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}

/* Prevent body scroll when lightbox is open */
body.lightbox-open {
    overflow: hidden;
}
