/* ==========================================================================
   WooCommerce Product Customizer - Frontend Styles
   ========================================================================== */

/* Reset and Base Styles */
.wpc-customizer-container *,
.wpc-shortcode-container * {
    box-sizing: border-box;
}

.wpc-customizer-container {
    margin: 30px 0;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    background: #fff;
    overflow: hidden;
}

.wpc-shortcode-container {
    margin: 20px 0;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    background: #fff;
    overflow: hidden;
}

.wpc-customizer-title {
    margin: 0 0 20px 0;
    padding: 20px 20px 0 20px;
    font-size: 24px;
    font-weight: 600;
    color: #333;
}

.wpc-product-price {
    padding: 0 20px 10px 20px;
    font-size: 18px;
    font-weight: 500;
    color: #666;
}

/* Main Wrapper */
.wpc-customizer-wrapper {
    display: flex;
    min-height: 500px;
    gap: 20px;
    padding: 20px;
}

.wpc-customizer-interface {
    display: flex;
    min-height: 400px;
    gap: 20px;
}

/* Canvas Section */
.wpc-canvas-section {
    flex: 1;
    min-width: 400px;
    display: flex;
    flex-direction: column;
}

.wpc-canvas-container {
    position: relative;
    background: #f8f9fa;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    padding: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 400px;
}

#wpc-customizer-canvas {
    border: 1px solid #ccc;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    background: #fff;
    cursor: crosshair;
}

.wpc-canvas-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.9);
    z-index: 10;
}

.wpc-loading-spinner {
    text-align: center;
    color: #666;
}

.wpc-spinner {
    width: 40px;
    height: 40px;
    margin: 0 auto 15px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #007cba;
    border-radius: 50%;
    animation: wpc-spin 1s linear infinite;
}

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

/* Canvas Controls */
.wpc-canvas-controls {
    position: absolute;
    top: 10px;
    right: 10px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    z-index: 5;
}

.wpc-canvas-controls button {
    width: 35px;
    height: 35px;
    border: 1px solid #ccc;
    background: #fff;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: bold;
    color: #666;
    transition: all 0.3s ease;
}

.wpc-canvas-controls button:hover {
    background: #f0f0f0;
    border-color: #999;
    color: #333;
}

.wpc-canvas-controls button:active {
    background: #e0e0e0;
}

/* Controls Section */
.wpc-controls-section {
    flex: 0 0 350px;
    background: #f8f9fa;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    max-height: 600px;
}

.wpc-controls-tabs {
    display: flex;
    background: #fff;
    border-bottom: 1px solid #dee2e6;
    border-radius: 8px 8px 0 0;
}

.wpc-tab-button {
    flex: 1;
    padding: 15px 20px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: #666;
    transition: all 0.3s ease;
    border-radius: 8px 8px 0 0;
}

.wpc-tab-button:hover {
    background: #f8f9fa;
    color: #333;
}

.wpc-tab-button.active {
    background: #007cba;
    color: #fff;
}

.wpc-tab-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

/* Control Groups */
.wpc-control-groups {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.wpc-control-group {
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    overflow: hidden;
    transition: all 0.3s ease;
}

.wpc-control-group:hover {
    border-color: #007cba;
    box-shadow: 0 2px 4px rgba(0,124,186,0.1);
}

.wpc-control-group.active {
    border-color: #007cba;
    box-shadow: 0 2px 8px rgba(0,124,186,0.2);
}

.wpc-control-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
    cursor: pointer;
}

.wpc-control-group.collapsed .wpc-control-header {
    border-bottom: none;
}

.wpc-control-title {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #333;
}

.wpc-toggle-control {
    width: 24px;
    height: 24px;
    border: 1px solid #ccc;
    background: #fff;
    border-radius: 3px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: bold;
    color: #666;
    transition: all 0.3s ease;
}

.wpc-toggle-control:hover {
    background: #f0f0f0;
}

.wpc-control-body {
    padding: 20px;
}

/* Control Rows */
.wpc-control-row {
    margin-bottom: 20px;
}

.wpc-control-row:last-child {
    margin-bottom: 0;
}

.wpc-control-label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 500;
    color: #333;
}

/* Text Controls */
.wpc-text-controls .wpc-control-row {
    margin-bottom: 25px;
}

.wpc-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
}

.wpc-text-input {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 14px;
    transition: border-color 0.3s ease;
}

.wpc-text-input:focus {
    outline: none;
    border-color: #007cba;
    box-shadow: 0 0 0 2px rgba(0,124,186,0.2);
}

