/**
 * Daily Darshan Gallery - Front-end Styles (Final Complete Updated)
 */

/* ------------------- Variables ------------------- */
:root {
    --dd-primary-color: #3f51b5; /* A vibrant blue for accents */
    --dd-border-color: #ddd;
    --dd-background-color: #f9f9f9;
    --dd-spacing: 1.25rem;
    --dd-max-width: 900px;
    --dd-shadow-md: 0 4px 12px rgba(0,0,0,0.1);
    --dd-shadow-lg: 0 6px 16px rgba(0,0,0,0.15);
}

/* ------------------- Global ------------------- */
body.dd-lightbox-open {
    overflow: hidden !important; 
}

#daily-darshan-wrapper {
    max-width: var(--dd-max-width);
    margin: 0 auto;
    padding: 0 1rem;
    box-sizing: border-box;
    
    /* ADDED: Ensures block-level children (like the date selector) are centered if they use margin: auto */
    /* This ensures that any element that doesn't fill 100% width is centered */
    text-align: center; 
}

/* ------------------- Date Selector ------------------- */
.dd-date-selector-wrapper {
    /* Set the block to inline-block so that the parent's text-align: center works,
       while still honoring max-width and internal styling */
    display: inline-block; 
    
    margin: 0 auto var(--dd-spacing); 
    text-align: center; 
    padding: 0.75rem 1rem;
    background: #fff;
    border: 1px solid var(--dd-border-color);
    border-radius: 8px;
    box-shadow: var(--dd-shadow-md);
    max-width: 220px; 
}
.dd-date-selector-wrapper label { 
    display: block; 
    font-weight: 600; 
    margin-bottom: 0.4rem; 
    color: #333; 
}
#dd-date-input { /* Corrected ID from PHP file */
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--dd-border-color);
    border-radius: 6px;
    width: 200px;
    box-sizing: border-box;
    font-size: 1.5rem;
}

/* ------------------- Gallery Layout ------------------- */

/* Gallery Content Container (The AJAX target) */
#dd-gallery-content {
    /* Styles for the wrapper of the grid */
    padding-top: var(--dd-spacing);
}

.dd-gallery-items { 
    /* This class should likely be applied to the container of the individual items */
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); 
    gap: var(--dd-spacing);
    width: 100%;
    margin: 0;
    padding: 0;
}
/* Gallery Item */
.dd-album-item {
    background: #fff;
    border: 1px solid rgba(0,0,0,0.08);
    border-radius: 8px;
    padding: var(--dd-spacing);
    box-shadow: var(--dd-shadow-md);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    cursor: pointer;
    overflow: hidden;
    /* ADDED: Center align content within the item */
    text-align: center;
}
.dd-album-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--dd-shadow-lg);
}

/* Images */
.dd-album-item img { 
    width: 100%;
    height: auto;
    /* Change display from 'block' to allow margin: 0 auto to work */
    display: block; 
    
    /* ADDED: Use margin auto to center the image itself (if it were smaller than 100% width) */
    /* Since width is 100%, this margin only helps if the image container has padding/margin */
    margin: 0 auto; /* Ensure it's explicitly centered */
    
    object-fit: contain;
    border-radius: 6px;
    transition: transform 0.3s ease;
}
.dd-album-item:hover img { 
    transform: scale(1.03); 
}

/* Album Title (H3) */
.dd-album-item h3 {
    font-weight: 700; 
    font-size: 1.9rem; 
    color: #fff; /* Changed text color to white for contrast on dark background */
    margin-top: 0;
    margin-bottom: 1.5rem;
    
    /* ADDED: Slot/Block Styling */
    display: inline-block; /* Allows the background to wrap the text content */
    padding: 1rem 1rem; /* Inner padding for the slot */
    background: var(--dd-primary-color); /* Use the primary color as the background */
    border-radius: 6px; /* Rounded edges */
    text-align: center; /* Ensures the text inside the block is centered */
    line-height: 1.2; /* Tidy up the line height */
}

