/*
 * Atlas Product Designer CSS
 * Version: 3.10.2
 *
 * Changelog v3.10.2:
 * - Desktop: rotation slider visible (matches scale slider pattern)
 * - Rotation step: 45° → 15° for finer control via buttons
 * - Label: Greek "Περιστροφή:" with degree display
 * - Tablet/mobile: rotation slider stays hidden (gestures sufficient)
 *
 * Changelog v3.10.1:
 * - Desktop side panel: breakpoint 1024px→1245px (fits WoodMart 1300px container)
 * - Floating bar: extended 769–1244px with two-row layout
 *   Row 1: Rotate + AI buttons (centered)
 *   Row 2: Scale slider + Color + Remove
 * - Canvas flex-basis: 0 + min-width: 250px (shrinks before wrapping)
 *
 * Changelog v3.10.0:
 * - Desktop: side panel layout (controls beside canvas)
 * - Tablet: floating bottom toolbar (glass morphism)
 * - Mobile: unchanged
 * - New design tokens for panel and floating bar
 *
 * Changelog v3.9.0:
 * - Unified toolbar panel (4 control zones → 1)
 * - WCAG AA contrast fixes (5 elements)
 * - CSS custom properties (design tokens)
 * - Rotation slider hidden (buttons + gestures sufficient)
 * - Inline color picker
 * - Remove button redesigned (red, WCAG compliant)
 * - Arrow indicators: yellow → brand blue
 */

/* ─── Design Tokens ──────────────────────────────────────────── */
:root {
    --apd-primary: #2e6bc6;
    --apd-primary-hover: #2558a8;
    --apd-text: #374151;
    --apd-muted: #6b7280;
    --apd-danger: #c0392b;
    --apd-danger-hover: #a93226;
    --apd-surface: #f8fafc;
    --apd-border: #e2e8f0;
    --apd-ai-start: #5a6fd6;
    --apd-ai-end: #764ba2;
    --apd-radius-panel: 10px;
    --apd-radius-btn: 6px;
    /* Side panel (desktop) */
    --apd-panel-width: 200px;
    --apd-panel-gap: 12px;
    --apd-label-size: 11px;
    /* Floating bar (tablet) */
    --apd-float-bg: rgba(255, 255, 255, 0.97);
    --apd-float-shadow: 0 -2px 16px rgba(0, 0, 0, 0.12);
    --apd-float-blur: 12px;
}

/* ─── Toast Notifications ────────────────────────────────────── */
#apd-toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    pointer-events: none;
}

.apd-toast {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    margin-bottom: 12px;
    max-width: 350px;
    min-width: min(280px, calc(100vw - 40px));
    opacity: 0;
    overflow: hidden;
    pointer-events: all;
    position: relative;
    transform: translateX(100%);
    transition: all 0.3s ease;
}

.apd-toast.apd-toast-show {
    opacity: 1;
    transform: translateX(0);
}

.apd-toast-content {
    align-items: center;
    display: flex;
    padding: 16px;
    position: relative;
}

.apd-toast-message {
    flex: 1;
    font-size: 14px;
    line-height: 1.5;
    padding-right: 12px;
}

