/**
 * Gallery Prikaz Styles
 *
 * Responsive gallery layout with consistent card heights and enhanced content display
 * Includes brand theming support with CSS custom properties
 *
 * @author Frajder <dev@frajder.com>
 * @version 1.2
 * @since 1.0
 */

/* Brand Theme Variables */
:root {
    --brand-primary-color: #007bff;
    --brand-secondary-color: #6c757d;
    --brand-accent-color: #28a745;
    --brand-text-primary: #333;
    --brand-text-secondary: #666;
    --brand-text-muted: #888;
    --brand-bg-primary: #fff;
    --brand-bg-secondary: #f8f9fa;
    --brand-border-color: #ddd;
    --brand-shadow-light: rgba(0,0,0,0.1);
    --brand-shadow-medium: rgba(0,0,0,0.15);
    --brand-radius: 8px;
    --brand-transition: 0.2s ease;
}

/* Gallery Row Structure */
.gallery-row {
    display: flex;
    flex-wrap: wrap;
    margin-bottom: 20px;
    align-items: stretch; /* Ensure all cards in row have same height */
}

/* Gallery Items */
.gallery-item {
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
}

/* Gallery Card Container - Fixed Height Approach */
.gallery-card {
    border: 1px solid var(--brand-border-color);
    border-radius: var(--brand-radius);
    overflow: hidden;
    background: var(--brand-bg-primary);
    box-shadow: 0 2px 8px var(--brand-shadow-light);
    transition: transform var(--brand-transition), box-shadow var(--brand-transition);
    display: flex;
    flex-direction: column;
    height: 340px; /* Fixed height for consistency */
    text-align: center; /* Center all content */
}

.gallery-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px var(--brand-shadow-medium);
}

/* Image Wrapper - Fixed Height */
.gallery-image-wrapper {
    position: relative;
    overflow: hidden;
    background: var(--brand-bg-secondary);
    height: 200px; /* Fixed image area height */
}

.gallery-image-wrapper a {
    display: block;
    text-decoration: none;
    height: 100%;
}

.gallery-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.gallery-image-wrapper:hover .gallery-image {
    transform: scale(1.05);
}

/* Content Area - Fixed Height with Overflow Handling */
.gallery-content {
    padding: 20px 15px 15px 15px; /* Extra top padding for better spacing */
    height: 140px; /* Fixed content area height */
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
}

/* Typography */
.gallery-title {
    font-size: 16px;
    font-weight: 600;
    margin: 5px 0 10px 0; /* Better spacing from top and bottom */
    color: var(--brand-text-primary);
    line-height: 1.3;
    height: 44px; /* Fixed height for 2 lines max */
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    text-align: center;
}

.gallery-description {
    font-size: 14px;
    color: var(--brand-text-secondary);
    margin: 0 0 10px 0;
    line-height: 1.4;
    flex: 1;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    text-align: center;
}

.gallery-link {
    margin-top: auto;
    padding-top: 8px;
    height: 20px; /* Fixed height for link area */
    text-align: center;
}

.gallery-link small {
    color: var(--brand-primary-color);
    font-weight: 500;
    white-space: nowrap;
}

.gallery-link i {
    margin-right: 4px;
}

/* Responsive Adjustments */
@media (max-width: 991px) {
    .gallery-card {
        height: 320px;
    }

    .gallery-image-wrapper {
        height: 180px;
    }

    .gallery-content {
        height: 140px;
        padding: 12px;
    }

    .gallery-title {
        font-size: 15px;
        height: 40px;
    }

    .gallery-description {
        font-size: 13px;
    }
}

@media (max-width: 767px) {
    .gallery-row {
        margin-bottom: 15px;
    }

    .gallery-item {
        margin-bottom: 15px;
    }

    .gallery-card {
        height: 300px;
    }

    .gallery-image-wrapper {
        height: 160px;
    }

    .gallery-content {
        height: 140px;
        padding: 10px;
    }

    .gallery-title {
        font-size: 14px;
        height: 36px;
    }

    .gallery-description {
        font-size: 12px;
    }
}

/* Modal Enhancement */
#imagemodal .modal-dialog {
    max-width: 90%;
    width: auto;
}

#imagemodal .imagepreview {
    max-height: 80vh;
    width: auto;
    height: auto;
}

/* Loading States */
.gallery-image-wrapper::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg,
        var(--brand-bg-secondary) 25%,
        var(--brand-border-color) 50%,
        var(--brand-bg-secondary) 75%
    );
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
    z-index: 1;
    opacity: 0;
}

.gallery-image-wrapper.loading::before {
    opacity: 1;
}

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

/* Professional Brand Enhancements */

/* Enhanced focus states for accessibility */
.gallery-card a:focus {
    outline: 2px solid var(--brand-primary-color);
    outline-offset: 2px;
}

/* Brand-specific color overrides - can be customized per site */
[data-brand="green"] {
    --brand-primary-color: #28a745;
    --brand-accent-color: #20c997;
}

[data-brand="blue"] {
    --brand-primary-color: #007bff;
    --brand-accent-color: #17a2b8;
}

[data-brand="red"] {
    --brand-primary-color: #dc3545;
    --brand-accent-color: #fd7e14;
}

/* Enhanced mobile experience */
@media (max-width: 575px) {
    .gallery-card {
        margin-bottom: 20px;
        height: auto; /* Let cards grow naturally on mobile */
        min-height: 320px;
    }

    .gallery-content {
        padding: 15px;
        height: auto; /* Allow content to flow naturally */
        min-height: 120px;
    }

    .gallery-title {
        font-size: 18px;
        height: auto;
        min-height: 44px;
        margin: 10px 0 15px 0; /* More spacing on mobile */
    }

    .gallery-description {
        font-size: 15px;
        line-height: 1.5;
    }

    /* Better touch targets */
    .gallery-card a {
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
}