/**
 * Loview Reel Builder - Editor Styles
 * Version 2.0 - New Layout with Frames at Top
 *
 * @package Loview_Reel_Builder
 * @since 2.0.0
 */

/* =====================================================
   CSS Variables
   ===================================================== */
:root {
    --reel-primary: #ff6900;
    --reel-primary-hover: #e55d00;
    --reel-primary-light: rgba(255, 105, 0, 0.1);
    --reel-secondary: #333333;
    --reel-secondary-hover: #555555;
    --reel-danger: #dc3545;
    --reel-danger-hover: #c82333;
    --reel-success: #28a745;
    --reel-background: #f8f7f5;
    --reel-panel-bg: #ffffff;
    --reel-border: #e0dcd5;
    --reel-text: #333333;
    --reel-text-muted: #666666;
    --reel-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    --reel-shadow-hover: 0 4px 16px rgba(0, 0, 0, 0.12);
    --reel-radius: 12px;
    --reel-radius-sm: 6px;
    --reel-transition: 0.2s ease;
}

/* =====================================================
   Main Editor Container
   ===================================================== */
.brandname-reel-editor {
    margin: 20px 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    max-width: 100%;
}

/* =====================================================
   Frame Selector - NOW AT TOP
   ===================================================== */
.reel-frames-container {
    background: var(--reel-panel-bg);
    border-radius: var(--reel-radius);
    padding: 16px 20px;
    margin-bottom: 16px;
    box-shadow: var(--reel-shadow);
    border: 1px solid var(--reel-border);
}

.reel-frames-header {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 12px;
}

.reel-frames-row {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding: 8px 0;
    -webkit-overflow-scrolling: touch;
}

