/* ===== IMAGE GALLERY RESPONSIVE SIZING ===== */
.image-gallery-row[data-image-count="1"] .image-flex-item,
.image-gallery-row[data-image-count="1"] .image-card {
    max-width: 100%;
}

.image-gallery-row[data-image-count="2"] .image-flex-item,
.image-gallery-row[data-image-count="2"] .image-card {
    max-width: 45%;
}

.image-gallery-row[data-image-count="3"] .image-flex-item,
.image-gallery-row[data-image-count="3"] .image-card {
    max-width: 30%;
}

.image-gallery-row[data-image-count="4"] .image-flex-item,
.image-gallery-row[data-image-count="4"] .image-card {
    max-width: 22%;
}

.image-gallery-row[data-image-count="5"] .image-flex-item,
.image-gallery-row[data-image-count="5"] .image-card {
    max-width: 18%;
}

.image-gallery-row[data-image-count="6"] .image-flex-item,
.image-gallery-row[data-image-count="6"] .image-card {
    max-width: 15%;
}

/* ===== IMAGE GALLERY LAYOUT ===== */
.image-gallery-row,
.image-list {
    display: flex;
    justify-content: center;
    flex-wrap: nowrap;
    gap: 16px;
    overflow-x: auto;
    padding-bottom: 1rem;
}

.image-flex-item,
.image-card {
    flex: 0 0 auto;
    max-width: 100%;
    box-sizing: border-box;
    text-align: center;
}

    .image-flex-item img,
    .image-card img {
        max-width: 400px;
        width: 100%;
        height: auto;
        display: block;
        border-radius: 4px;
        transition: transform 0.2s ease;
    }

        .image-flex-item img:hover {
            transform: scale(1.02);
        }

    .image-card textarea {
        width: 100%;
        max-width: 400px;
        margin: 2px auto;
        display: block;
    }

/* ===== SECTION CONTROLS ===== */
.image-gallery-section {
    position: relative;
}

.img-gallery-icons {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 10;
    display: none;
}

.image-gallery-section:hover .img-gallery-icons {
    display: block;
}

/* ===== ROW CONTROLS ===== */
.row-controls {
    display: flex;
    align-items: center;
    margin-bottom: 1rem;
    gap: 0.5rem;
}

.row-title-container {
    flex: 1;
    position: relative;
}

.row-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 0.75rem;
    margin-bottom: 1rem;
}

