/* Base Styles */
.testimonial-gallery-page {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    line-height: 1.5;
    color: #333;
    background: #f8f9fa;
}

/* Page Header */
.page-header-section {
    padding: 60px 0 40px;
    text-align: center;
    background: #fff;
    border-bottom: 1px solid #eaeaea;
}

.page-title {
    font-size: 2.5rem;
    font-weight: 700;
    color: #1a365d;
    margin-bottom: 20px;
}

.page-description {
    max-width: 800px;
    margin: 0 auto;
    font-size: 1.1rem;
    color: #4a5568;
    line-height: 1.6;
}

/* Gallery Grid */
.gallery-section {
    padding: 40px 0 80px;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 30px;
    margin: 0;
}

@media (max-width: 768px) {
    .gallery-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }
}

/* Gallery Card */
.gallery-card {
    background: #fff;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 2px 15px rgba(0, 0, 0, 0.08);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.gallery-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
}

/* Image Container */
.card-image-container {
    position: relative;
    width: 100%;
    flex: 1;
    background: #f8f9fa;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 350px;
    overflow: hidden;
}

/* Image Styling - A4 Aspect Ratio */
.card-image {
    max-width: 85%;
    max-height: 85%;
    width: auto;
    height: auto;
    object-fit: contain;
    transition: transform 0.5s ease;
}

.gallery-card:hover .card-image {
    transform: scale(1.02);
}

/* View Overlay */
.view-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.gallery-card:hover .view-overlay {
    opacity: 1;
}

.view-button {
    background: #fff;
    color: #2d3748;
    border: none;
    padding: 12px 28px;
    font-size: 0.95rem;
    font-weight: 600;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.view-button:hover {
    background: #4299e1;
    color: white;
    transform: translateY(-2px);
}

/* Client Info - Always Visible */
.client-info {
    padding: 20px;
    background: #fff;
    border-top: 1px solid #eaeaea;
    text-align: center;
}

.client-name {
    font-size: 1.1rem;
    font-weight: 600;
    color: #2d3748;
    margin: 0 0 8px 0;
    line-height: 1.3;
}

.client-country {
    font-size: 0.95rem;
    color: #718096;
    margin: 0;
    font-weight: 500;
}

/* No Images Message */
.no-images-message {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px 20px;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 2px 15px rgba(0, 0, 0, 0.08);
}

.no-images-message p {
    font-size: 1.1rem;
    color: #718096;
}

/* Modal Styles */
#testimonialModal .modal-content {
    border-radius: 12px;
    border: none;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

.modal-header {
    border-bottom: 1px solid #e2e8f0;
    padding: 15px 20px;
    background: #f8fafc;
    flex-shrink: 0;
}

.modal-title {
    font-size: 1.2rem;
    font-weight: 600;
    color: #2d3748;
    margin: 0;
}

.btn-close {
    border: none;
    background: none;
    font-size: 1.25rem;
    color: #718096;
    cursor: pointer;
    padding: 5px;
    transition: color 0.2s ease;
    line-height: 1;
}

.btn-close:hover {
    color: #2d3748;
}

/* Letter Display Container */
.letter-display-container {
    background: #f1f5f9;
    padding: 30px;
    flex: 1;
    overflow: auto;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    min-height: 400px;
    max-height: 60vh;
}

.modal-image {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 4px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
    display: block;
    margin: 0 auto;
    opacity: 0;
    animation: fadeIn 0.5s ease forwards 0.1s;
    object-position: top left;
}

/* Optimize for A4 letters */
.modal-image.a4-size {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

/* Modal Client Info */
.modal-client-info {
    padding: 20px;
    background: #fff;
    border-top: 1px solid #e2e8f0;
    text-align: center;
    flex-shrink: 0;
}

#modalClientName {
    font-size: 1.2rem;
    font-weight: 600;
    color: #2d3748;
    margin: 0 0 8px 0;
}

#modalClientCountry {
    font-size: 1rem;
    color: #718096;
    margin: 0;
    font-weight: 500;
}

.modal-footer {
    border-top: 1px solid #e2e8f0;
    padding: 15px 20px;
    background: #f8fafc;
    display: flex;
    justify-content: flex-end;
    flex-shrink: 0;
}

