/* ==========================================================================
   Image Processor Styles
   Layout: Left content (toolbar, preview, additional) | Right panel (full height)
   ========================================================================== */

.gd-img-processor {
    display: flex;
    background-color: #fff;
    border-radius: 0.5rem;
    box-shadow: 0 0.625rem 1.25rem rgba(0, 0, 0, 0.04),
                0 0.125rem 0.375rem rgba(0, 0, 0, 0.04),
                0 0 0.0625rem rgba(0, 0, 0, 0.04);
    overflow: hidden;
    margin-bottom: 6rem;
}

/* ==========================================================================
   Left Content Area
   ========================================================================== */

.gd-img-processor__content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* ==========================================================================
   Toolbar
   ========================================================================== */

.gd-img-processor__toolbar {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1.25rem;
    background-color: #fff;
}

.gd-img-processor__back {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    background-color: var(--control-background, #f4f6f8);
    color: var(--link-color, #4a8af4);
    transition: background-color 0.2s;
    text-decoration: none;
    flex-shrink: 0;
}

.gd-img-processor__back:hover {
    background-color: var(--control-background-hover, #e9ecef);
}

.gd-img-processor__back svg {
    width: 1.25rem;
    height: 1.25rem;
}

.gd-img-processor__filename {
    color: var(--text-color, #333);
    font-size: 0.875rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ==========================================================================
   Preview Area
   ========================================================================== */

.gd-img-processor__preview {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
    min-height: 25rem;
    background-color: #f8f9fa;
    overflow: hidden;
}

.gd-img-processor__preview-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.625rem;
    max-width: 100%;
    min-height: 0;
}

/* 24rem = the preview's 25rem min-height minus its 0.5rem padding top and bottom.
   A percentage max-height can't be used: it would resolve against the
   content-height wrapper and be ignored. */
.gd-img-processor__preview-img {
    display: block;
    max-width: 100%;
    max-height: 24rem;
}

/* A rotated image keeps its unrotated layout box, so its width becomes the
   visible height. Cap that width by the panel's height to keep it inside. */
.gd-img-processor__preview-img--rotated {
    max-width: 24rem;
}

/* Cropper.js container, crop panel only - keep it inside the preview box. */
.gd-img-processor__preview .cropper-container {
    max-width: 100%;
}

/* Empty for panels that publish no note, so the preview keeps its layout. */
.gd-img-processor__preview-note {
    font-size: 0.8125rem;
    color: #6c757d;
    white-space: nowrap;
}

.gd-img-processor__preview-note:empty {
    display: none;
}

.gd-img-processor__preview-note-accent {
    color: var(--control-color, #4a8af4);
    font-weight: 600;
}

/* ==========================================================================
   Additional Images (Bottom Area)
   ========================================================================== */

.gd-img-processor__additional {
    padding: 1rem 1.5rem 1.5rem;
    background-color: #fff;
    border-top: 0.0625rem solid var(--border-color, #e9ecef);
}

.gd-img-processor__additional-label {
    font-size: 0.8125rem;
    color: #6c757d;
    margin-bottom: 0.75rem;
}

/* min-height reserves room for a 3.5rem thumbnail even before one exists, so
   adding the first doesn't grow the strip and stretch the whole row. This is a
   div, so border-box applies: 3.5rem thumb + 0.5rem padding top and bottom. */
.gd-img-processor__additional-list {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-height: 4.5rem;
    overflow-x: auto;
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
    scrollbar-width: thin;
    scrollbar-color: #ccc transparent;
}

.gd-img-processor__additional-list::-webkit-scrollbar {
    height: 0.375rem;
}

.gd-img-processor__additional-list::-webkit-scrollbar-track {
    background: transparent;
}

.gd-img-processor__additional-list::-webkit-scrollbar-thumb {
    background-color: #ccc;
    border-radius: 0.1875rem;
}

/* Deliberately smaller than .gd-img-processor__thumb img (3.5rem). The list
   reserves the taller height itself, so the strip doesn't grow when the first
   thumbnail appears. */
.gd-img-processor__add-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 3rem;
    height: 3rem;
    min-width: 3rem;
    border: 0.125rem dashed var(--link-color, #4a8af4);
    border-radius: 0.375rem;
    background-color: transparent;
    color: var(--link-color, #4a8af4);
    cursor: pointer;
    transition: background-color 0.2s, border-color 0.2s;
}

.gd-img-processor__add-btn:hover {
    background-color: rgba(74, 138, 244, 0.05);
}

.gd-img-processor__add-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.gd-img-processor__add-btn svg {
    width: 1.25rem;
    height: 1.25rem;
}

/* Thumbnail */
.gd-img-processor__thumb {
    position: relative;
    flex-shrink: 0;
}

.gd-img-processor__thumb img {
    display: block;
    height: 3.5rem;
    width: auto;
    border-radius: 0.25rem;
    object-fit: cover;
}

.gd-img-processor__thumb-remove {
    position: absolute;
    top: -0.375rem;
    right: -0.375rem;
    width: 1.25rem;
    height: 1.25rem;
    border-radius: 50%;
    border: none;
    background-color: #dc3545;
    color: #fff;
    font-size: 0.875rem;
    line-height: 1;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
}

.gd-img-processor__thumb:hover .gd-img-processor__thumb-remove {
    display: flex;
}

/* ==========================================================================
   Right Panel - Controls (full height)
   ========================================================================== */

.gd-img-processor__panel {
    width: 14rem;
    min-width: 14rem;
    display: flex;
    flex-direction: column;
    border-left: 0.0625rem solid var(--border-color, #e9ecef);
    background-color: #fff;
    padding: 1.5rem;
}

.gd-img-processor__section {
    margin-bottom: 1.5rem;
}

.gd-img-processor__section-title {
    font-size: 0.75rem;
    font-weight: 600;
    color: #333;
    letter-spacing: 0.03em;
    margin-bottom: 1rem;
}

.gd-img-processor__section-content {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

/* ==========================================================================
   Toggle Switch (for Flip options)
   ========================================================================== */

.gd-img-processor__toggle-label {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    font-size: 0.875rem;
    color: var(--text-color, #333);
}

.gd-img-processor__toggle {
    display: none;
}

.gd-img-processor__toggle-switch {
    position: relative;
    width: 2.75rem;
    height: 1.5rem;
    background-color: #e9ecef;
    border-radius: 0.75rem;
    transition: background-color 0.2s;
    flex-shrink: 0;
}

.gd-img-processor__toggle-switch::after {
    content: '';
    position: absolute;
    top: 0.1875rem;
    left: 0.1875rem;
    width: 1.125rem;
    height: 1.125rem;
    background-color: #fff;
    border-radius: 50%;
    box-shadow: 0 0.0625rem 0.1875rem rgba(0, 0, 0, 0.2);
    transition: transform 0.2s;
}

.gd-img-processor__toggle:checked + .gd-img-processor__toggle-switch {
    background-color: var(--control-color, #4a8af4);
}

.gd-img-processor__toggle:checked + .gd-img-processor__toggle-switch::after {
    transform: translateX(1.25rem);
}

.gd-img-processor__toggle-text {
    flex: 1;
}

/* ==========================================================================
   Radio Buttons
   ========================================================================== */

.gd-img-processor__section-content .gd-radio-label {
    gap: 0.75rem;
}

.gd-img-processor__rotate-arrow {
    color: #6c757d;
    margin-left: 0.25rem;
}

/* ==========================================================================
   Resize Panel
   ========================================================================== */

/* .gd-tabs ships page-sized; scale it down for the 14rem side panel. */
.gd-img-processor__tabs {
    gap: 1.25rem;
    font-size: 0.875rem;
    margin: 0 0 1.25rem;
    padding: 0;
    list-style: none;
}

.gd-img-processor__tabs > li {
    padding-bottom: 0.5rem;
}

.gd-img-processor__size-inputs {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.gd-img-processor__size-inputs .gd-input {
    max-width: none;
    min-width: 0;
    flex: 1;
    text-align: center;
    padding: 0 0.5rem;
}

/* Spinners steal width in a narrow field and the values are typed anyway. */
.gd-img-processor__size-inputs .gd-input::-webkit-outer-spin-button,
.gd-img-processor__size-inputs .gd-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.gd-img-processor__size-inputs .gd-input[type="number"] {
    -moz-appearance: textfield;
    appearance: textfield;
}

.gd-img-processor__size-separator {
    color: #a9b1c3;
    font-size: 0.875rem;
    flex-shrink: 0;
}

/* ==========================================================================
   Actions
   ========================================================================== */

.gd-img-processor__actions {
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.gd-img-processor__process-btn {
    width: 100%;
    height: 2.75rem;
    font-size: 0.9375rem;
}

.gd-img-processor__start-over {
    text-align: center;
    font-size: 0.875rem;
    color: #6c757d;
    text-decoration: none;
    transition: color 0.2s;
}

.gd-img-processor__start-over:hover {
    color: var(--link-color, #4a8af4);
}

/* ==========================================================================
   Responsive - Mobile Layout
   ========================================================================== */

@media screen and (max-width: 48rem) {
    .gd-img-processor {
        flex-direction: column;
    }

    /* No order override: DOM order already gives
       toolbar -> preview -> additional images -> operations. */
    .gd-img-processor__panel {
        width: 100%;
        min-width: auto;
        border-left: none;
        border-top: 0.0625rem solid var(--border-color, #e9ecef);
        padding: 1rem 1.25rem;
    }

    .gd-img-processor__section {
        margin-bottom: 1rem;
    }

    .gd-img-processor__section-content {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 0.5rem 1.5rem;
    }

    /* Column like desktop: full-width button, link centred beneath it.
       The button's width and the link's centring come from the base rules,
       so no process-btn / start-over overrides are needed here. */
    .gd-img-processor__actions {
        flex-direction: column;
        margin-top: 1rem;
        gap: 1rem;
    }

    .gd-img-processor__preview {
        min-height: 16rem;
        padding: 1.5rem;
    }

    /* 13rem = this breakpoint's 16rem min-height less its 1.5rem padding
       top and bottom. Must track .gd-img-processor__preview above. */
    .gd-img-processor__preview-img {
        max-height: 13rem;
    }

    .gd-img-processor__preview-img--rotated {
        max-width: 13rem;
    }

    .gd-img-processor__toolbar {
        padding: 0.75rem 1rem;
    }

    .gd-img-processor__back {
        width: 2.25rem;
        height: 2.25rem;
    }

    .gd-img-processor__additional {
        padding: 1rem;
    }
}