.reel-frames-hint {
    text-align: center;
    font-size: 12px;
    color: var(--reel-text-muted);
    margin-top: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.hint-icon {
    font-size: 14px;
}

/* Frame Cards */
.reel-frame {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    transition: transform var(--reel-transition);
    flex-shrink: 0;
    user-select: none;
}

.reel-frame:hover {
    transform: translateY(-3px);
}

.reel-frame.sortable-ghost {
    opacity: 0.4;
}

.reel-frame.sortable-chosen {
    transform: scale(1.05);
}

.reel-frame-inner {
    position: relative;
    width: 80px;
    height: 80px;
    border: 3px solid var(--reel-border);
    border-radius: var(--reel-radius-sm);
    overflow: hidden;
    transition: all var(--reel-transition);
    background-color: #d0d0d0;
    background-image:
        linear-gradient(45deg, #b8b8b8 25%, transparent 25%),
        linear-gradient(-45deg, #b8b8b8 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #b8b8b8 75%),
        linear-gradient(-45deg, transparent 75%, #b8b8b8 75%);
    background-size: 10px 10px;
    background-position: 0 0, 0 5px, 5px -5px, -5px 0;
}

.reel-frame.selected .reel-frame-inner {
    border-color: var(--reel-primary);
    box-shadow: 0 0 0 3px var(--reel-primary-light);
}

.reel-frame.completed .reel-frame-inner {
    border-color: var(--reel-success);
}

.reel-frame-preview {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.reel-frame-thumbnail {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.reel-frame-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--reel-text-muted);
    text-align: center;
    padding: 6px;
}

.reel-frame-plus {
    font-size: 22px;
    font-weight: bold;
    color: var(--reel-primary);
    line-height: 1;
}

.reel-frame-upload-text {
    font-size: 9px;
    margin-top: 3px;
    line-height: 1.2;
}

.reel-frame-remove {
    position: absolute;
    top: 3px;
    right: 3px;
    width: 20px;
    height: 20px;
    background: var(--reel-danger);
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 13px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform var(--reel-transition);
    line-height: 1;
    z-index: 5;
}

.reel-frame-remove:hover {
    transform: scale(1.15);
}

.reel-frame-drag-handle {
    position: absolute;
    bottom: 3px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 10px;
    color: rgba(0, 0, 0, 0.3);
    cursor: grab;
    padding: 2px 4px;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 3px;
    opacity: 0;
    transition: opacity var(--reel-transition);
}

.reel-frame:hover .reel-frame-drag-handle {
    opacity: 1;
}

.reel-frame-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--reel-text);
    margin-top: 6px;
}

.reel-frame.selected .reel-frame-label {
    color: var(--reel-primary);
}

.reel-frame-status {
    font-size: 10px;
    color: var(--reel-text-muted);
    margin-top: 2px;
    height: 14px;
}

.reel-frame.completed .reel-frame-status::after {
    content: "✓";
    color: var(--reel-success);
    font-weight: bold;
}

/* =====================================================
   Main Editor Container - Horizontal Layout
   ===================================================== */
.reel-editor-container {
    display: flex;
    gap: 16px;
    background: var(--reel-background);
    border-radius: var(--reel-radius);
    padding: 16px;
    border: 1px solid var(--reel-border);
    min-height: 400px;
}

/* =====================================================
   Options Panel
   ===================================================== */
.reel-options-panel {
    width: 260px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.reel-options-section {
    background: var(--reel-panel-bg);
    border-radius: var(--reel-radius-sm);
    overflow: hidden;
    box-shadow: var(--reel-shadow);
}

.reel-options-title {
    font-size: 11px;
    font-weight: 700;
    color: var(--reel-text);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0;
    padding: 12px 14px;
    background: linear-gradient(135deg, var(--reel-primary-light), transparent);
    border-bottom: 2px solid var(--reel-primary);
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
}

.reel-section-toggle .toggle-icon {
    font-size: 10px;
    transition: transform var(--reel-transition);
}

.reel-section-collapsible.collapsed .toggle-icon {
    transform: rotate(-90deg);
}

.reel-section-content {
    padding: 14px;
    transition: max-height 0.3s ease, padding 0.3s ease;
    overflow: hidden;
}

.reel-section-collapsible.collapsed .reel-section-content {
    max-height: 0;
    padding: 0 14px;
}

.reel-option-group {
    margin-bottom: 14px;
}

.reel-option-group:last-child {
    margin-bottom: 0;
}

.reel-option-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    font-weight: 500;
    color: var(--reel-text);
    margin-bottom: 6px;
}

.reel-slider-value {
    font-size: 11px;
    font-weight: 600;
    color: var(--reel-primary);
    background: var(--reel-primary-light);
    padding: 2px 6px;
    border-radius: var(--reel-radius-sm);
}

.reel-options-actions {
    padding: 14px;
}

/* =====================================================
   Buttons
   ===================================================== */
.reel-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 14px;
    font-size: 13px;
    font-weight: 600;
    border: none;
    border-radius: var(--reel-radius-sm);
    cursor: pointer;
    transition: all var(--reel-transition);
    width: 100%;
}

.reel-btn-icon {
    font-size: 16px;
}

.reel-btn-primary {
    background: var(--reel-primary);
    color: white;
}

.reel-btn-primary:hover {
    background: var(--reel-primary-hover);
    transform: translateY(-1px);
}

.reel-btn-secondary {
    background: var(--reel-secondary);
    color: white;
    margin-top: 8px;
}

.reel-btn-secondary:hover {
    background: var(--reel-secondary-hover);
}

.reel-btn-outline {
    background: transparent;
    color: var(--reel-primary);
    border: 2px solid var(--reel-primary);
    width: auto;
    padding: 8px 16px;
}

.reel-btn-outline:hover {
    background: var(--reel-primary);
    color: white;
}

.reel-btn-danger {
    background: var(--reel-danger);
    color: white;
}

.reel-btn-danger:hover {
    background: var(--reel-danger-hover);
}

/* =====================================================
   Filter Buttons
   ===================================================== */
.reel-filter-buttons {
    display: flex;
    gap: 6px;
}

.reel-filter-btn {
    flex: 1;
    padding: 7px 10px;
    font-size: 11px;
    font-weight: 500;
    background: #f5f5f5;
    border: 2px solid transparent;
    border-radius: var(--reel-radius-sm);
    cursor: pointer;
    transition: all var(--reel-transition);
}

.reel-filter-btn:hover {
    background: #ebebeb;
}

.reel-filter-btn.active {
    background: var(--reel-primary-light);
    border-color: var(--reel-primary);
    color: var(--reel-primary);
}

/* =====================================================
   Sliders
   ===================================================== */
.reel-slider {
    width: 100%;
    height: 5px;
    -webkit-appearance: none;
    appearance: none;
    background: #e0e0e0;
    border-radius: 3px;
    outline: none;
}

.reel-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    background: var(--reel-primary);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(255, 105, 0, 0.3);
    transition: transform var(--reel-transition);
}

.reel-slider::-webkit-slider-thumb:hover {
    transform: scale(1.1);
}

.reel-slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    background: var(--reel-primary);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(255, 105, 0, 0.3);
}

/* =====================================================
   Text Input & Select
   ===================================================== */
.reel-text-field {
    width: 100%;
    padding: 9px 11px;
    font-size: 13px;
    border: 2px solid var(--reel-border);
    border-radius: var(--reel-radius-sm);
    transition: border-color var(--reel-transition);
    box-sizing: border-box;
}

.reel-text-field:focus {
    outline: none;
    border-color: var(--reel-primary);
}

.reel-select {
    width: 100%;
    padding: 9px 11px;
    font-size: 13px;
    border: 2px solid var(--reel-border);
    border-radius: var(--reel-radius-sm);
    background: white;
    cursor: pointer;
    transition: border-color var(--reel-transition);
}

.reel-select:focus {
    outline: none;
    border-color: var(--reel-primary);
}

/* =====================================================
   Color Palette
   ===================================================== */