/* Captions */
.dd-caption { 
    padding: 1rem 1rem 0; /* Adjusted padding top, kept horizontal padding small */
    margin-bottom: 0;
    font-size: 1.5rem; 
    color: #555;
    line-height: 1.4;
    
    /* ADDED: Subtle Styling for Readability */
    font-style: italic; /* Makes it feel like an annotation */
    color: #333; /* Darker color for better readability against the white background */
    max-width: 90%; /* Restrict width slightly to prevent very long lines in grid layout */
    margin-left: auto; /* Centering helper */
    margin-right: auto; /* Centering helper */
}

/* Image Size Classes (Applied to the #dd-gallery-content wrapper in PHP) */
#dd-gallery-content.dd-img-size-thumbnail .dd-album-item img { max-width: 150px; }
#dd-gallery-content.dd-img-size-medium .dd-album-item img { max-width: 300px; }
#dd-gallery-content.dd-img-size-large .dd-album-item img { max-width: 500px; }
#dd-gallery-content.dd-img-size-full .dd-album-item img { max-width: 700px; }


/* ------------------- Lightbox (Requires JS implementation) ------------------- */

/* Overlay */
#dd-lightbox-overlay { /* Using simpler ID */
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.9);
    z-index: 99999;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    visibility: hidden; 
    transition: opacity 0.3s ease, visibility 0s 0.3s; 
    padding: 20px;
    box-sizing: border-box;
}
#dd-lightbox-overlay.active {
    opacity: 1;
    visibility: visible;
    transition: opacity 0.3s ease;
}

.dd-lightbox-content {
    position: relative;
    max-width: 95%;
    max-height: 95%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Image inside lightbox */
.dd-lightbox-image {
    max-width: 100%;
    max-height: 80vh;
    object-fit: contain;
    display: block;
    margin: 0 auto;
    border-radius: 6px;
    box-shadow: var(--dd-shadow-lg);
}

/* Caption inside lightbox */
.dd-lightbox-caption {
    color: #fff;
    text-align: center;
    padding: 15px 0 0;
    font-size: 1.1rem;
    max-width: 100%;
    line-height: 1.5;
}

/* Close Button (top right) */
.dd-lightbox-close {
    position: absolute;
    top: -10px; /* Adjust position */
    right: -10px;
    color: #fff;
    font-size: 2.5rem;
    cursor: pointer;
    opacity: 0.8;
    transition: opacity 0.2s ease;
    z-index: 100000;
}
.dd-lightbox-close:hover { opacity: 1; }

/* Navigation Arrows */
.dd-lightbox-prev,
.dd-lightbox-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    font-size: 3rem;
    color: #fff;
    cursor: pointer;
    user-select: none;
    opacity: 0.8;
    transition: opacity 0.2s ease;
    padding: 0 20px;
    z-index: 100000;
    text-shadow: 0 0 10px rgba(0,0,0,0.8);
}
.dd-lightbox-prev { left: 10px; }
.dd-lightbox-next { right: 10px; }
.dd-lightbox-prev:hover, .dd-lightbox-next:hover { opacity: 1; }

/* ------------------- Spinner / Messages ------------------- */
#dd-loading-spinner { /* Corrected ID from PHP/JS */
    display: none; /* Hide by default, shown by JS */
}
.dd-spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--dd-primary-color);
    border-radius: 50%;
    width: 36px; height: 36px;
    animation: spin 1s linear infinite;
    margin: 2rem auto;
}
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

.dd-no-photos,
.dd-error-message {
    padding: var(--dd-spacing);
    text-align: center;
    border: 1px dashed var(--dd-primary-color);
    background: #fff;
    color: #333;
    border-radius: 4px;
    font-weight: 600;
}

/* ------------------- Responsive ------------------- */
@media (max-width: 768px) {
    .dd-gallery-items { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
    .dd-lightbox-close { top: 10px; right: 20px; font-size: 2rem; }
}
@media (max-width: 480px) {
    .dd-gallery-items { grid-template-columns: 1fr; }
    .dd-lightbox-prev, .dd-lightbox-next { font-size: 2rem; padding: 0 10px; }
}