.wpc-char-counter {
    font-size: 12px;
    color: #666;
    white-space: nowrap;
}

.wpc-char-counter.wpc-counter-warning {
    color: #e74c3c;
    font-weight: 600;
}

.wpc-font-select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 14px;
    background: #fff;
    transition: border-color 0.3s ease;
}

.wpc-font-select:focus {
    outline: none;
    border-color: #007cba;
}

.wpc-color-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
}

.wpc-color-input {
    width: 50px;
    height: 40px;
    border: 1px solid #ccc;
    border-radius: 4px;
    cursor: pointer;
    background: none;
    padding: 2px;
}

.wpc-color-input::-webkit-color-swatch-wrapper {
    padding: 0;
    border: none;
    border-radius: 2px;
}

.wpc-color-input::-webkit-color-swatch {
    border: none;
    border-radius: 2px;
}

.wpc-color-preview {
    width: 30px;
    height: 30px;
    border: 1px solid #ccc;
    border-radius: 4px;
    background: #000;
}

.wpc-range-wrapper {
    display: flex;
    align-items: center;
    gap: 15px;
}

.wpc-font-size-input {
    flex: 1;
    height: 6px;
    border-radius: 3px;
    background: #ddd;
    outline: none;
    -webkit-appearance: none;
    transition: background 0.3s ease;
}

.wpc-font-size-input::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #007cba;
    cursor: pointer;
    transition: background 0.3s ease;
}

.wpc-font-size-input::-webkit-slider-thumb:hover {
    background: #005a87;
}

.wpc-font-size-input::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #007cba;
    cursor: pointer;
    border: none;
}

.wpc-size-display {
    font-size: 14px;
    font-weight: 600;
    color: #333;
    min-width: 40px;
    text-align: right;
}

/* Image Controls */
.wpc-image-controls .wpc-control-label {
    margin-bottom: 15px;
}

.wpc-image-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 10px;
    max-height: 300px;
    overflow-y: auto;
}

.wpc-image-option {
    position: relative;
    border: 2px solid #ddd;
    border-radius: 6px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s ease;
    aspect-ratio: 1;
}

.wpc-image-option:hover {
    border-color: #007cba;
    transform: scale(1.05);
}

.wpc-image-option.selected {
    border-color: #007cba;
    box-shadow: 0 2px 8px rgba(0,124,186,0.3);
}

.wpc-image-option img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.wpc-image-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,124,186,0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.wpc-image-option.selected .wpc-image-overlay {
    opacity: 1;
}

.wpc-check-icon {
    color: #fff;
    font-size: 20px;
    font-weight: bold;
}

/* Preview Section */
.wpc-preview-container {
    text-align: center;
}

.wpc-preview-image-container {
    margin-bottom: 20px;
    padding: 20px;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.wpc-preview-placeholder {
    color: #666;
    font-style: italic;
}

#wpc-preview-image {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.wpc-generate-preview {
    background: #007cba;
    color: #fff;
    border: none;
    padding: 12px 24px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.3s ease;
}

.wpc-generate-preview:hover {
    background: #005a87;
}

.wpc-generate-preview:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* Actions Section */
.wpc-actions-section {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    background: #f8f9fa;
    border-top: 1px solid #dee2e6;
    gap: 20px;
}

.wpc-actions-left,
.wpc-actions-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

.wpc-actions-section .button {
    padding: 12px 20px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 1px solid;
}

.wpc-reset-all,
.wpc-save-design {
    background: #fff;
    color: #666;
    border-color: #ccc;
}

.wpc-reset-all:hover,
.wpc-save-design:hover {
    background: #f8f9fa;
    color: #333;
    border-color: #999;
}

.wpc-add-to-cart {
    background: #007cba;
    color: #fff;
    border-color: #007cba;
    font-weight: 600;
}

.wpc-add-to-cart:hover {
    background: #005a87;
    border-color: #005a87;
}

.wpc-add-to-cart:disabled {
    background: #ccc;
    border-color: #ccc;
    cursor: not-allowed;
}

/* Validation Messages */
.wpc-validation-messages {
    flex: 1;
}

.wpc-validation-error {
    background: #f8d7da;
    color: #721c24;
    padding: 10px 15px;
    border-radius: 4px;
    border: 1px solid #f5c6cb;
}

.wpc-validation-error ul {
    margin: 0;
    padding: 0;
    list-style: none;
}

