#sgl-gallery-container {
    /* This container will now be constrained by the theme's content width */
    /* The .sgl-admin-view class is added via PHP if the user is logged in */
    width: 100%;
}

.sgl-folder {
    /* This is now a full-width container, styles are moved below */
    border: 1px solid #ddd;
}

/* Make the grids full-width, breaking out of the theme's container */
#sgl-gallery-container .sgl-folder,
#sgl-gallery-container .sgl-image-grid,
#sgl-gallery-container .sgl-folder-grid,
#sgl-gallery-container #sgl-frontend-form,
#sgl-gallery-container #sgl-youtube-form {
    width: 100vw;
    position: relative;
    left: 50%;
    transform: translateX(-50%);
    padding: 20px 40px; /* Add padding so content doesn't touch the edges */
    box-sizing: border-box;
    max-width: none; /* Ensure no theme max-width is applied */
    margin-bottom: 40px;
}

/* Grids inside the now-full-width folder should NOT break out again */
#sgl-gallery-container .sgl-folder .sgl-image-grid,
#sgl-gallery-container .sgl-folder .sgl-folder-grid,
#sgl-gallery-container .sgl-folder #sgl-frontend-form,
#sgl-gallery-container .sgl-folder #sgl-youtube-form {
    width: 100%;
    position: static;
    transform: none;
    padding: 0;
    max-width: 100%;
    margin-bottom: 0;
}

.sgl-image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); /* Noch mehr Spalten */
    gap: 20px;
}

.sgl-image-item {
    position: relative;
    overflow: hidden;
    transition: box-shadow 0.3s ease;
}

.sgl-image-item:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.sgl-image-item img {
    width: 100%;
    height: auto;
    display: block;
    transition: transform 0.3s ease;
}

.sgl-image-item:hover img {
    transform: scale(1.05);
}

.sgl-folder-actions {
    margin-top: 10px;
}

#sgl-frontend-form {
    margin-top: 40px;
    padding: 20px;
    border: 1px solid #ddd;
}

#sgl-youtube-form {
    margin-top: 20px;
    padding: 20px;
    border: 1px solid #ddd;
    border-top: none;
}

.sgl-folder-grid {
    display: grid;
    gap: 20px;
    margin-top: 40px;
    margin-bottom: 40px;
}

.sgl-folder-item {
    position: relative;
    border: 1px solid #ddd;
    text-align: center;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.sgl-folder-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.12);
}

.sgl-folder-item a {
    display: block;
    text-decoration: none;
    color: #333;
}

.sgl-folder-item img {
    width: 100%;
    height: 180px;
    object-fit: cover;
    display: block;
}

.sgl-folder-item h3 {
    margin: 0;
    padding: 15px;
    font-size: 16px;
    background-color: #f9f9f9;
}

.sgl-folder-actions {
    position: absolute;
    top: 5px;
    right: 5px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    z-index: 2;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.sgl-folder-item:hover .sgl-folder-actions,
.sgl-folder-item:focus-within .sgl-folder-actions {
    opacity: 1;
}

.sgl-folder-placeholder {
    width: 100%;
    height: 180px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #f0f0f0;
    color: #aaa;
}

.sgl-video-placeholder {
    width: 100%;
    padding-top: 75%; /* Aspect ratio 4:3 */
    position: relative;
    background-color: #222;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sgl-video-placeholder::after {
    content: '▶';
    color: white;
    font-size: 40px;
    opacity: 0.7;
}

.sgl-image-actions {
    position: absolute;
    top: 5px;
    right: 5px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    z-index: 10;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.sgl-image-item:hover .sgl-image-actions,
.sgl-image-item:focus-within .sgl-image-actions {
    opacity: 1;
}

.delete-image, .set-cover-image, .move-image {
    background: red;
    color: white;
    border: none;
    cursor: pointer;
    padding: 5px;
    font-size: 12px;
}

.set-cover-image, .move-image {
    background: #0073aa;
}

.delete-folder, .rename-folder {
    background: red;
    color: white;
    border: none;
    cursor: pointer;
    padding: 5px;
    font-size: 12px;
    width: 28px;
}

.rename-folder { background: #0073aa; }

.sgl-folder > a {
    display: inline-block;
    margin-bottom: 20px;
    color: #0073aa;
    text-decoration: none;
}

/* --- Sorting Styles --- */
.sgl-admin-view .sgl-image-item,
.sgl-admin-view .sgl-folder-item {
    cursor: move;
}

.ui-sortable-placeholder {
    border: 2px dashed #ccc;
    background-color: #f7f7f7;
    visibility: visible !important;
    border-radius: 3px;
}

.ui-sortable-helper {
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    transform: scale(1.05);
    z-index: 9999;
}

/* --- Pagination Styles --- */
.sgl-pagination {
    margin-top: 30px;
    text-align: center;
}

.sgl-pagination .page-numbers {
    display: inline-block;
    padding: 8px 14px;
    margin: 0 3px;
    border: 1px solid #ddd;
    border-radius: 4px;
    text-decoration: none;
    color: #0073aa;
    transition: background-color 0.2s, color 0.2s;
}

.sgl-pagination .page-numbers:hover {
    background-color: #f0f0f0;
}

.sgl-pagination .page-numbers.current {
    background-color: #0073aa;
    color: #fff;
    border-color: #0073aa;
    cursor: default;
}

/* --- Hidden Title --- */
.sgl-image-title.sgl-title-hidden {
    display: none;
}
.sgl-admin-view .sgl-image-title.sgl-title-hidden {
    display: block;
    opacity: 0.5;
    font-style: italic;
}

/* --- Modal --- */
.sgl-modal { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); z-index: 10000; display: flex; align-items: center; justify-content: center; }
.sgl-modal-content { background: white; padding: 20px; border-radius: 5px; width: 300px; box-shadow: 0 2px 10px rgba(0,0,0,0.2); }
.sgl-modal-content h3 { margin-top: 0; }
.sgl-modal-content input[type="text"] { width: 100%; margin-bottom: 10px; padding: 8px; border: 1px solid #ccc; border-radius: 4px; box-sizing: border-box; }
.sgl-modal-content label { display: block; margin-bottom: 15px; }
.sgl-modal-actions { display: flex; justify-content: flex-end; gap: 10px; }

/* --- Lightbox Counter --- */
.gslide-count {
    position: absolute;
    top: 15px;
    left: 15px;
    color: #fff;
    font-size: 14px;
    background: rgba(0, 0, 0, 0.5);
    padding: 5px 10px;
    border-radius: 4px;
    z-index: 9999;
}

/* --- Bulk Selection --- */
.sgl-image-select {
    position: absolute;
    top: 5px;
    left: 5px;
    z-index: 10;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.sgl-image-item:hover .sgl-image-select,
.sgl-image-select.checked {
    opacity: 1;
}

.sgl-bulk-checkbox {
    width: 20px;
    height: 20px;
    cursor: pointer;
    box-shadow: 0 0 5px rgba(0,0,0,0.5);
}

/* --- Progress Bar --- */
.sgl-progress-container {
    display: none;
    margin-top: 15px;
    margin-bottom: 10px;
}
.sgl-progress-bar-wrapper {
    width: 100%;
    background-color: #f0f0f1;
    border-radius: 4px;
    height: 20px;
    overflow: hidden;
    border: 1px solid #ddd;
}
.sgl-progress-bar {
    width: 0%;
    height: 100%;
    background-color: #2271b1;
    transition: width 0.2s ease;
}
.sgl-progress-text {
    font-size: 12px;
    margin-top: 5px;
    color: #666;
    text-align: center;
}
