/* ========================================
   Enhanced Features CSS
   ======================================== */

/* Page Progress Bar */
#page-progress-bar {
    background: linear-gradient(90deg, #005df8, #0045c7);
    height: 3px;
    left: 0;
    position: fixed;
    top: 0;
    transition: width 0.3s ease, opacity 0.3s ease;
    width: 0%;
    z-index: 9999;
}

/* ========================================
   Lazy Loading Images
   ======================================== */

/* Base styles for all images - prevent layout shift */
img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* Lazy loading placeholder state */
img.lazyload {
    opacity: 0;
    transition: opacity 0.4s ease-in-out;
    background-color: #f0f0f0;
    background-image: linear-gradient(90deg, #f0f0f0 0%, #e0e0e0 50%, #f0f0f0 100%);
    background-size: 200% 100%;
    animation: lazy-loading-placeholder 1.5s ease-in-out infinite;
}

/* Fade-in effect when image loads */
img.lazyloaded,
img.fade-in {
    opacity: 1;
    animation: none;
    background: none;
}

/* Smooth fade-in animation */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

img.fade-in {
    animation: fadeIn 0.5s ease-in-out;
}

/* Placeholder animation for lazy loading */
@keyframes lazy-loading-placeholder {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* Error state for failed image loads */
img.lazyload-error {
    opacity: 0.5;
    background-color: #f8f8f8;
    border: 1px dashed #ddd;
}

/* Ensure images maintain aspect ratio to prevent layout shift */
/* Images with width/height attributes will maintain aspect ratio naturally */
/* The browser will use these attributes to reserve space and prevent CLS */
img[width][height] {
    max-width: 100%;
    height: auto;
}

/* Carousel and above-fold images should load immediately */
.carousel-item img,
.carousel-inner img,
#slider img,
.hero img,
header img,
.above-fold img,
img[data-no-lazy] {
    opacity: 1 !important;
    animation: none !important;
    background: none !important;
}

/* Bootstrap compatibility - ensure img-fluid works with lazy loading */
img.img-fluid.lazyload {
    width: 100%;
    height: auto;
}

/* Scroll Animations */
.animate-on-scroll {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.animate-on-scroll.animated {
    opacity: 1;
    transform: translateY(0);
}


/* Cookie Consent Banner */
#cookie-consent {
    background: #162341;
    bottom: 0;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    color: #ffffff;
    left: 0;
    opacity: 0;
    padding: 20px;
    position: fixed;
    transform: translateY(100%);
    transition: all 0.3s ease;
    width: 100%;
    z-index: 10000;
}

#cookie-consent.visible {
    opacity: 1;
    transform: translateY(0);
}

#cookie-consent .container {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    justify-content: space-between;
}

#cookie-consent p {
    flex: 1;
    margin: 0;
    min-width: 250px;
    color: #ffffff;
}

#cookie-consent .cookie-buttons {
    display: flex;
    gap: 10px;
}

#cookie-consent button {
    background: #005df8;
    border: none;
    border-radius: 4px;
    color: #ffffff;
    cursor: pointer;
    padding: 10px 20px;
}

#cookie-consent #cookie-decline {
    background: transparent;
    border: 1px solid #ffffff;
}

#cookie-consent #cookie-decline:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Social Sharing Buttons */
.social-share {
    display: flex;
    gap: 10px;
    margin: 20px 0;
}

.social-share-btn {
    align-items: center;
    background: #f5f5f5;
    border: none;
    border-radius: 50%;
    color: #333;
    cursor: pointer;
    display: flex;
    height: 40px;
    justify-content: center;
    transition: all 0.3s ease;
    width: 40px;
}

.social-share-btn:hover {
    background: #005df8;
    color: #ffffff;
    transform: translateY(-2px);
}

/* Header Search Button */
.search-toggle {
    align-items: center;
    color: #333;
    display: flex;
    font-size: 18px;
    height: 40px;
    justify-content: center;
    margin-left: 15px;
    text-decoration: none;
    width: 40px;
}

