/**
 * Illustration Configurator Pro - Editor Styles
 * Version 2.0 - Optimized editor interface styling
 * Based on original editor.html styles but enhanced for new architecture
 */

/* ----------------------------------------------------------------------------------------------- 
                                     Editor Container & Layout
   ----------------------------------------------------------------------------------------------- */

.icp-editor-container {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    background-color: #f7f7f7;
    margin: 0;
    padding: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.icp-editor-wrapper {
    width: 100%;
    height: 100vh;
    margin: 0;
    padding: 20px;
    background-color: #fff;
    border: 1px solid #ddd;
    border-radius: 10px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
    text-align: center;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
}

/* ----------------------------------------------------------------------------------------------- 
                                     Editor Header
   ----------------------------------------------------------------------------------------------- */

.icp-editor-header {
    margin-bottom: 20px;
    cursor: default;
    flex-shrink: 0;
}

.icp-editor-header h2 {
    font-weight: bold;
    margin: 0 0 10px 0;
    color: #333;
    font-size: 24px;
}

.icp-editor-header p {
    margin: 0;
    color: #666;
    font-size: 14px;
    line-height: 1.4;
}

/* ----------------------------------------------------------------------------------------------- 
                                     Canvas Container
   ----------------------------------------------------------------------------------------------- */

.icp-editor-canvas-container {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 20px;
    min-height: 400px;
    position: relative;
    overflow: hidden;
    max-width: 100%;
    max-height: 100%;
}

.icp-main-canvas {
    border: 1px solid #ccc;
    border-radius: 10px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
    cursor: crosshair;
    max-width: 800px;
    max-height: 600px;
    width: 800px;
    height: 600px;
    background-color: #fff;
    object-fit: contain;
    display: block;
}

.icp-main-canvas:hover {
    /* Removed scale transform that was causing overflow */
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.2);
}

/* Canvas loading state */
.icp-canvas-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.9);
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.icp-canvas-loading .spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #0073aa;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 10px;
}

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

/* ----------------------------------------------------------------------------------------------- 
                                     Editor Toolbar
   ----------------------------------------------------------------------------------------------- */

.icp-editor-toolbar {
    background-color: #333333;
    color: #fff;
    padding: 12px;
    text-align: center;
    border-radius: 8px;
    margin-bottom: 15px;
    flex-shrink: 0;
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

.icp-btn {
    background-color: #444;
    color: #fff;
    border: none;
    padding: 10px 20px;
    font-size: 14px;
    cursor: pointer;
    border-radius: 5px;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    text-decoration: none;
    font-family: inherit;
    line-height: 1;
}

.icp-btn:hover {
    background-color: #555;
    transform: translateY(-1px);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.icp-btn:active {
    background-color: #666;
    transform: translateY(0);
}

.icp-btn:disabled {
    background-color: #666;
    cursor: not-allowed;
    opacity: 0.6;
    transform: none;
}

.icp-btn-primary {
    background-color: #0073aa;
}

.icp-btn-primary:hover {
    background-color: #005177;
}

.icp-btn-secondary {
    background-color: #666;
}

.icp-btn-secondary:hover {
    background-color: #777;
}

/* Dashicons in buttons */
.icp-btn .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
    line-height: 1;
}

/* ----------------------------------------------------------------------------------------------- 
                                     Editor Status
   ----------------------------------------------------------------------------------------------- */

.icp-editor-status {
    margin-bottom: 15px;
    flex-shrink: 0;
}

.icp-status-label {
    background-color: #fff;
    padding: 10px 15px;
    border: 1px solid #ccc;
    border-radius: 8px;
    margin: 0 auto;
    display: inline-block;
    font-weight: bold;
    min-width: 200px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* ----------------------------------------------------------------------------------------------- 
                                     Editor Actions
   ----------------------------------------------------------------------------------------------- */

.icp-editor-actions {
    flex-shrink: 0;
    margin-top: auto;
    padding-top: 15px;
}

#icp-save-btn {
    background-color: #090a47;
    color: white;
    padding: 12px 30px;
    font-size: 16px;
    font-weight: bold;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

#icp-save-btn:hover {
    background-color: #0c0f6e;
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(9, 10, 71, 0.3);
}

#icp-save-btn:active {
    background-color: #0c0f6e;
    transform: scale(0.98);
}

#icp-save-btn:disabled {
    background-color: #666;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Save button animation */
@keyframes saveButtonPulse {
    0% {
        transform: scale(1);
        background-color: #090a47;
    }
    50% {
        transform: scale(1.05);
        background-color: #0c0f6e;
    }
    100% {
        transform: scale(1);
        background-color: #090a47;
    }
}

#icp-save-btn.pulse {
    animation: saveButtonPulse 0.6s ease-in-out;
}

/* ----------------------------------------------------------------------------------------------- 
                                     Modal Styles
   ----------------------------------------------------------------------------------------------- */

.icp-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.icp-modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(2px);
}

.icp-modal-content {
    position: relative;
    background: white;
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    max-width: 95vw;
    max-height: 95vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.icp-modal-header {
    padding: 20px;
    border-bottom: 1px solid #ddd;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: #f8f9fa;
}

.icp-modal-title {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    color: #333;
}

.icp-modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #666;
    padding: 5px;
    border-radius: 3px;
    transition: all 0.2s ease;
}

