/* SC Gallery Client Frontend Styles - COMPLETE FILE */

.scgc-gallery {
    margin: 20px 0;
    font-family: inherit;
}

.scgc-error,
.scgc-no-results {
    padding: 20px;
    text-align: center;
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    border-radius: 4px;
    margin: 20px 0;
}

.scgc-no-results {
    background: #d1ecf1;
    color: #0c5460;
    border-color: #bee5eb;
}

/* Procedure Sections */
.scgc-procedure-section {
    margin-bottom: 40px;
}

.scgc-procedure-title {
    font-size: 24px;
    font-weight: 600;
    margin: 0 0 20px 0;
    color: #2c3e50;
    border-bottom: 2px solid #3498db;
    padding-bottom: 10px;
}

.scgc-gallery-title {
    font-size: 28px;
    font-weight: 600;
    margin: 0 0 30px 0;
    color: #2c3e50;
    text-align: center;
}

/* Photo Grid */
.scgc-photo-grid {
    display: grid;
    gap: 20px;
    margin: 20px 0;
}

.scgc-columns-1 { grid-template-columns: 1fr; }
.scgc-columns-2 { grid-template-columns: repeat(2, 1fr); }
.scgc-columns-3 { grid-template-columns: repeat(3, 1fr); }
.scgc-columns-4 { grid-template-columns: repeat(4, 1fr); }

/* Center grids that only have 1 or 2 cards by switching to flex just for those cases */
.scgc-photo-grid.scgc-count-1,
.scgc-photo-grid.scgc-count-2 {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 20px;
}

/* 1 item: use exact 3-column width to match the normal grid */
.scgc-photo-grid.scgc-count-1 .scgc-photo-set-card {
    flex: 0 1 calc((100% - 40px) / 3);
    max-width: calc((100% - 40px) / 3);
}

/* 2 items: keep normal 3-column width so cards match the full grid */
.scgc-photo-grid.scgc-count-2 .scgc-photo-set-card {
    flex: 0 1 calc((100% - 40px) / 3);
    max-width: calc((100% - 40px) / 3);
}


/* Responsive grid */
@media (max-width: 991px) {
    .scgc-columns-3,
    .scgc-columns-4 {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .scgc-photo-grid.scgc-count-1 .scgc-photo-set-card,
    .scgc-photo-grid.scgc-count-2 .scgc-photo-set-card {
        flex: 0 1 calc((100% - 20px) / 2);
        max-width: calc((100% - 20px) / 2);
    }

    /* Center the orphan 3rd item when 3 items collapse to 2 columns */
    .scgc-photo-grid.scgc-columns-3 {
        justify-content: center;
    }
}

@media (max-width: 991px) and (min-width: 768px) {
    /* Convert 3-item grid into flex so the orphan will center */
    .scgc-photo-grid.scgc-columns-3.scgc-count-3 {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: 20px;
    }

    /* Use the proper 2-column width for this breakpoint */
    .scgc-photo-grid.scgc-columns-3.scgc-count-3 .scgc-photo-set-card {
        flex: 0 1 calc((100% - 20px) / 2);
        max-width: calc((100% - 20px) / 2);
    }
}

@media (max-width: 767px) {
    .scgc-columns-2,
    .scgc-columns-3,
    .scgc-columns-4 {
        grid-template-columns: 1fr;
    }
    
    .scgc-photo-grid.scgc-count-1 .scgc-photo-set-card,
    .scgc-photo-grid.scgc-count-2 .scgc-photo-set-card {
        flex: 0 1 100%;
        max-width: 100%;
    }
}

/* Photo Set Cards */
.scgc-photo-set-card {
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    cursor: pointer;
    position: relative;
}

.scgc-photo-set-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}

.scgc-photo-set-card.scgc-clicking {
    transform: translateY(-2px) scale(0.98);
}

.scgc-photo-set-card.scgc-clicked {
    transform: scale(0.95);
}

/* Image Loading States */
.scgc-photo-item.scgc-loading {
    position: relative;
}

.scgc-photo-item.scgc-loading::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #f8f9fa;
    z-index: 1;
}