.apd-toast-close {
    background: none;
    border: none;
    color: #666;
    cursor: pointer;
    font-size: 20px;
    min-height: 44px;
    min-width: 44px;
    line-height: 1;
    padding: 0;
    transition: color 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.apd-toast-close:hover {
    color: #333;
}

.apd-toast-progress {
    background: rgba(0, 0, 0, 0.1);
    bottom: 0;
    height: 4px;
    left: 0;
    position: absolute;
    width: 100%;
}

.apd-toast-success { border-left: 4px solid #28a745; }
.apd-toast-success .apd-toast-progress { background: #28a745; }
.apd-toast-error { border-left: 4px solid #dc3545; }
.apd-toast-error .apd-toast-progress { background: #dc3545; }
.apd-toast-warning { border-left: 4px solid #ffc107; }
.apd-toast-warning .apd-toast-progress { background: #ffc107; }
.apd-toast-info { border-left: 4px solid #17a2b8; }
.apd-toast-info .apd-toast-progress { background: #17a2b8; }

@media (max-width: 768px) {
    #apd-toast-container {
        left: 10px;
        right: 10px;
        top: 10px;
    }
    .apd-toast {
        max-width: 100%;
    }
}

/* ─── Container & Canvas ─────────────────────────────────────── */
#apd-product-base {
    width: 100%;
    height: auto;
    max-width: 100%;
}

#apd-case-designer-container {
    position: relative;
    width: 100%;
    max-width: min(500px, 95vw);
    margin: auto;
    text-align: center;
}

#apd-canvas-area {
    position: relative;
    width: 70%;
    height: auto;
    margin: auto;
}

#apd-overlay-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    touch-action: none;
}

#apd-uploaded-image-canvas {
    width: 100%;
    height: auto;
    cursor: grab;
    touch-action: none;
}

#apd-uploaded-image-canvas:active {
    cursor: grabbing;
}

/* ─── Upload Area ────────────────────────────────────────────── */
#apd-upload-area {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 20px;
    border: 2px dashed transparent;
    border-radius: 8px;
    transition: border-color 0.3s ease, background-color 0.3s ease;
    box-sizing: border-box;
    cursor: pointer;
}

#apd-upload-area.apd-drag-over {
    border-color: var(--apd-primary);
    background-color: rgba(46, 107, 198, 0.08);
}

.apd-drag-hint {
    margin: 8px 0 0;
    font-size: 13px;
    color: #999;
}

.apd-custom-file-upload {
    display: inline-block;
    padding: 14px 24px;
    min-height: 44px;
    background-color: var(--apd-primary);
    color: #fff;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s ease, box-shadow 0.3s ease;
    margin-top: 10px;
    font-size: 16px;
    box-sizing: border-box;
}

.apd-custom-file-upload:hover {
    background-color: var(--apd-primary-hover);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

.apd-upload-label-mobile {
    display: none;
}

.apd-custom-file-input {
    display: none;
}

.apd-upload-icon-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.apd-upload-icon-wrapper svg {
    width: clamp(80px, 25vw, 125px);
    height: clamp(80px, 25vw, 125px);
    margin-bottom: 10px;
}

/* ─── Arrow Indicators (WCAG fix: yellow → brand blue pulse) ── */
.apd-arrow {
    width: 0;
    height: 0;
    border-style: solid;
    border-color: transparent;
    position: absolute;
    pointer-events: none;
    z-index: 150;
    display: block;
}

.apd-arrow-up {
    border-width: 0 10px 15px 10px;
    border-bottom-color: var(--apd-primary);
    top: 10px;
    left: 50%;
    transform: translateX(-50%) translateY(0);
    animation: extract-up 2s infinite;
}

.apd-arrow-down {
    border-width: 15px 10px 0 10px;
    border-top-color: var(--apd-primary);
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%) translateY(0);
    animation: extract-down 2s infinite;
}

.apd-arrow-left {
    border-width: 10px 15px 10px 0;
    border-right-color: var(--apd-primary);
    top: 50%;
    left: 10px;
    transform: translateY(-50%) translateX(0);
    animation: extract-left 2s infinite;
}

.apd-arrow-right {
    border-width: 10px 0 10px 15px;
    border-left-color: var(--apd-primary);
    top: 50%;
    right: 10px;
    transform: translateY(-50%) translateX(0);
    animation: extract-right 2s infinite;
}

@keyframes extract-up {
    0%, 100% {
        transform: translateX(-50%) translateY(0);
        opacity: 1;
        border-bottom-color: var(--apd-primary);
    }
    50% {
        transform: translateX(-50%) translateY(-10px);
        opacity: 0.5;
        border-bottom-color: var(--apd-primary);
    }
}

@keyframes extract-down {
    0%, 100% {
        transform: translateX(-50%) translateY(0);
        opacity: 1;
        border-top-color: var(--apd-primary);
    }
    50% {
        transform: translateX(-50%) translateY(10px);
        opacity: 0.5;
        border-top-color: var(--apd-primary);
    }
}