.reel-color-palette {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.reel-color-btn {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 2px solid #ddd;
    cursor: pointer;
    transition: all var(--reel-transition);
}

.reel-color-btn:hover {
    transform: scale(1.15);
}

.reel-color-btn.active {
    border-color: var(--reel-primary);
    box-shadow: 0 0 0 2px var(--reel-primary-light);
}

.reel-color-btn[data-color="#ffffff"] {
    border-color: #ccc;
}

/* =====================================================
   Canvas Area
   ===================================================== */
.reel-canvas-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--reel-panel-bg);
    border-radius: var(--reel-radius-sm);
    padding: 16px;
    box-shadow: var(--reel-shadow);
    min-height: 380px;
}

/* Format guide (example images above canvas warning) */
.reel-format-guide {
    width: 100%;
    max-width: 450px;
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: center;
    gap: 12px 16px;
    margin-bottom: 12px;
}

.reel-format-guide__item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    max-width: 100%;
}

.reel-format-guide__frame {
    width: var(--fg-w, 11mm);
    height: var(--fg-h, 10mm);
    box-sizing: border-box;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(0, 0, 0, 0.12);
    border-radius: var(--reel-radius-sm, 4px);
    background-color: #e8e8e8;
    background-image:
        linear-gradient(45deg, #ccc 25%, transparent 25%),
        linear-gradient(-45deg, #ccc 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #ccc 75%),
        linear-gradient(-45deg, transparent 75%, #ccc 75%);
    background-size: 8px 8px;
    background-position: 0 0, 0 4px, 4px -4px, -4px 0;
}

.reel-format-guide__img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    vertical-align: middle;
    display: block;
}

.reel-format-guide__caption {
    font-size: 11px;
    line-height: 1.3;
    color: var(--reel-text-muted, #666);
    text-align: center;
    max-width: 120px;
}

@media screen and (max-width: 600px) {
    .reel-format-guide {
        gap: 10px 12px;
        margin-bottom: 10px;
    }

    .reel-format-guide__caption {
        font-size: 10px;
        max-width: 100px;
    }
}

/* FEATURE 2: Canvas Warning Text */
.reel-canvas-warning {
    width: 100%;
    max-width: 450px;
    background: linear-gradient(135deg, #fff8e1 0%, #ffecb3 100%);
    border: 1px solid #ffc107;
    border-radius: var(--reel-radius-sm);
    padding: 12px 16px;
    margin-bottom: 12px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    box-shadow: 0 2px 4px rgba(255, 193, 7, 0.2);
}

.reel-canvas-warning .warning-icon {
    font-size: 18px;
    flex-shrink: 0;
    line-height: 1.4;
}

.reel-canvas-warning .warning-text {
    font-size: 13px;
    color: #856404;
    line-height: 1.5;
}

@media screen and (max-width: 600px) {
    .reel-canvas-warning {
        padding: 10px 12px;
        margin-bottom: 10px;
    }
    
    .reel-canvas-warning .warning-icon {
        font-size: 16px;
    }
    
    .reel-canvas-warning .warning-text {
        font-size: 12px;
    }
}

.reel-canvas-wrapper {
    position: relative;
    width: 100%;
    max-width: 450px;
    /* PROBLEM 1 FIX: Use CSS variable for aspect ratio, set from PHP (canvas_width / canvas_height) */
    aspect-ratio: var(--reel-canvas-aspect-ratio, 92 / 81);
    /* Checkerboard so transparent PNG areas are visible */
    background-color: #d0d0d0;
    background-image:
        linear-gradient(45deg, #b8b8b8 25%, transparent 25%),
        linear-gradient(-45deg, #b8b8b8 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #b8b8b8 75%),
        linear-gradient(-45deg, transparent 75%, #b8b8b8 75%);
    background-size: 12px 12px;
    background-position: 0 0, 0 6px, 6px -6px, -6px 0;
    border-radius: var(--reel-radius-sm);
    overflow: hidden;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.1);
    transition: border-color var(--reel-transition), box-shadow var(--reel-transition);
}

/* REQ 9 - Orange border when frame is selected */
.reel-canvas-wrapper.frame-selected {
    border: 3px solid var(--reel-primary);
    border-radius: 8px;
    box-shadow: 0 0 0 4px rgba(255, 105, 0, 0.2), var(--reel-shadow);
}

/* Alternative: Add border when canvas has content */
.brandname-reel-editor.has-selection .reel-canvas-wrapper {
    border: 3px solid var(--reel-primary);
    border-radius: 8px;
    box-shadow: 0 0 0 4px rgba(255, 105, 0, 0.2);
}

.reel-canvas-wrapper canvas {
    display: block;
}

.reel-canvas-placeholder {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f9f9f9;
    color: var(--reel-text-muted);
    font-size: 15px;
    text-align: center;
    padding: 20px;
}

.reel-canvas-placeholder.hidden {
    display: none;
}

/* =====================================================
   Validation Message
   ===================================================== */
.reel-validation-message {
    margin-top: 12px;
    padding: 12px 16px;
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: var(--reel-radius-sm);
    color: #856404;
    font-size: 14px;
    text-align: center;
}

/* =====================================================
   Add to Cart Button Overlay
   ===================================================== */
.single_add_to_cart_button.reel-disabled {
    opacity: 0.5;
    pointer-events: none;
    cursor: not-allowed;
}

/* =====================================================
   TEMPLATE VARIATIONS
   ===================================================== */

/* Template A: Tools Left (Default) */
.template-a .reel-editor-container {
    flex-direction: row;
}

.template-a .reel-options-panel {
    order: 1;
}

.template-a .reel-canvas-area {
    order: 2;
}

/* Template B: Tools Right */
.template-b .reel-editor-container {
    flex-direction: row;
}

.template-b .reel-options-panel {
    order: 2;
}

.template-b .reel-canvas-area {
    order: 1;
}

/* Template C: Compact */
.template-c .reel-options-panel {
    width: 220px;
}

.template-c .reel-options-title {
    font-size: 10px;
    padding: 10px 12px;
}

.template-c .reel-section-content {
    padding: 10px;
}

.template-c .reel-option-group {
    margin-bottom: 10px;
}

.template-c .reel-btn {
    padding: 8px 12px;
    font-size: 12px;
}

.template-c .reel-frame-inner {
    width: 65px;
    height: 65px;
}

/* =====================================================
   Responsive Styles
   ===================================================== */
@media screen and (max-width: 900px) {
    .reel-editor-container {
        flex-direction: column !important;
    }

    .reel-options-panel {
        width: 100% !important;
        order: 2 !important;
        flex-direction: row;
        flex-wrap: wrap;
    }

    .reel-options-section {
        flex: 1;
        min-width: 200px;
    }

    .reel-canvas-area {
        order: 1 !important;
        min-height: 300px;
    }
}

@media screen and (max-width: 600px) {
    .brandname-reel-editor {
        margin: 10px 0;
    }

    .reel-frames-container {
        padding: 12px 8px;
    }

    .reel-frames-header {
        justify-content: center;
        flex-wrap: wrap;
        gap: 8px;
        margin-bottom: 10px;
    }

    /* TASK 6: Use WRAP layout instead of scroll on mobile */
    .reel-frames-row {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: 10px;
        padding: 8px 0;
        /* Remove horizontal scroll */
        overflow: visible;
    }

    /* TASK 6: Allow frames to wrap naturally */
    .reel-frame {
        flex: 0 0 auto;
        /* Calculated to fit ~4 frames per row with gap on small screens */
        width: calc(25% - 10px);
        min-width: 65px;
        max-width: 80px;
    }

    .reel-frame-inner {
        width: 100%;
        height: 0;
        padding-bottom: 100%; /* Square aspect ratio */
        position: relative;
    }

    .reel-frame-preview {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
    }

    .reel-frame-thumbnail {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        object-fit: cover;
    }

    .reel-frame-empty {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
    }

    .reel-frame-remove {
        position: absolute;
        top: 2px;
        right: 2px;
        width: 18px;
        height: 18px;
        font-size: 11px;
        z-index: 10;
    }

    .reel-frame-plus {
        font-size: 20px;
    }

    .reel-frame-upload-text {
        display: none;
    }

    .reel-frame-label {
        font-size: 10px;
        text-align: center;
        margin-top: 4px;
    }

    .reel-editor-container {
        padding: 12px;
    }

    .reel-options-panel {
        flex-direction: column;
    }

    .reel-options-section {
        min-width: 100%;
    }

    /* Collapse sections by default on mobile */
    .reel-section-collapsible .reel-section-content {
        max-height: 0;
        padding: 0 14px;
    }

    .reel-section-collapsible.expanded .reel-section-content {
        max-height: 1000px;
        padding: 14px;
    }

    .reel-canvas-area {
        min-height: 280px;
        padding: 12px;
    }

    .reel-canvas-wrapper {
        max-width: 100%;
    }
}

@media screen and (max-width: 400px) {
    /* TASK 6: Smaller frames on very small screens, still wrapped */
    .reel-frame {
        width: calc(25% - 6px);
        min-width: 55px;
        max-width: 65px;
    }

    .reel-frames-row {
        gap: 6px;
        padding: 6px 2px;
    }

    .reel-frame-label {
        font-size: 9px;
    }

    .reel-frame-plus {
        font-size: 16px;
    }

    .reel-btn-outline {
        font-size: 10px;
        padding: 5px 8px;
    }

    .reel-frames-hint {
        font-size: 9px;
    }

    .reel-frames-header {
        gap: 6px;
    }

    #reel-clear-all,
    #reel-bulk-upload {
        font-size: 9px;
        padding: 5px 6px;
    }
}

/* =====================================================
   Loading States
   ===================================================== */
.reel-loading {
    position: relative;
    pointer-events: none;
}

.reel-loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 24px;
    height: 24px;
    margin: -12px 0 0 -12px;
    border: 3px solid var(--reel-primary-light);
    border-top-color: var(--reel-primary);
    border-radius: 50%;
    animation: reel-spin 0.8s linear infinite;
}

@keyframes reel-spin {
    to {
        transform: rotate(360deg);
    }
}

/* =====================================================
   Admin Styles
   ===================================================== */
.brandname-reel-admin-panel {
    background: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 15px;
    margin-top: 15px;
}

.reel-admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    flex-wrap: wrap;
    gap: 8px;
}

.reel-token-display {
    font-size: 12px;
    color: #666;
}

.reel-token-display code {
    background: #fff;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 11px;
}

.reel-admin-thumbnails {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 15px;
}

.reel-admin-thumb {
    position: relative;
    width: 60px;
    height: 60px;
    border-radius: 4px;
    overflow: hidden;
    border: 1px solid #ddd;
}

.reel-admin-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.reel-admin-thumb-label {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    font-size: 10px;
    text-align: center;
    padding: 2px;
}

.reel-admin-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.reel-admin-actions .button {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.reel-admin-actions .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
}

.reel-admin-notice {
    padding: 10px;
    border-radius: 4px;
}

.reel-admin-notice-warning {
    background: #fff3cd;
    border: 1px solid #ffc107;
    color: #856404;
}

.reel-meta-box-content {
    margin: 0;
}

.reel-meta-item {
    padding: 8px 0;
    border-bottom: 1px solid #eee;
}

.reel-meta-item:last-child {
    border-bottom: none;
}

/* =====================================================
   Fabric.js Overrides
   ===================================================== */
.canvas-container {
    margin: 0 auto;
}

.upper-canvas {
    cursor: move !important;
}

/* =====================================================
   TASK 9: Toast Notifications - Stackable
   Multiple toasts can appear simultaneously
   Each toast has its own position and disappears independently
   ===================================================== */
.reel-toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 12px 20px;
    background: var(--reel-secondary);
    color: white;
    border-radius: var(--reel-radius-sm);
    box-shadow: var(--reel-shadow-hover);
    z-index: 9999;
    animation: toastSlideIn 0.3s ease;
    /* TASK 9: Add transition for smooth repositioning */
    transition: bottom 0.3s ease;
    max-width: 300px;
    word-wrap: break-word;
}

.reel-toast.success {
    background: var(--reel-success);
}

.reel-toast.error {
    background: var(--reel-danger);
}

.reel-toast.warning {
    background: #ffb900;
    color: #333;
}

.reel-toast.info {
    background: #0073aa;
}

/* TASK 9: Renamed animation to avoid conflicts */
@keyframes toastSlideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* =====================================================
   TASK 5: Mobile Bottom Sheet UI
   Swipeable bottom sheet for editing tools on mobile
   ===================================================== */
@media screen and (max-width: 600px) {
    /* Bottom sheet container */
    .reel-bottom-sheet {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: var(--reel-panel-bg);
        border-radius: 20px 20px 0 0;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
        z-index: 1000;
        transition: transform 0.3s ease;
        max-height: 33vh;
        overflow-y: auto;
    }

    /* Collapsed state - show only handle */
    .reel-bottom-sheet.collapsed {
        transform: translateY(calc(100% - 50px));
    }

    /* Expanded state - show full content */
    .reel-bottom-sheet.expanded {
        transform: translateY(0);
    }

    /* Handle bar for dragging */
    .reel-bottom-sheet-handle {
        display: flex;
        flex-direction: column;
        align-items: center;
        padding: 12px 20px;
        cursor: pointer;
        background: linear-gradient(135deg, var(--reel-primary-light), #fff);
        border-bottom: 1px solid var(--reel-border);
        position: sticky;
        top: 0;
        z-index: 10;
    }

    .reel-bottom-sheet-handle .handle-bar {
        width: 40px;
        height: 4px;
        background: var(--reel-border);
        border-radius: 2px;
        margin-bottom: 8px;
    }

    .reel-bottom-sheet-handle .handle-text {
        font-size: 12px;
        font-weight: 600;
        color: var(--reel-primary);
        text-transform: uppercase;
        letter-spacing: 0.5px;
    }

    /* Options panel inside bottom sheet */
    .reel-bottom-sheet .reel-options-panel {
        width: 100% !important;
        padding: 12px;
        flex-direction: column;
    }

    /* Hide original options panel placement */
    .reel-editor-container .reel-options-panel:not(.reel-bottom-sheet .reel-options-panel) {
        display: none;
    }

    /* Adjust canvas area when bottom sheet exists */
    .brandname-reel-editor:has(.reel-bottom-sheet) .reel-canvas-area {
        padding-bottom: 60px;
    }
}

/* =====================================================
   TEST 1: Clear All Button
   ===================================================== */
.reel-frames-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    gap: 10px;
}

#reel-clear-all {
    background: transparent;
    color: var(--reel-danger);
    border: 2px solid var(--reel-danger);
    width: auto;
    padding: 8px 16px;
    font-size: 12px;
}

#reel-clear-all:hover {
    background: var(--reel-danger);
    color: white;
}