.scgc-photo-item.scgc-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #e9ecef;
    border-top: 2px solid #3498db;
    border-radius: 50%;
    animation: scgc-spin 1s linear infinite;
    z-index: 2;
}

.scgc-photo-item.scgc-image-error {
    background: #f8f9fa;
}

/* Before/After Container */
.scgc-before-after-container {
    position: relative;
    display: grid;
    grid-template-columns: 1fr 1fr;
    background: #f8f9fa;
}

.scgc-photo-item {
    position: relative;
    /*aspect-ratio: 4/3;*/
    overflow: hidden;
    
    background:#404040;
    min-height:108px;
}

.scgc-photo-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.scgc-photo-set-card:hover .scgc-photo-item img {
    transform: scale(1.05);
}

.scgc-photo-label {
    position: absolute;
    bottom: 8px;
    left: 8px;
    background: rgba(0,0,0,0.8);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
}

.scgc-before .scgc-photo-label {
    background: rgba(231, 76, 60, 0.9);
}

.scgc-after .scgc-photo-label {
    background: rgba(39, 174, 96, 0.9);
}

/* Divider line between before/after */
.scgc-before-after-container::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 10%;
    bottom: 10%;
    width: 2px;
    background: white;
    transform: translateX(-50%);
    box-shadow: 0 0 4px rgba(0,0,0,0.3);
}

/* Photo Set Info */
.scgc-case-number {
    font-size: 16px;
    font-weight: 600;
    margin: 0 0 8px 0;
    color: #2c3e50;
}

.scgc-description {
    font-size: 14px;
    color: #7f8c8d;
    margin: 0 0 8px 0;
    line-height: 1.4;
}

.scgc-photo-count {
    font-size: 12px;
    color: #95a5a6;
    font-weight: 500;
}

/* View More Section */
.scgc-view-more {
    text-align: center;
    margin: 30px 0;
}

.scgc-view-more-button {
    display: inline-block;
    padding: 12px 24px;
    background: #3498db;
    color: white;
    text-decoration: none;
    border-radius: 6px;
    font-weight: 600;
    transition: background-color 0.3s ease;
}

.scgc-view-more-button:hover {
    background: #2980b9;
    color: white;
    text-decoration: none;
}

/* Load More */
.scgc-load-more-container {
    text-align: center;
    margin: 40px 0;
}