.icp-modal-close:hover {
    background-color: #e9ecef;
    color: #333;
}

.icp-modal-body {
    flex: 1;
    overflow: auto;
}

/* ----------------------------------------------------------------------------------------------- 
                                     Responsive Design
   ----------------------------------------------------------------------------------------------- */

@media (max-width: 768px) {
    .icp-editor-wrapper {
        padding: 10px;
        border-radius: 0;
        height: 100vh;
    }
    
    .icp-editor-header h2 {
        font-size: 20px;
    }
    
    .icp-editor-header p {
        font-size: 12px;
    }
    
    .icp-editor-toolbar {
        padding: 8px;
        gap: 5px;
    }
    
    .icp-btn {
        padding: 8px 12px;
        font-size: 12px;
    }
    
    #icp-save-btn {
        padding: 10px 20px;
        font-size: 14px;
    }
    
    .icp-main-canvas {
        max-width: calc(100vw - 40px);
        max-height: calc(100vh - 300px);
    }
}

@media (max-width: 480px) {
    .icp-editor-wrapper {
        padding: 5px;
    }
    
    .icp-editor-toolbar {
        flex-direction: column;
        gap: 8px;
    }
    
    .icp-btn {
        width: 100%;
        justify-content: center;
    }
    
    .icp-main-canvas {
        max-width: calc(100vw - 20px);
        max-height: calc(100vh - 350px);
    }
}

/* ----------------------------------------------------------------------------------------------- 
                                     Loading States
   ----------------------------------------------------------------------------------------------- */

.icp-loading {
    opacity: 0.6;
    pointer-events: none;
    position: relative;
}

.icp-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #0073aa;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* ----------------------------------------------------------------------------------------------- 
                                     Error States
   ----------------------------------------------------------------------------------------------- */

.icp-error {
    color: #d63384;
    background-color: #f8d7da;
    border: 1px solid #f5c2c7;
    border-radius: 5px;
    padding: 10px 15px;
    margin: 10px 0;
}

.icp-success {
    color: #0f5132;
    background-color: #d1e7dd;
    border: 1px solid #badbcc;
    border-radius: 5px;
    padding: 10px 15px;
    margin: 10px 0;
}

.icp-warning {
    color: #664d03;
    background-color: #fff3cd;
    border: 1px solid #ffecb5;
    border-radius: 5px;
    padding: 10px 15px;
    margin: 10px 0;
}

/* ----------------------------------------------------------------------------------------------- 
                                     Accessibility
   ----------------------------------------------------------------------------------------------- */

.icp-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;
}

/* Focus styles */
.icp-btn:focus,
.icp-main-canvas:focus {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .icp-editor-wrapper {
        border: 2px solid #000;
    }
    
    .icp-btn {
        border: 1px solid #000;
    }
    
    .icp-main-canvas {
        border: 2px solid #000;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .icp-btn,
    .icp-main-canvas,
    #icp-save-btn {
        transition: none;
    }
    
    .icp-canvas-loading .spinner {
        animation: none;
    }
    
    @keyframes spin {
        to { transform: none; }
    }
}

/* ----------------------------------------------------------------------------------------------- 
                                     Print Styles
   ----------------------------------------------------------------------------------------------- */

@media print {
    .icp-editor-toolbar,
    .icp-editor-actions,
    .icp-btn {
        display: none;
    }
    
    .icp-editor-wrapper {
        border: none;
        box-shadow: none;
        padding: 0;
    }
    
    .icp-main-canvas {
        max-width: 100%;
        max-height: none;
        border: 1px solid #000;
    }
}

/* ----------------------------------------------------------------------------------------------- 
                                     Dark Mode Support
   ----------------------------------------------------------------------------------------------- */

@media (prefers-color-scheme: dark) {
    .icp-editor-container[data-theme="auto"] {
        background-color: #1a1a1a;
        color: #fff;
    }
    
    .icp-editor-container[data-theme="auto"] .icp-editor-wrapper {
        background-color: #2d2d2d;
        border-color: #444;
        color: #fff;
    }
    
    .icp-editor-container[data-theme="auto"] .icp-editor-header h2 {
        color: #fff;
    }
    
    .icp-editor-container[data-theme="auto"] .icp-editor-header p {
        color: #ccc;
    }
    
    .icp-editor-container[data-theme="auto"] .icp-status-label {
        background-color: #3d3d3d;
        border-color: #555;
        color: #fff;
    }
    
    .icp-editor-container[data-theme="auto"] .icp-main-canvas {
        border-color: #555;
    }
}

/* Explicit dark theme */
.icp-editor-container[data-theme="dark"] {
    background-color: #1a1a1a;
    color: #fff;
}

.icp-editor-container[data-theme="dark"] .icp-editor-wrapper {
    background-color: #2d2d2d;
    border-color: #444;
    color: #fff;
}

.icp-editor-container[data-theme="dark"] .icp-editor-header h2 {
    color: #fff;
}

.icp-editor-container[data-theme="dark"] .icp-editor-header p {
    color: #ccc;
}

.icp-editor-container[data-theme="dark"] .icp-status-label {
    background-color: #3d3d3d;
    border-color: #555;
    color: #fff;
}

.icp-editor-container[data-theme="dark"] .icp-main-canvas {
    border-color: #555;
}