.add-image-btn {
    color: #0d6efd;
    background-color: transparent;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

    .add-image-btn:hover {
        background-color: rgba(13, 110, 253, 0.1);
        transform: scale(1.1);
    }

    .add-image-btn i {
        font-size: 0.9rem;
    }

.remove-row-btn {
    color: #dc3545;
    background-color: transparent;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

    .remove-row-btn:hover {
        background-color: rgba(220, 53, 69, 0.1);
        transform: scale(1.1);
    }

/* ===== IMAGE CONTROLS OVERLAY ===== */
.image-card .position-relative {
    overflow: hidden;
}

.image-controls-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: space-between;
    padding: 8px;
    opacity: 0;
    transition: opacity 0.2s ease;
    background: linear-gradient(to bottom, rgba(0,0,0,0.4) 0%, rgba(0,0,0,0) 40%);
    pointer-events: none;
}

.image-card:hover .image-controls-overlay {
    opacity: 1;
}

.image-controls-overlay .drag-handle,
.image-controls-overlay .remove-image-btn {
    color: white;
    background: rgba(0,0,0,0.5);
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    pointer-events: auto;
    border: none;
    z-index: 1100;
}

    .image-controls-overlay .drag-handle:hover,
    .image-controls-overlay .remove-image-btn:hover {
        background: rgba(0,0,0,0.8);
        transform: scale(1.1);
    }

    .image-controls-overlay .remove-image-btn:hover {
        background: rgba(220,53,69,0.8);
    }

.ui-sortable-helper .image-controls-overlay {
    display: none;
}

/* ===== TYPOGRAPHY ===== */
.rowSubtitle {
    font-size: 20px;
    width: 100% !important;
    max-width: 100% !important;
    display: block !important;
}

.caption {
    font-size: 14px;
}

.SectionHeader,
#SectionHeader,
.image-gallery-section h2 {
    color: #f58025 !important;
    font-size: 48px !important;
    font-weight: 300 !important;
    line-height: 1.2;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    display: block;
}

.RowTitle,
.image-gallery-section h4 {
    color: #f58025 !important;
    font-size: 34px !important;
    font-weight: 300 !important;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    display: block;
}

/* ===== UTILITY CLASSES ===== */
.placeholder {
    background-color: #e9ecef;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 120px;
    font-size: 0.9rem;
    color: #777;
}

textarea {
    resize: none;
}

.sortable-placeholder {
    width: 160px;
    height: 240px;
    border: 2px dashed #aaa;
    background: #f8f9fa;
    opacity: 0.7;
    margin: 5px;
}

.row-sort-placeholder {
    border: 2px dashed #aaa;
    background: #f8f9fa;
    height: 100px;
    margin-bottom: 1rem;
}

/* ===== THEME STYLES ===== */
.theme-light {
    background-color: #f8f9fa;
    color: #212529;
}

    .theme-light input,
    .theme-light textarea {
        color: #212529;
        border: none;
        background-color: transparent !important;
        box-shadow: none;
        margin-bottom: 0.5rem;
    }

    .theme-light select {
        background-color: #ffffff;
        color: #212529;
    }

.theme-dark {
    background-color: #212529;
    color: #ffffff;
}

    .theme-dark input,
    .theme-dark textarea {
        color: #fff;
        border: none;
        background-color: transparent !important;
        box-shadow: none;
        margin-bottom: 0.5rem;
    }

        .theme-dark input:focus,
        .theme-dark textarea:focus {
            color: #fff !important;
            background-color: transparent !important;
        }

    .theme-dark select {
        background-color: #343a40;
        color: #fff;
        border-color: #495057;
    }

    .theme-dark .row-drag-handle,
    .theme-dark .drag-handle {
        color: #ffffff !important;
    }

.theme-gray {
    background-color: #6c757d;
    color: #ffffff;
}

    .theme-gray input,
    .theme-gray textarea {
        color: #fff;
        border: none;
        background-color: transparent !important;
        box-shadow: none;
        margin-bottom: 0.5rem;
    }

        .theme-gray input:focus,
        .theme-gray textarea:focus {
            color: #212529 !important;
            background-color: transparent !important;
        }

    .theme-gray select {
        background-color: #adb5bd;
        color: #212529;
        border-color: #6c757d;
    }

    .theme-gray .row-drag-handle,
    .theme-gray .drag-handle {
        color: #ffffff !important;
    }

    .theme-gray .remove-image-btn,
    .theme-gray .remove-row-btn,
    .theme-gray .add-image-btn {
        background-color: #ffffff;
        color: #212529;
        border: 1px solid rgba(0, 0, 0, 0.15);
    }

        .theme-gray .remove-image-btn:hover,
        .theme-gray .remove-row-btn:hover,
        .theme-gray .add-image-btn:hover {
            background-color: #e9ecef;
        }

.theme-none input,
.theme-none textarea {
    color: #495057;
    border: none;
    background-color: transparent !important;
    box-shadow: none;
    margin-bottom: 0.5rem;
}

/* ===== GALLERY SELECTION CONTAINER ===== */
.imagegallery-selection-container {
    min-height: 80vh;
    padding: 20px 0 60px 0;
    background-color: #fafafa;
    border-bottom: 3px solid #dee2e6;
    margin-bottom: 40px;
    position: relative;
}

    .imagegallery-selection-container::after {
        content: '';
        position: absolute;
        bottom: -10px;
        left: 50%;
        transform: translateX(-50%);
        width: 80%;
        height: 2px;
        background: linear-gradient(90deg, transparent, #f58025, transparent);
        box-shadow: 0 2px 8px rgba(245, 128, 37, 0.3);
    }

.gallery-wrapper {
    position: relative;
    border-radius: 8px;
    margin-bottom: 25px;
    margin-top: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    border: 2px solid #e9ecef;
    transition: all 0.3s ease;
}

    .gallery-wrapper:hover {
        box-shadow: 0 8px 25px rgba(245, 128, 37, 0.15);
        border-color: #f58025;
        transform: translateY(-2px);
    }

    .gallery-wrapper::before {
        content: "Image Gallery Preview";
        position: absolute;
        top: -12px;
        left: 20px;
        background: white;
        padding: 4px 12px;
        font-size: 0.85rem;
        color: #6c757d;
        border: 1px solid #dee2e6;
        border-radius: 4px;
        font-weight: 500;
        z-index: 15;
    }

.add-to-page-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    display: none;
    z-index: 20;
    color: #f58025;
    background: white;
    border-radius: 50%;
    padding: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    transition: all 0.2s ease;
}

    .add-to-page-btn:hover {
        color: white;
        background: #f58025;
        transform: scale(1.1);
    }

.gallery-wrapper:hover .add-to-page-btn {
    display: block;
}

/* ===== MOBILE RESPONSIVE ===== */
@media (max-width: 576px) {
    .hero-icons {
        visibility: visible !important;
    }

    .image-gallery-row {
        flex-wrap: wrap !important;
    }

        .image-gallery-row[data-image-count="1"] .image-flex-item,
        .image-gallery-row[data-image-count="1"] .image-card {
            max-width: 75%;
        }

        .image-gallery-row[data-image-count="2"] .image-flex-item,
        .image-gallery-row[data-image-count="3"] .image-flex-item,
        .image-gallery-row[data-image-count="4"] .image-flex-item,
        .image-gallery-row[data-image-count="5"] .image-flex-item,
        .image-gallery-row[data-image-count="6"] .image-flex-item,
        .image-gallery-row[data-image-count="2"] .image-card,
        .image-gallery-row[data-image-count="3"] .image-card,
        .image-gallery-row[data-image-count="4"] .image-card,
        .image-gallery-row[data-image-count="5"] .image-card,
        .image-gallery-row[data-image-count="6"] .image-card {
            max-width: 45%;
        }

    .add-to-page-btn {
        display: block !important;
    }
}

/* Always show icons on mobile */
@media (hover: none) and (pointer: coarse) {
    .img-gallery-icons,
    .add-to-page-btn {
        display: block !important;
    }
}