/* =====================================================
   TEST 2: Crop Tool Styles
   ===================================================== */
#reel-crop-tool {
    background: linear-gradient(135deg, #4a4a4a, #333);
    color: white;
    margin-top: 10px;
}

#reel-crop-tool:hover {
    background: linear-gradient(135deg, #5a5a5a, #444);
}

#reel-crop-buttons {
    display: none;
    gap: 8px;
    margin-top: 10px;
}

#reel-crop-buttons.show {
    display: flex;
}

#reel-crop-confirm {
    flex: 1;
    background: var(--reel-success);
    color: white;
}

#reel-crop-confirm:hover {
    background: #218838;
}

#reel-crop-cancel {
    flex: 1;
    background: var(--reel-danger);
    color: white;
}

/* Hide sections during crop mode */
.crop-mode-hidden {
    opacity: 0.3;
    pointer-events: none;
}

.reel-crop-section {
    border: 2px solid var(--reel-primary) !important;
}

/* =====================================================
   TEST 5: Enhanced Template Variations
   ===================================================== */

/* Template A: Tools Left (Default) - already defined */

/* Template B: Tools Right - enhanced */
.template-b .reel-editor-container {
    flex-direction: row;
}

.template-b .reel-options-panel {
    order: 2;
    border-left: 3px solid var(--reel-primary);
    border-radius: var(--reel-radius-sm) 0 0 var(--reel-radius-sm);
}