@keyframes extract-left {
    0%, 100% {
        transform: translateY(-50%) translateX(0);
        opacity: 1;
        border-right-color: var(--apd-primary);
    }
    50% {
        transform: translateY(-50%) translateX(-10px);
        opacity: 0.5;
        border-right-color: var(--apd-primary);
    }
}

@keyframes extract-right {
    0%, 100% {
        transform: translateY(-50%) translateX(0);
        opacity: 1;
        border-left-color: var(--apd-primary);
    }
    50% {
        transform: translateY(-50%) translateX(10px);
        opacity: 0.5;
        border-left-color: var(--apd-primary);
    }
}

/* ─── Loader & Spinner ───────────────────────────────────────── */
#apd-loader-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    display: none;
}

#apd-loader {
    text-align: center;
    color: #fff;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.apd-spinner {
    border: 8px solid rgba(255, 255, 255, 0.1);
    border-top: 8px solid #fff;
    border-radius: 50%;
    width: 60px;
    height: 60px;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

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

/* ─── Modal ──────────────────────────────────────────────────── */
.apd-modal {
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
}

.apd-modal-content {
    background-color: #fff;
    padding: 20px;
    border-radius: 10px;
    width: 90%;
    max-width: 500px;
    text-align: center;
    font-family: 'Roboto', sans-serif;
}

.apd-modal-content h2 {
    font-family: 'Roboto', sans-serif;
    font-weight: 500;
}

.apd-modal-content p {
    font-family: 'Roboto', sans-serif;
    font-weight: 400;
}

/* WCAG fix: #aaa (2.32:1) → #666666 (5.74:1) */
.apd-close {
    color: #666666;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.apd-close:hover,
.apd-close:focus {
    color: black;
    text-decoration: none;
    cursor: pointer;
}

#apd-design-preview {
    max-width: 100%;
    height: auto;
    margin: 20px 0;
}

.apd-modal-footer {
    display: flex;
    justify-content: space-around;
    margin-top: 20px;
    gap: 10px;
    flex-wrap: wrap;
}

.apd-modal-footer .btn {
    padding: 10px 20px;
    font-size: 16px;
    text-decoration: none;
    border-radius: 5px;
    transition: background-color 0.3s ease, color 0.3s ease;
    width: 100%;
    max-width: 45%;
    box-sizing: border-box;
    text-align: center;
}

.apd-modal-footer .btn-primary {
    background-color: var(--apd-primary);
    color: #fff;
}

.apd-modal-footer .btn-primary:hover {
    background-color: #1e4a9e;
    color: #f1f1f1;
}

.apd-modal-footer .btn-secondary {
    background-color: #6c757d;
    color: #fff;
}

.apd-modal-footer .btn-secondary:hover {
    background-color: #565e64;
    color: #f1f1f1;
}

/* ─── Unified Toolbar Panel ──────────────────────────────────── */
.apd-toolbar {
    display: flex;
    flex-direction: column;
    margin: 12px auto 0;
    width: 100%;
    max-width: 500px;
    background: var(--apd-surface);
    border: 1px solid var(--apd-border);
    border-radius: var(--apd-radius-panel);
    overflow: hidden;
}

/* Row 1: Rotate buttons + AI buttons */
.apd-toolbar__actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    gap: 8px;
    flex-wrap: wrap;
}

/* Divider between sections */
.apd-toolbar__divider {
    height: 1px;
    background: var(--apd-border);
    margin: 0 12px;
}

/* Row 3: Color picker + Remove button */
.apd-toolbar__footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    gap: 12px;
}

/* ─── Rotate Buttons (inside toolbar — no card) ──────────────── */
.apd-button-container {
    display: flex;
    justify-content: center;
    gap: 4px;
    padding: 0;
    margin: 0;
    border: none;
    box-shadow: none;
    border-radius: 0;
}

#apd-control-buttons {
    display: flex;
    justify-content: center;
    margin: 0;
}

#apd-control-buttons svg {
    cursor: pointer;
    fill: var(--apd-muted);
    padding: 8px;
    min-width: 44px;
    min-height: 44px;
    box-sizing: border-box;
    border-radius: var(--apd-radius-btn);
    transition: fill 0.2s ease, background-color 0.2s ease;
}

#apd-control-buttons svg:hover {
    fill: var(--apd-primary);
    background-color: rgba(46, 107, 198, 0.08);
}