.scgc-load-more-button {
    background: #3498db;
    color: white;
    border: none;
    padding: 15px 30px;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.scgc-load-more-button:hover {
    background: #2980b9;
}

.scgc-load-more-button:disabled {
    background: #bdc3c7;
    cursor: not-allowed;
}

.scgc-loading {
    color: #7f8c8d;
    font-style: italic;
}

/* Procedure Header */
.scgc-procedure-header {
    margin-bottom: 30px;
    text-align: center;
}

.scgc-back-link {
    margin-top: 10px;
}

.scgc-back-button {
    display: inline-block;
    padding: 8px 16px;
    background: #f8f9fa;
    color: #495057;
    text-decoration: none;
    border-radius: 4px;
    font-size: 14px;
    transition: background-color 0.3s ease;
}

.scgc-back-button:hover {
    background: #e9ecef;
    color: #495057;
    text-decoration: none;
}

/* Patient Detail Styles */
.scgc-patient-detail {
    margin: 20px 0;
}

.scgc-patient-header {
    margin-bottom: 30px;
}

.scgc-patient-title {
    font-size: 28px;
    font-weight: 600;
    margin: 10px 0;
    color: #2c3e50;
}

.scgc-patient-sets {
    display: grid;
    gap: 40px;
}

.scgc-patient-set {
    background: #fff;
    border: 1px solid #e1e5e9;
    border-radius: 8px;
    padding: 25px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.scgc-set-title {
    margin: 0 0 15px 0;
    font-size: 22px;
    color: #2c3e50;
    border-bottom: 2px solid #3498db;
    padding-bottom: 10px;
}

.scgc-procedure-name {
    color: #7f8c8d;
    font-size: 16px;
    margin: 0 0 20px 0;
    font-weight: 500;
}

.scgc-patient-photos {
    display: grid;
    gap: 25px;
}

.scgc-photo-view {
    border: 1px solid #e9ecef;
    border-radius: 6px;
    overflow: hidden;
}

.scgc-view-title {
    background: #f8f9fa;
    padding: 12px 20px;
    margin: 0;
    font-size: 18px;
    color: #495057;
    border-bottom: 1px solid #e9ecef;
}

.scgc-before-after-pair {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
}

.scgc-patient-detail .scgc-photo-item {
    position: relative;
    aspect-ratio: 4/5;
    overflow: hidden;
    cursor: pointer;
}

.scgc-patient-detail .scgc-photo-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.scgc-patient-detail .scgc-photo-item:hover img {
    transform: scale(1.02);
}

.scgc-patient-detail .scgc-photo-label {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 8px;
    text-align: center;
    font-weight: 600;
    font-size: 14px;
    color: white;
}

.scgc-patient-detail .scgc-before .scgc-photo-label {
    background: rgba(231, 76, 60, 0.9);
}

.scgc-patient-detail .scgc-after .scgc-photo-label {
    background: rgba(39, 174, 96, 0.9);
}

/* LAYOUT VARIATIONS */

/* Stacked Layout Override */
.scgc-layout-stacked .scgc-photo-grid {
    display: block !important;
    max-width: 800px;
    margin: 20px auto !important;
}

.scgc-layout-stacked .scgc-photo-set-card {
    display: flex !important;
    align-items: flex-start;
    gap: 20px;
    margin-bottom: 30px;
    background: #fff;
    border: 1px solid #e1e5e9;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.scgc-layout-stacked .scgc-before-after-container {
    flex: 0 0 200px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
}

.scgc-layout-stacked .scgc-photo-set-info {
    flex: 1;
    padding: 0;
}

/* In stacked layout, let images size naturally */
.scgc-layout-stacked .scgc-photo-item {
    aspect-ratio: unset !important;
    height: auto;
}

.scgc-layout-stacked .scgc-photo-item img {
    width: 100%;
    height: auto;
}

/* Loading Animation */
.scgc-loading-grid {
    opacity: 0.7;
    pointer-events: none;
}

.scgc-loading-grid::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 32px;
    height: 32px;
    margin: -16px 0 0 -16px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #3498db;
    border-radius: 50%;
    animation: scgc-spin 1s linear infinite;
}

@keyframes scgc-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Mobile responsive */
@media (max-width: 991px) {
    .scgc-before-after-pair {
        grid-template-columns: 1fr;
    }
    
    .scgc-patient-detail .scgc-photo-item {
        aspect-ratio: 3/4;
    }
    
    .scgc-layout-stacked .scgc-photo-set-card {
        flex-direction: column;
        align-items: stretch;
    }
    
    .scgc-layout-stacked .scgc-before-after-container {
        flex: none;
        max-width: 300px;
        margin: 0 auto 15px auto;
    }
}

/* Accessibility */
.scgc-photo-set-card:focus {
    outline: 2px solid #3498db;
    outline-offset: 2px;
}

/* Patient Detail Links - Added for clickable gallery cards */
.scgc-info-link {
    text-decoration: none !important;
    color: inherit;
    display: block;
    position:relative;
    padding: 15px;
}

.scgc-info-link:hover {
    text-decoration: none;
}

.scgc-photo-set-card {
    cursor: default;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.scgc-photo-set-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

/* View Patient Button */
.scgc-view-patient-btn {
    margin-top: 12px;
    text-align: center;
    display: inline-block;
    padding: 8px 12px;
    background: #3498db;
    color: white !important;
    text-decoration: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 600;
    transition: background-color 0.3s ease;
    
    position:absolute;
    right:15px;
    bottom:15px;
}

.scgc-photo-set-info:hover .scgc-view-patient-btn {
    background: #2980b9;
    color: white !important;
    text-decoration: none;
}

/* Ensure links don't interfere with layout */
/*.scgc-photo-set-link .scgc-before-after-container {
    pointer-events: all;
}*/

/* Stacked layout link adjustments */
/*.scgc-layout-stacked .scgc-photo-set-link {
    display: contents;
}*/

/* Print styles */
@media print {
    .scgc-load-more-container,
    .scgc-view-more {
        display: none;
    }
    
    .scgc-photo-set-card {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #ddd;
    }
}