.search-toggle:hover {
    color: #005df8;
}

/* Site Search */
#search-box {
    background: rgba(255, 255, 255, 0.98);
    display: none;
    height: 100vh;
    left: 0;
    padding: 100px 20px 20px;
    position: fixed;
    top: 0;
    width: 100%;
    z-index: 10003;
}

#search-box.visible {
    display: block;
}

#search-input {
    border: 2px solid #005df8;
    border-radius: 4px;
    font-size: 24px;
    max-width: 800px;
    margin: 0 auto;
    padding: 15px 20px;
    width: 100%;
}

#search-results {
    max-width: 800px;
    margin: 30px auto 0;
}

#search-close {
    background: none;
    border: none;
    color: #333;
    cursor: pointer;
    font-size: 32px;
    position: absolute;
    right: 30px;
    top: 30px;
}

/* Breadcrumb Navigation */
.breadcrumb {
    background: transparent;
    display: flex;
    flex-wrap: wrap;
    list-style: none;
    margin: 0;
    padding: 15px 0;
}

.breadcrumb-item {
    display: flex;
}

.breadcrumb-item + .breadcrumb-item::before {
    color: #6c757d;
    content: "/";
    padding: 0 10px;
}

.breadcrumb-item a {
    color: #005df8;
    text-decoration: none;
}

.breadcrumb-item.active {
    color: #6c757d;
}

/* Reading Progress Indicator */
#reading-progress {
    background: #005df8;
    height: 3px;
    left: 0;
    position: fixed;
    top: 0;
    transition: width 0.1s ease;
    width: 0%;
    z-index: 9998;
}



/* Lightbox */
#lightbox {
    align-items: center;
    background: rgba(0, 0, 0, 0.95);
    display: none;
    height: 100vh;
    justify-content: center;
    left: 0;
    position: fixed;
    top: 0;
    width: 100%;
    z-index: 10004;
}

#lightbox.visible {
    display: flex;
}

#lightbox-img {
    max-height: 90vh;
    max-width: 90vw;
    object-fit: contain;
}

#lightbox-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 50%;
    color: #ffffff;
    cursor: pointer;
    font-size: 32px;
    height: 50px;
    position: absolute;
    right: 30px;
    top: 30px;
    transition: all 0.3s ease;
    width: 50px;
}

#lightbox-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

.lightbox-trigger {
    cursor: pointer;
    transition: transform 0.3s ease;
}

.lightbox-trigger:hover {
    transform: scale(1.05);
}

/* Enhanced Form Validation */
.form-control.is-invalid {
    border-color: #dc3545;
}

.form-control.is-valid {
    border-color: #28a745;
}

.invalid-feedback {
    color: #dc3545;
    display: block;
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

/* Loading Skeleton */
.skeleton {
    animation: skeleton-loading 1.5s ease-in-out infinite;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    border-radius: 4px;
}

@keyframes skeleton-loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

.skeleton-text {
    height: 1rem;
    margin-bottom: 0.5rem;
}

.skeleton-title {
    height: 2rem;
    margin-bottom: 1rem;
    width: 60%;
}

.skeleton-image {
    aspect-ratio: 16 / 9;
    height: auto;
    width: 100%;
}

/* Print Styles */
@media print {
    .no-print,
    header,
    footer,
    .top-menu,
    .go-to-top,
    #dark-mode-toggle,
    .social-share,
    #cookie-consent {
        display: none !important;
    }

    body {
        background: #fff !important;
        color: #000 !important;
    }

    a {
        color: #000 !important;
        text-decoration: underline !important;
    }

    img {
        max-width: 100% !important;
        page-break-inside: avoid !important;
    }
}

/* Responsive Adjustments */
@media (max-width: 768px) {
    #cookie-consent .container {
        flex-direction: column;
        text-align: center;
    }



    #search-input {
        font-size: 18px;
        padding: 12px 15px;
    }
}