/* ─── AI Enhancement Bar (inside toolbar) ────────────────────── */
#apd-ai-bar {
    display: flex;
    justify-content: flex-end;
    gap: 6px;
    margin: 0;
    flex-wrap: wrap;
}

/* WCAG fix: #667eea (3.66:1) → #5a6fd6 (4.57:1) */
.apd-ai-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 12px;
    min-height: 36px;
    background: linear-gradient(135deg, var(--apd-ai-start) 0%, var(--apd-ai-end) 100%) !important;
    color: #fff !important;
    border: none !important;
    border-radius: var(--apd-radius-btn);
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
    box-sizing: border-box;
    white-space: nowrap;
    letter-spacing: 0.3px;
}

.apd-ai-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 3px 10px rgba(90, 111, 214, 0.35);
}

.apd-ai-btn:active {
    transform: translateY(0);
}

.apd-ai-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.apd-ai-btn svg {
    flex-shrink: 0;
}

.apd-ai-btn-undo {
    background: linear-gradient(135deg, #6c757d 0%, #495057 100%) !important;
}

.apd-ai-btn-undo:hover {
    box-shadow: 0 3px 10px rgba(108, 117, 125, 0.35);
}

/* ─── Scale Slider (inside toolbar) ──────────────────────────── */
#apd-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px 16px;
    width: 100%;
    box-sizing: border-box;
}

#apd-controls label.apd-toolbar__scale-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    font-size: 14px;
    color: var(--apd-text);
    font-weight: 600;
    margin-bottom: 6px;
}

#apd-controls label.apd-toolbar__scale-label span {
    font-weight: 500;
    font-size: 14px;
    color: var(--apd-primary);
}

#apd-controls input[type="range"] {
    width: 100%;
    -webkit-appearance: none;
    appearance: none;
    height: 6px;
    border-radius: 3px;
    background: var(--apd-border);
    outline: none;
    transition: background 0.3s ease;
    margin: 0;
}

#apd-controls input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--apd-primary);
    border: 3px solid #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    transition: background 0.2s ease, box-shadow 0.2s ease;
}

#apd-controls input[type="range"]::-webkit-slider-thumb:hover {
    background: var(--apd-primary-hover);
    box-shadow: 0 2px 6px rgba(46, 107, 198, 0.35);
}

#apd-controls input[type="range"]::-moz-range-thumb {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--apd-primary);
    border: 3px solid #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    cursor: pointer;
}

/* ─── Color Picker (inline in footer) ────────────────────────── */
#apd-color-picker-container,
#apd-color-picker-container-mobile {
    display: none;
    align-items: center;
    gap: 8px;
}

#apd-color-picker-container label,
#apd-color-picker-container-mobile label {
    font-size: 14px;
    font-weight: 600;
    color: var(--apd-text);
    white-space: nowrap;
}

/* WCAG fix: border #ccc (1.6:1) → #6b7280 (4.83:1) */
input[type="color"] {
    -webkit-appearance: none;
    width: 44px;
    height: 44px;
    cursor: pointer;
    border: 2px solid var(--apd-muted);
    border-radius: var(--apd-radius-btn);
    background-color: #fff;
    padding: 3px;
    transition: box-shadow 0.3s ease, border-color 0.2s ease;
}

input[type="color"]:hover {
    border-color: var(--apd-primary);
}

input[type="color"]:focus {
    outline: none;
    border-color: var(--apd-primary);
    box-shadow: 0 0 0 3px rgba(46, 107, 198, 0.25);
}

/* ─── Remove Image Button (WCAG fix: #6c757d80 → #c0392b) ──── */
#apd-remove-image {
    display: none;
    padding: 8px 16px;
    min-height: 40px;
    background-color: var(--apd-danger);
    color: #fff;
    border: none;
    border-radius: var(--apd-radius-btn);
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    box-sizing: border-box;
    transition: background-color 0.2s ease, box-shadow 0.2s ease;
    white-space: nowrap;
    margin-left: auto;
}

#apd-remove-image:hover {
    background-color: var(--apd-danger-hover);
    box-shadow: 0 2px 8px rgba(192, 57, 43, 0.3);
}

