/**
 * Printful Image Placement Editor Styles
 */

/* Editor Container */
.printful-editor-wrapper {
    display: flex;
    gap: 24px;
    margin: 20px 0;
    padding: 20px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

.printful-editor-main {
    flex: 1;
    min-width: 0;
}

.printful-editor-sidebar {
    width: 280px;
    flex-shrink: 0;
}

/* Placement Tabs */
.editor-placement-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.editor-placement-tab {
    padding: 10px 20px;
    background: #f5f5f5;
    border: 2px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: #555;
    transition: all 0.2s ease;
    text-transform: capitalize;
}

.editor-placement-tab:hover {
    background: #ebebeb;
    color: #333;
}

.editor-placement-tab.active {
    background: linear-gradient(135deg, #8b5cf6 0%, #6366f1 100%);
    color: #fff;
    border-color: transparent;
}

.editor-placement-tab.has-artwork::after {
    content: '✓';
    margin-left: 6px;
    font-size: 12px;
}

/* Canvas Container */
.editor-canvas-container {
    position: relative;
    background: #f8f8f8;
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 500px;
    border: 2px dashed #ddd;
}

.editor-canvas-container canvas {
    max-width: 100%;
    border-radius: 8px;
}

/* Print Area Label */
.editor-print-area-label {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(139, 92, 246, 0.9);
    color: #fff;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    z-index: 10;
}

/* Control Panel */
.editor-controls {
    background: #f9fafb;
    border-radius: 12px;
    padding: 20px;
}

.editor-control-group {
    margin-bottom: 20px;
}

.editor-control-group:last-child {
    margin-bottom: 0;
}

.editor-control-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    font-size: 13px;
    font-weight: 600;
    color: #374151;
}

.editor-control-value {
    font-weight: 500;
    color: #8b5cf6;
    background: rgba(139, 92, 246, 0.1);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
}

/* Sliders */
.editor-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: #e5e7eb;
    outline: none;
    cursor: pointer;
}

.editor-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: linear-gradient(135deg, #8b5cf6 0%, #6366f1 100%);
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(139, 92, 246, 0.4);
    transition: transform 0.15s ease;
}

.editor-slider::-webkit-slider-thumb:hover {
    transform: scale(1.1);
}

.editor-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: linear-gradient(135deg, #8b5cf6 0%, #6366f1 100%);
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 6px rgba(139, 92, 246, 0.4);
}

/* Button Groups */
.editor-button-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.editor-btn {
    flex: 1;
    min-width: 80px;
    padding: 10px 16px;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.editor-btn-secondary {
    background: #fff;
    color: #374151;
    border: 1px solid #e5e7eb;
}

.editor-btn-secondary:hover {
    background: #f3f4f6;
    border-color: #d1d5db;
}

.editor-btn-primary {
    background: linear-gradient(135deg, #8b5cf6 0%, #6366f1 100%);
    color: #fff;
}

.editor-btn-primary:hover {
    background: linear-gradient(135deg, #7c3aed 0%, #4f46e5 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3);
}

.editor-btn-danger {
    background: #fef2f2;
    color: #dc2626;
    border: 1px solid #fecaca;
}

.editor-btn-danger:hover {
    background: #fee2e2;
}

.editor-btn i {
    font-size: 14px;
}

/* Divider */
.editor-divider {
    height: 1px;
    background: #e5e7eb;
    margin: 16px 0;
}

/* Tips Section */
.editor-tips {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 8px;
    padding: 12px;
    margin-top: 16px;
}

.editor-tips-title {
    font-size: 12px;
    font-weight: 600;
    color: #166534;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.editor-tips-list {
    font-size: 11px;
    color: #15803d;
    line-height: 1.5;
    margin: 0;
    padding-left: 16px;
}

.editor-tips-list li {
    margin-bottom: 4px;
}

/* Loading State */
.editor-loading {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 100;
    border-radius: 12px;
}

.editor-loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #e5e7eb;
    border-top-color: #8b5cf6;
    border-radius: 50%;
    animation: editor-spin 0.8s linear infinite;
}

@keyframes editor-spin {
    to {
        transform: rotate(360deg);
    }
}

.editor-loading-text {
    margin-top: 12px;
    font-size: 14px;
    color: #6b7280;
}

/* Crop Tool */
.editor-crop-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
}

.editor-crop-overlay.active {
    display: flex;
}

.editor-crop-container {
    background: #fff;
    border-radius: 16px;
    padding: 24px;
    max-width: 90vw;
    max-height: 90vh;
}

.editor-crop-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 16px;
}