.wpc-validation-error li {
    margin-bottom: 5px;
}

.wpc-validation-error li:last-child {
    margin-bottom: 0;
}

/* Product Gallery Integration */
.wpc-live-preview-thumb {
    order: -1;
}

.wpc-live-preview-thumb img {
    border: 2px solid #007cba;
    border-radius: 4px;
}

.wpc-customized-thumbnail {
    border: 2px solid #007cba;
    border-radius: 4px;
}

/* Notifications */
.wpc-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 15px 20px;
    border-radius: 6px;
    color: #fff;
    font-size: 14px;
    font-weight: 500;
    max-width: 400px;
    z-index: 10000;
    opacity: 0;
    transform: translateX(100%);
    transition: all 0.3s ease;
}

.wpc-notification.show {
    opacity: 1;
    transform: translateX(0);
}

.wpc-notification-success {
    background: #28a745;
}

.wpc-notification-error {
    background: #dc3545;
}

.wpc-notification-info {
    background: #007cba;
}

/* Fullscreen Mode */
.wpc-fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 999999;
    background: #fff;
    margin: 0;
    border: none;
    border-radius: 0;
}

body.wpc-fullscreen-active {
    overflow: hidden;
}

.wpc-fullscreen .wpc-customizer-wrapper {
    height: calc(100vh - 140px);
    max-height: none;
}

.wpc-fullscreen .wpc-canvas-container {
    min-height: auto;
    height: 100%;
}

.wpc-fullscreen .wpc-controls-section {
    max-height: none;
    height: 100%;
}

/* Error States */
.wpc-error-message {
    padding: 20px;
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    border-radius: 6px;
    color: #721c24;
    text-align: center;
    margin: 20px;
}

.wpc-no-areas {
    text-align: center;
    color: #666;
    font-style: italic;
    padding: 40px 20px;
}

/* Loading States */
.wpc-loading {
    opacity: 0.6;
    pointer-events: none;
    position: relative;
}

.wpc-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 #007cba;
    border-radius: 50%;
    animation: wpc-spin 1s linear infinite;
    z-index: 1;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .wpc-customizer-wrapper,
    .wpc-customizer-interface {
        flex-direction: column;
        gap: 20px;
    }
    
    .wpc-canvas-section {
        min-width: auto;
    }
    
    .wpc-controls-section {
        flex: none;
        max-height: 400px;
    }
    
    .wpc-actions-section {
        flex-direction: column;
        align-items: stretch;
        gap: 15px;
    }
    
    .wpc-actions-left,
    .wpc-actions-right {
        justify-content: center;
    }
}

@media (max-width: 768px) {
    .wpc-customizer-wrapper,
    .wpc-customizer-interface {
        padding: 15px;
    }
    
    .wpc-customizer-title {
        font-size: 20px;
        padding: 15px 15px 0 15px;
    }
    
    .wpc-canvas-container {
        padding: 15px;
        min-height: 300px;
    }
    
    #wpc-customizer-canvas {
        max-width: 100%;
        height: auto;
    }
    
    .wpc-controls-section {
        max-height: 350px;
    }
    
    .wpc-tab-content {
        padding: 15px;
    }
    
    .wpc-control-body {
        padding: 15px;
    }
    
    .wpc-image-gallery {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .wpc-canvas-controls {
        position: relative;
        top: auto;
        right: auto;
        flex-direction: row;
        justify-content: center;
        margin-top: 10px;
    }
    
    .wpc-notification {
        right: 10px;
        left: 10px;
        max-width: none;
    }
}

@media (max-width: 480px) {
    .wpc-input-wrapper {
        flex-direction: column;
        align-items: stretch;
    }
    
    .wpc-char-counter {
        text-align: right;
    }
    
    .wpc-color-wrapper {
        justify-content: space-between;
    }
    
    .wpc-range-wrapper {
        gap: 10px;
    }
    
    .wpc-image-gallery {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }
    
    .wpc-actions-section .button {
        padding: 10px 16px;
        font-size: 13px;
    }
}

/* Print Styles */
@media print {
    .wpc-customizer-container,
    .wpc-shortcode-container {
        display: none;
    }
}

/* High Contrast Support */
@media (prefers-contrast: high) {
    .wpc-control-group {
        border-width: 2px;
    }
    
    .wpc-tab-button.active {
        border: 2px solid #fff;
    }
    
    .wpc-image-option.selected {
        border-width: 3px;
    }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
    .wpc-customizer-container *,
    .wpc-shortcode-container * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}