#apd-remove-image:focus-visible {
    outline: 3px solid rgba(192, 57, 43, 0.5);
    outline-offset: 2px;
}

#apd-remove-image::after {
    content: '\2715';
    margin-left: 8px;
    font-size: 14px;
}

/* ─── Visually Hidden (rotation slider kept in DOM for JS) ──── */
.apd-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ─── Gesture Hint Overlay ───────────────────────────────────── */
.apd-gesture-hint {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.8);
    color: #fff;
    padding: 10px 18px;
    border-radius: 8px;
    font-size: 13px;
    text-align: center;
    z-index: 200;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    line-height: 1.4;
}

.apd-gesture-hint.apd-gesture-hint-visible {
    opacity: 1;
}

.apd-gesture-hint-icon {
    display: block;
    font-size: 22px;
    margin-bottom: 4px;
}

/* ─── Gesture Feedback Overlay ───────────────────────────────── */
.apd-gesture-feedback {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(0, 0, 0, 0.75);
    color: #fff;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    font-family: 'Roboto', -apple-system, BlinkMacSystemFont, sans-serif;
    z-index: 200;
    pointer-events: none;
    opacity: 0;
    transform: translateY(-4px);
    transition: opacity 0.2s ease, transform 0.2s ease;
    white-space: nowrap;
    letter-spacing: 0.3px;
    line-height: 1.4;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.apd-gesture-feedback.apd-feedback-visible {
    opacity: 1;
    transform: translateY(0);
}

/* ─── Mobile Styles ──────────────────────────────────────────── */
@media (max-width: 768px) {
    /* Sliders hidden on mobile — gestures replace them */
    #apd-controls {
        display: none !important;
    }

    /* Desktop color picker hidden on mobile */
    #apd-color-picker-container {
        display: none !important;
    }

    /* Toolbar: stack actions vertically */
    .apd-toolbar__actions {
        flex-direction: column;
        align-items: stretch;
        gap: 6px;
    }

    #apd-control-buttons {
        justify-content: center;
    }

    #apd-ai-bar {
        justify-content: center;
    }

    .apd-ai-btn {
        flex: 1;
        justify-content: center;
        min-height: 44px;
        font-size: 13px;
    }

    /* Footer: stack on mobile */
    .apd-toolbar__footer {
        flex-direction: column;
        align-items: center;
        gap: 8px;
    }

    #apd-color-picker-container-mobile {
        display: flex;
        align-items: center;
        gap: 8px;
    }

    #apd-remove-image {
        width: 100%;
        max-width: 280px;
        text-align: center;
        margin-left: 0;
    }

    /* Hide dividers between hidden sections */
    .apd-toolbar__divider:nth-of-type(1) {
        display: block;
    }

    /* Hide second divider (before hidden sliders) */
    .apd-toolbar__divider:nth-of-type(2) {
        display: none;
    }

    .apd-drag-hint {
        display: none;
    }

    .apd-upload-label-desktop {
        display: none;
    }

    .apd-upload-label-mobile {
        display: inline-block;
    }
}

/* ─── Desktop: Side Panel Layout (1245px+) ─────────────────────
 * Controls beside canvas instead of below.
 * Canvas stays ~380px, toolbar becomes 200px sticky side panel.
 * Total ~592px of the ~599px+ WoodMart column at 1245px viewport.
 * Below 1245px, floating bar is used instead (see next section).
 * ──────────────────────────────────────────────────────────── */