.template-b .reel-canvas-area {
    order: 1;
    border-radius: 0 var(--reel-radius-sm) var(--reel-radius-sm) 0;
}

/* Template C: Compact - enhanced */
.template-c .reel-frames-container {
    padding: 12px 16px;
}

.template-c .reel-frame-inner {
    width: 65px;
    height: 65px;
}

.template-c .reel-editor-container {
    gap: 12px;
    padding: 12px;
}

.template-c .reel-options-panel {
    width: 200px;
}

.template-c .reel-options-section {
    margin-bottom: 8px;
}

.template-c .reel-options-title {
    font-size: 10px;
    padding: 8px 10px;
}

.template-c .reel-section-content {
    padding: 10px;
}

.template-c .reel-option-group {
    margin-bottom: 8px;
}

.template-c .reel-btn {
    padding: 6px 10px;
    font-size: 11px;
}

.template-c .reel-filter-btn {
    padding: 5px 8px;
    font-size: 10px;
}

.template-c .reel-slider {
    height: 4px;
}

.template-c .reel-canvas-area {
    padding: 12px;
}

/* =====================================================
   FIX #1: Focus-Visible Styles for Accessibility
   ===================================================== */
.reel-frame:focus-visible,
.reel-btn:focus-visible,
.reel-filter-btn:focus-visible,
.reel-color-btn:focus-visible {
    outline: 3px solid var(--reel-primary, #ff6900);
    outline-offset: 2px;
}

.reel-frame:focus-visible {
    z-index: 10;
    box-shadow: 0 0 0 4px rgba(255, 105, 0, 0.3);
}

.reel-slider:focus-visible {
    outline: 2px solid var(--reel-primary, #ff6900);
    outline-offset: 2px;
}

.reel-select:focus-visible,
.reel-text-field:focus-visible {
    outline: 2px solid var(--reel-primary, #ff6900);
    outline-offset: 1px;
    border-color: var(--reel-primary, #ff6900);
}

/* Skip link for keyboard users */
.reel-skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--reel-primary, #ff6900);
    color: #fff;
    padding: 8px 16px;
    z-index: 100000;
    text-decoration: none;
    border-radius: var(--reel-radius-sm);
}

.reel-skip-link:focus {
    top: 0;
}

/* =====================================================
   FIX #5: Bulk Upload Progress Overlay
   ===================================================== */
.reel-progress-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99999;
    backdrop-filter: blur(4px);
}

.reel-progress-content {
    background: #fff;
    padding: 40px 60px;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 90%;
    width: 300px;
}

.reel-progress-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #eee;
    border-top-color: var(--reel-primary, #ff6900);
    border-radius: 50%;
    animation: reel-spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes reel-spin {
    to {
        transform: rotate(360deg);
    }
}

.reel-progress-text {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 10px;
    color: var(--reel-text, #333);
}

.reel-progress-count {
    font-size: 24px;
    font-weight: 700;
    color: var(--reel-primary, #ff6900);
}

/* Progress bar alternative (optional) */
.reel-progress-bar-container {
    width: 100%;
    height: 8px;
    background: #eee;
    border-radius: 4px;
    overflow: hidden;
    margin-top: 16px;
}

.reel-progress-bar {
    height: 100%;
    background: var(--reel-primary, #ff6900);
    border-radius: 4px;
    transition: width 0.3s ease;
}

/* =====================================================
   ENHANCEMENT #3: Reduced Motion Support
   ===================================================== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .reel-frame:hover {
        transform: none;
    }
    
    .reel-btn:hover {
        transform: none;
    }
    
    .reel-bottom-sheet {
        transition: none;
    }
    
    .reel-toast {
        animation: none;
        opacity: 1;
        transform: translateX(0);
    }
    
    .reel-progress-spinner {
        animation: none;
        border-top-color: var(--reel-primary, #ff6900);
        border-right-color: var(--reel-primary, #ff6900);
    }
    
    .reel-canvas-skeleton {
        animation: none;
        background: #e8e8e8;
    }
    
    .reel-spinner-inline {
        animation: none;
        border-top-color: #fff;
        border-right-color: #fff;
    }
}

/* =====================================================
   ENHANCEMENT #5: Save Button Spinner
   ===================================================== */
.reel-spinner-inline {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: reel-spin 0.8s linear infinite;
    vertical-align: middle;
    margin-right: 6px;
}

.single_add_to_cart_button:disabled {
    opacity: 0.7;
    cursor: wait;
}

/* =====================================================
   ENHANCEMENT #6: Canvas Skeleton Loading
   ===================================================== */
.reel-canvas-skeleton {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s infinite;
    border-radius: var(--reel-radius-sm);
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: center;
}

.reel-canvas-skeleton::after {
    content: '';
    width: 40px;
    height: 40px;
    border: 3px solid #ccc;
    border-top-color: var(--reel-primary, #ff6900);
    border-radius: 50%;
    animation: reel-spin 1s linear infinite;
}

@keyframes skeleton-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.reel-canvas-skeleton.hidden {
    display: none;
}

/* =====================================================
   ENHANCEMENT #7: RTL Layout Support
   ===================================================== */
[dir="rtl"] .brandname-reel-editor {
    direction: rtl;
}

[dir="rtl"] .reel-frames-row {
    direction: rtl;
}

[dir="rtl"] .reel-frame-remove {
    right: auto;
    left: 3px;
}

[dir="rtl"] .reel-frame-drag-handle {
    right: auto;
    left: 3px;
    margin-right: 0;
    margin-left: 3px;
}

[dir="rtl"] .reel-options-panel {
    border-left: none;
    border-right: 3px solid var(--reel-primary);
}

[dir="rtl"] .reel-slider-value {
    margin-left: 0;
    margin-right: 10px;
}

[dir="rtl"] .reel-toast {
    right: auto;
    left: 20px;
}

[dir="rtl"] .reel-btn-icon {
    margin-right: 0;
    margin-left: 6px;
}

[dir="rtl"] .toggle-icon {
    margin-left: 0;
    margin-right: auto;
}

[dir="rtl"] .reel-section-toggle .toggle-icon {
    transform: rotate(180deg);
}

[dir="rtl"] .reel-section-toggle.expanded .toggle-icon {
    transform: rotate(270deg);
}

[dir="rtl"] .reel-frames-header {
    flex-direction: row-reverse;
}

[dir="rtl"] .reel-editor-container {
    flex-direction: row-reverse;
}

[dir="rtl"] .reel-format-guide {
    flex-direction: row-reverse;
}

[dir="rtl"] .reel-canvas-warning .warning-icon {
    margin-right: 0;
    margin-left: 8px;
}

[dir="rtl"] .reel-progress-overlay .reel-spinner-inline {
    margin-right: 0;
    margin-left: 6px;
}

/* =====================================================
   Success Modal Styles
   ===================================================== */
.reel-success-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.reel-success-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
}

.reel-success-modal-content {
    position: relative;
    background: #fff;
    border-radius: 16px;
    padding: 40px;
    text-align: center;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: reel-modal-appear 0.3s ease-out;
}

@keyframes reel-modal-appear {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.reel-success-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 20px;
    background: linear-gradient(135deg, #10b981, #059669);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    animation: reel-icon-bounce 0.5s ease-out 0.2s both;
}

@keyframes reel-icon-bounce {
    0% { transform: scale(0); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

.reel-success-title {
    font-size: 24px;
    font-weight: 700;
    color: #1f2937;
    margin: 0 0 10px;
}

.reel-success-message {
    font-size: 16px;
    color: #6b7280;
    margin: 0 0 30px;
}

.reel-success-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.reel-success-modal .reel-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 14px 28px;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
}

.reel-success-modal .reel-btn-primary {
    background: linear-gradient(135deg, #f97316, #ea580c);
    color: #fff;
}

.reel-success-modal .reel-btn-primary:hover {
    background: linear-gradient(135deg, #ea580c, #c2410c);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(249, 115, 22, 0.4);
}

.reel-success-modal .reel-btn-secondary {
    background: #f3f4f6;
    color: #374151;
}

.reel-success-modal .reel-btn-secondary:hover {
    background: #e5e7eb;
}

/* Prevent body scroll when modal is open */
body.reel-modal-open {
    overflow: hidden;
}

/* =====================================================
   Saving Status Styles
   ===================================================== */
#reel-validation-message.reel-saving-status {
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    color: #fff;
    padding: 12px 16px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    animation: reel-pulse-bg 2s ease-in-out infinite;
}

#reel-validation-message.reel-saving-status strong {
    font-weight: 700;
    font-size: 16px;
}

@keyframes reel-pulse-bg {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.85; }
}

#reel-validation-message.reel-error {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: #fff;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 14px;
}

#reel-validation-message .reel-spinner-inline {
    width: 16px;
    height: 16px;
    border-width: 2px;
}

/* Cart button states */
.single_add_to_cart_button.reel-saving {
    background: linear-gradient(135deg, #6b7280, #4b5563) !important;
    cursor: wait !important;
}

.single_add_to_cart_button .reel-progress-count {
    font-weight: 700;
    margin-left: 4px;
}

/* =====================================================
   Progress Modal (During Add to Cart)
   ===================================================== */
.reel-progress-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.reel-progress-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
}

.reel-progress-modal-content {
    position: relative;
    background: linear-gradient(145deg, #1a1a2e, #16213e);
    border-radius: 24px;
    padding: 50px 40px;
    text-align: center;
    max-width: 420px;
    width: 90%;
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.5), 
                0 0 0 1px rgba(255, 255, 255, 0.1);
    animation: reel-progress-appear 0.4s ease-out;
}

@keyframes reel-progress-appear {
    from { 
        opacity: 0; 
        transform: scale(0.8) translateY(30px); 
    }
    to { 
        opacity: 1; 
        transform: scale(1) translateY(0); 
    }
}

/* Circular Progress Icon */
.reel-progress-modal .reel-progress-icon {
    width: 120px;
    height: 120px;
    margin: 0 auto 30px;
    position: relative;
}

.reel-progress-spinner-svg {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.reel-progress-spinner-track {
    stroke: rgba(255, 255, 255, 0.1);
}

.reel-progress-spinner-fill {
    stroke: #f97316;
    stroke-dasharray: 126;
    stroke-dashoffset: 126;
    transition: stroke-dashoffset 0.3s ease;
}

.reel-progress-percent {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 28px;
    font-weight: 700;
    color: #fff;
    font-family: 'SF Mono', 'Roboto Mono', monospace;
}

/* Title & Stage */
.reel-progress-modal .reel-progress-title {
    font-size: 24px;
    font-weight: 700;
    color: #fff;
    margin: 0 0 8px;
}

.reel-progress-stage {
    font-size: 16px;
    color: #f97316;
    margin: 0 0 30px;
    font-weight: 500;
    min-height: 24px;
    animation: reel-stage-pulse 1.5s ease-in-out infinite;
}

@keyframes reel-stage-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* Progress Bar */
.reel-progress-modal .reel-progress-bar-container {
    margin-bottom: 24px;
}

.reel-progress-modal .reel-progress-bar {
    height: 12px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 12px;
}

.reel-progress-modal .reel-progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #f97316, #fb923c, #f97316);
    background-size: 200% 100%;
    border-radius: 6px;
    transition: width 0.3s ease;
    animation: reel-bar-shimmer 2s linear infinite;
}

@keyframes reel-bar-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.reel-progress-modal .reel-progress-bar-text {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.7);
}

.reel-progress-modal .reel-progress-bar-text .reel-progress-current {
    font-weight: 700;
    color: #f97316;
    font-size: 18px;
}

.reel-progress-modal .reel-progress-bar-text .reel-progress-total {
    font-weight: 700;
    color: #fff;
    font-size: 18px;
}

/* Info Text */
.reel-progress-info {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.6);
    margin: 0 0 8px;
}

.reel-progress-warning {
    font-size: 12px;
    color: #fbbf24;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.reel-progress-warning::before {
    content: '⚠️';
}

/* Mobile Responsive for Progress Modal */
@media (max-width: 480px) {
    .reel-progress-modal-content {
        padding: 40px 24px;
        margin: 16px;
        border-radius: 20px;
    }
    
    .reel-progress-modal .reel-progress-icon {
        width: 100px;
        height: 100px;
        margin-bottom: 24px;
    }
    
    .reel-progress-percent {
        font-size: 24px;
    }
    
    .reel-progress-modal .reel-progress-title {
        font-size: 20px;
    }
    
    .reel-progress-stage {
        font-size: 14px;
    }
}

/* Disable other buttons during progress */
body.reel-progress-active .cart-contents,
body.reel-progress-active .mini-cart-link,
body.reel-progress-active [href*="cart"],
body.reel-progress-active .woocommerce-mini-cart__buttons {
    pointer-events: none !important;
    opacity: 0.5 !important;
}

/* Mobile responsive for success modal */
@media (max-width: 480px) {
    .reel-success-modal-content {
        padding: 30px 20px;
        margin: 20px;
    }
    
    .reel-success-title {
        font-size: 20px;
    }
    
    .reel-success-icon {
        width: 64px;
        height: 64px;
    }
    
    .reel-success-icon svg {
        width: 32px;
        height: 32px;
    }
}

/* Reduced motion for success modal */
@media (prefers-reduced-motion: reduce) {
    .reel-success-modal-content {
        animation: none;
    }
    
    .reel-success-icon {
        animation: none;
    }
}