.btn-close-modal {
    background: #4299e1;
    color: white;
    border: none;
    padding: 8px 20px;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-close-modal:hover {
    background: #3182ce;
    transform: translateY(-1px);
}

/* Responsive Design */
@media (max-width: 1200px) {
    .container {
        max-width: 100%;
        padding: 0 30px;
    }
}

@media (max-width: 992px) {
    .page-title {
        font-size: 2.2rem;
    }
    
    .card-image-container {
        min-height: 320px;
    }
    
    .letter-display-container {
        padding: 20px;
        min-height: 350px;
        max-height: 55vh;
    }
}

@media (max-width: 768px) {
    .page-header-section {
        padding: 40px 0 30px;
    }
    
    .page-title {
        font-size: 2rem;
    }
    
    .page-description {
        font-size: 1rem;
    }
    
    .gallery-grid {
        gap: 25px;
    }
    
    .card-image-container {
        min-height: 300px;
    }
    
    .client-info {
        padding: 18px;
    }
    
    .client-name {
        font-size: 1.05rem;
    }
    
    .client-country {
        font-size: 0.9rem;
    }
    
    .view-button {
        padding: 10px 22px;
        font-size: 0.9rem;
    }
    
    .modal-header,
    .modal-client-info,
    .modal-footer {
        padding: 15px;
    }
    
    .letter-display-container {
        padding: 15px;
        min-height: 300px;
        max-height: 50vh;
    }
    
    .modal-title {
        font-size: 1.1rem;
    }
}

@media (max-width: 576px) {
    .container {
        padding: 0 20px;
    }
    
    .page-title {
        font-size: 1.8rem;
    }
    
    .gallery-grid {
        gap: 20px;
    }
    
    .card-image-container {
        min-height: 280px;
    }
    
    .card-image {
        max-width: 90%;
        max-height: 90%;
    }
    
    .client-info {
        padding: 15px;
    }
    
    .client-name {
        font-size: 1rem;
    }
    
    .client-country {
        font-size: 0.85rem;
    }
    
    .view-button {
        padding: 8px 18px;
        font-size: 0.85rem;
    }
    
    .letter-display-container {
        padding: 10px;
        min-height: 250px;
        max-height: 45vh;
    }
    
    #modalClientName {
        font-size: 1.1rem;
    }
    
    #modalClientCountry {
        font-size: 0.95rem;
    }
    
    .btn-close-modal {
        padding: 8px 18px;
        font-size: 0.9rem;
    }
}

/* Image Loading States */
.card-image {
    opacity: 0;
    animation: fadeIn 0.5s ease forwards;
}

@keyframes fadeIn {
    to {
        opacity: 1;
    }
}

/* Image Error Fallback */
.card-image[src*="svg"] {
    max-width: 200px;
    max-height: 200px;
    opacity: 0.5;
}

.modal-image[src*="svg"] {
    max-width: 400px;
    max-height: 400px;
    opacity: 0.6;
}

/* Custom Scrollbar for Letter Display */
.letter-display-container::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.letter-display-container::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.letter-display-container::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

.letter-display-container::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Ensure modal backdrop is behind */
.modal-backdrop {
    z-index: 1040;
}

/* Fix for Bootstrap modal */
.modal {
    z-index: 1050;
}

/* Print Styles */
@media print {
    .page-header-section,
    .view-overlay,
    .modal-header,
    .modal-footer,
    .btn-close,
    .btn-close-modal {
        display: none;
    }
    
    .gallery-section {
        padding: 0;
    }
    
    .gallery-grid {
        display: block;
    }
    
    .gallery-card {
        break-inside: avoid;
        margin-bottom: 20px;
        box-shadow: none;
        border: 1px solid #ddd;
        page-break-inside: avoid;
    }
    
    .card-image-container {
        min-height: auto;
        height: 400px;
    }
    
    .modal-client-info {
        border: none;
        background: transparent;
    }
    
    .letter-display-container {
        background: transparent;
        border: 1px solid #eee;
        padding: 0;
    }
    
    .modal-image {
        box-shadow: none;
        border: 1px solid #ddd;
    }
}

/* Accessibility */
.view-button:focus,
.btn-close:focus,
.btn-close-modal:focus {
    outline: 2px solid #4299e1;
    outline-offset: 2px;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .gallery-card,
    .card-image,
    .view-overlay,
    .view-button,
    .modal-image,
    .btn-close-modal {
        transition: none;
        animation: none;
    }
}

/* Zoom controls for large images */
.image-zoom-controls {
    position: absolute;
    bottom: 15px;
    right: 15px;
    display: flex;
    gap: 8px;
    background: rgba(255, 255, 255, 0.9);
    padding: 8px;
    border-radius: 6px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.zoom-btn {
    background: #4299e1;
    color: white;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.zoom-btn:hover {
    background: #3182ce;
    transform: scale(1.1);
}