@media (min-width: 1245px) {

    /* Container: flex row, wrap only for holiday notice */
    #apd-case-designer-container {
        display: flex;
        flex-direction: row;
        flex-wrap: wrap;
        align-items: flex-start;
        gap: var(--apd-panel-gap);
        max-width: 100%;
        margin: 0;
        text-align: left;
    }

    /* Holiday notice: full width above canvas+panel when active */
    .apd-holiday-notice {
        flex: 0 0 100%;
        width: 100%;
    }

    /* Canvas: flex-basis 0 so it shrinks before wrapping */
    #apd-canvas-area {
        flex: 1 1 0;
        max-width: 380px;
        min-width: 250px;
        width: auto;
        margin: 0;
    }

    /* Toolbar: sticky side panel */
    .apd-toolbar {
        flex: 0 0 var(--apd-panel-width);
        width: var(--apd-panel-width);
        max-width: var(--apd-panel-width);
        flex-direction: column;
        margin: 0;
        position: sticky;
        top: 100px;
        align-self: flex-start;
        background: #fff;
        border: 1px solid var(--apd-border);
        border-radius: var(--apd-radius-panel);
        box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
        overflow: hidden;
        animation: apd-panel-in 0.3s ease-out;
    }

    @keyframes apd-panel-in {
        from { opacity: 0; transform: translateX(10px); }
        to { opacity: 1; transform: translateX(0); }
    }

    /* Actions row: stack vertically in narrow panel */
    .apd-toolbar__actions {
        flex-direction: column;
        align-items: stretch;
        padding: 10px;
        gap: 6px;
    }

    /* Rotate buttons: centered row */
    #apd-control-buttons {
        justify-content: center;
    }

    .apd-button-container {
        gap: 2px;
    }

    #apd-control-buttons svg {
        min-width: 38px;
        min-height: 38px;
        padding: 7px;
    }

    /* AI buttons: stack vertically, full width */
    #apd-ai-bar {
        flex-direction: column;
        gap: 4px;
        justify-content: stretch;
    }

    .apd-ai-btn {
        display: flex;
        font-size: 11px;
        padding: 6px 8px;
        min-height: 32px;
        justify-content: center;
        width: 100%;
        max-width: 100%;
        white-space: nowrap;
        box-sizing: border-box;
    }

    .apd-ai-btn svg {
        width: 14px;
        height: 14px;
    }

    /* Dividers: span full panel width */
    .apd-toolbar__divider {
        margin: 0;
    }

    /* Scale slider: vertical layout */
    #apd-controls {
        padding: 10px;
    }

    #apd-controls label.apd-toolbar__scale-label {
        flex-direction: column;
        align-items: flex-start;
        gap: 2px;
        font-size: var(--apd-label-size);
        text-transform: uppercase;
        letter-spacing: 0.5px;
        color: var(--apd-muted);
    }

    #apd-controls label.apd-toolbar__scale-label span {
        font-size: 14px;
        font-weight: 700;
        color: var(--apd-primary);
        text-transform: none;
        letter-spacing: 0;
    }

    #apd-controls input[type="range"]::-webkit-slider-thumb {
        width: 18px;
        height: 18px;
        border-width: 2px;
    }

    #apd-controls input[type="range"]::-moz-range-thumb {
        width: 18px;
        height: 18px;
        border-width: 2px;
    }

    /* Rotation slider: unhide on desktop, match scale slider */
    .apd-rotation-section.apd-sr-only {
        position: static;
        width: auto;
        height: auto;
        padding: 10px 0 0;
        margin: 8px 0 0;
        overflow: visible;
        clip: auto;
        clip-path: none;
        white-space: normal;
        border-top: 1px solid var(--apd-border);
    }

    .apd-rotation-section label.apd-toolbar__scale-label {
        flex-direction: column;
        align-items: flex-start;
        gap: 2px;
        font-size: var(--apd-label-size);
        text-transform: uppercase;
        letter-spacing: 0.5px;
        color: var(--apd-muted);
    }

    .apd-rotation-section label.apd-toolbar__scale-label span {
        font-size: 14px;
        font-weight: 700;
        color: var(--apd-primary);
        text-transform: none;
        letter-spacing: 0;
    }

    .apd-rotation-section input[type="range"] {
        width: 100%;
        margin: 0;
    }

    /* Footer: stack vertically */
    .apd-toolbar__footer {
        flex-direction: column;
        align-items: stretch;
        padding: 10px;
        gap: 8px;
    }

    #apd-color-picker-container label {
        font-size: var(--apd-label-size);
        text-transform: uppercase;
        letter-spacing: 0.5px;
        color: var(--apd-muted);
    }

    input[type="color"] {
        width: 36px;
        height: 36px;
    }

    /* Remove button: full width, compact */
    #apd-remove-image {
        width: 100%;
        font-size: 12px;
        padding: 6px 10px;
        min-height: 34px;
        margin-left: 0;
        text-align: center;
    }

    #apd-remove-image::after {
        font-size: 12px;
        margin-left: 4px;
    }
}