/* Section Title */
.editor-section-title {
    font-size: 16px;
    font-weight: 600;
    color: #111827;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.editor-section-title i {
    color: #8b5cf6;
}

/* Responsive */
@media (max-width: 900px) {
    .printful-editor-wrapper {
        flex-direction: column;
    }

    .printful-editor-sidebar {
        width: 100%;
    }

    .editor-canvas-container {
        min-height: 400px;
    }
}

@media (max-width: 600px) {
    .editor-placement-tabs {
        flex-direction: column;
    }

    .editor-placement-tab {
        text-align: center;
    }

    .editor-button-group {
        flex-direction: column;
    }

    .editor-btn {
        min-width: 100%;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .printful-editor-wrapper {
        background: #1f2937;
    }

    .editor-canvas-container {
        background: #111827;
        border-color: #374151;
    }

    .editor-controls {
        background: #111827;
    }

    .editor-control-label {
        color: #e5e7eb;
    }

    .editor-slider {
        background: #374151;
    }

    .editor-btn-secondary {
        background: #374151;
        color: #e5e7eb;
        border-color: #4b5563;
    }

    .editor-btn-secondary:hover {
        background: #4b5563;
    }

    .editor-placement-tab {
        background: #374151;
        color: #d1d5db;
    }

    .editor-placement-tab:hover {
        background: #4b5563;
    }

    .editor-tips {
        background: #064e3b;
        border-color: #065f46;
    }

    .editor-tips-title {
        color: #6ee7b7;
    }

    .editor-tips-list {
        color: #a7f3d0;
    }

    .editor-divider {
        background: #374151;
    }
}

/* Integration with existing product detail container */
#productContainer .printful-editor-wrapper,
#productContainerMockup .printful-editor-wrapper {
    margin-top: 0;
}

/* Ensure canvas is responsive within container */
.editor-canvas-container .canvas-container {
    max-width: 100% !important;
}

.editor-canvas-container .canvas-container canvas {
    max-width: 100% !important;
    height: auto !important;
}

/* ========================================
   Test Mockup Preview Section
   ======================================== */

.editor-test-mockup {
    margin-top: 16px;
}

.editor-test-mockup .editor-btn {
    width: 100%;
    padding: 12px 20px;
    font-size: 14px;
}

.editor-test-mockup .editor-btn i {
    font-size: 16px;
}

/* Mockup Preview Container */
.editor-mockup-preview {
    margin-top: 16px;
    min-height: 60px;
    position: relative;
}

/* Loading State */
.editor-mockup-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 30px 20px;
    background: #f9fafb;
    border-radius: 12px;
    border: 2px dashed #e5e7eb;
}

.editor-mockup-loading .editor-loading-spinner {
    width: 32px;
    height: 32px;
}

.editor-mockup-loading div:last-child {
    margin-top: 10px;
    font-size: 13px;
    color: #6b7280;
}

/* Mockup Result */
.editor-mockup-result {
    position: relative;
}

.editor-mockup-result img {
    width: 100%;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    cursor: zoom-in;
}

.editor-mockup-result img:hover {
    transform: scale(1.02);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

/* Success badge on mockup */
.editor-mockup-result .mockup-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: #fff;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 5px;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}

.editor-mockup-result .mockup-badge i {
    font-size: 12px;
}

/* Error state */
.editor-mockup-error {
    padding: 16px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 12px;
    color: #dc2626;
    font-size: 13px;
    text-align: center;
}

.editor-mockup-error i {
    display: block;
    font-size: 24px;
    margin-bottom: 8px;
}

/* Fullscreen mockup preview modal */
.editor-mockup-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    cursor: zoom-out;
}

.editor-mockup-modal.active {
    display: flex;
}

.editor-mockup-modal img {
    max-width: 90vw;
    max-height: 90vh;
    border-radius: 8px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.editor-mockup-modal .close-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: #fff;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    font-size: 24px;
    cursor: pointer;
    transition: background 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.editor-mockup-modal .close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Dark mode */
.king-night .editor-mockup-loading {
    background: #1f2937;
    border-color: #374151;
}

.king-night .editor-mockup-loading div:last-child {
    color: #9ca3af;
}

.king-night .editor-mockup-error {
    background: #451a1a;
    border-color: #7f1d1d;
    color: #fca5a5;
}