/* ─── Floating Bottom Toolbar (769px–1244px) ───────────────────
 * Covers both tablet (769–1023px where WoodMart stacks columns)
 * and narrow desktop (1024–1244px where columns are too tight
 * for side panel). Two-row layout with glass morphism.
 * Row 1: Rotate + AI buttons (centered)
 * Row 2: Scale slider + Color + Remove button
 * ──────────────────────────────────────────────────────────── */
@media (min-width: 769px) and (max-width: 1244px) {

    /* Container: block centered */
    #apd-case-designer-container {
        display: block;
        max-width: min(500px, 95vw);
        margin: auto;
    }

    /* Toolbar: fixed bottom floating bar */
    .apd-toolbar {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 350;
        margin: 0;
        max-width: 100%;
        border-radius: 12px 12px 0 0;
        background: var(--apd-float-bg);
        backdrop-filter: blur(var(--apd-float-blur));
        -webkit-backdrop-filter: blur(var(--apd-float-blur));
        box-shadow: var(--apd-float-shadow);
        border: none;
        border-top: 1px solid var(--apd-border);
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        justify-content: center;
        padding: 10px 20px;
        gap: 6px 12px;
        animation: apd-float-up 0.35s ease-out;
    }

    @keyframes apd-float-up {
        from { opacity: 0; transform: translateY(100%); }
        to { opacity: 1; transform: translateY(0); }
    }

    /* Hide dividers in floating bar */
    .apd-toolbar__divider {
        display: none;
    }

    /* ── Row 1: Actions (rotate + AI) ── */
    .apd-toolbar__actions {
        flex: 1 0 100%;
        flex-direction: row;
        flex-wrap: nowrap;
        justify-content: center;
        align-items: center;
        padding: 0;
        gap: 8px;
    }

    #apd-control-buttons {
        justify-content: center;
    }

    #apd-control-buttons svg {
        min-width: 36px;
        min-height: 36px;
        padding: 6px;
    }

    .apd-button-container {
        gap: 2px;
    }

    /* AI buttons: side by side */
    #apd-ai-bar {
        flex-direction: row;
        gap: 6px;
        flex-shrink: 0;
    }

    .apd-ai-btn {
        font-size: 12px;
        padding: 7px 14px;
        min-height: 36px;
        white-space: nowrap;
    }

    /* ── Row 2: Slider + Color + Remove ── */
    #apd-controls {
        flex: 1 1 auto;
        width: auto;
        min-width: 150px;
        padding: 0;
        flex-direction: row;
        align-items: center;
        gap: 8px;
    }

    #apd-controls label.apd-toolbar__scale-label {
        width: auto;
        justify-content: flex-start;
        font-size: 12px;
        margin-bottom: 0;
        white-space: nowrap;
        flex-shrink: 0;
        flex-direction: row;
        gap: 6px;
    }

    #apd-controls label.apd-toolbar__scale-label span {
        font-size: 13px;
        font-weight: 600;
    }

    #apd-controls input[type="range"] {
        flex: 1;
        width: auto;
        min-width: 80px;
    }

    /* Footer: color + remove inline */
    .apd-toolbar__footer {
        flex-direction: row;
        align-items: center;
        padding: 0;
        gap: 8px;
        flex-shrink: 0;
    }

    #apd-color-picker-container {
        flex-direction: row;
        align-items: center;
        gap: 6px;
    }

    #apd-color-picker-container label {
        font-size: 12px;
        white-space: nowrap;
    }

    input[type="color"] {
        width: 32px;
        height: 32px;
    }

    #apd-remove-image {
        font-size: 12px;
        padding: 7px 12px;
        min-height: 36px;
        margin-left: 0;
        white-space: nowrap;
    }

    #apd-remove-image::after {
        font-size: 12px;
        margin-left: 4px;
    }

    /* Space for floating bar so content isn't covered */
    #apd-case-designer-container {
        padding-bottom: 110px;
    }
}
