/**
 * Phone Case Designer - Frontend Styles
 */

/* Main Designer Container */
.pcd-designer-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
}

/* Product Information Section */
.pcd-product-info {
    background: #fff;
    border-radius: 8px;
    padding: 25px;
    margin-bottom: 25px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    border-left: 4px solid #2196F3;
}

.pcd-product-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    flex-wrap: wrap;
    gap: 15px;
}

.pcd-product-title {
    margin: 0;
    font-size: 28px;
    font-weight: 700;
    color: #333;
    line-height: 1.3;
}

.pcd-product-price {
    font-size: 24px;
    font-weight: 600;
    color: #2196F3;
}

.pcd-product-price .amount {
    color: inherit;
}

.pcd-product-description {
    color: #666;
    font-size: 16px;
    line-height: 1.6;
    margin: 0;
}

.pcd-product-description p {
    margin: 0 0 10px 0;
}

.pcd-product-description p:last-child {
    margin-bottom: 0;
}

/* Layout */
.pcd-designer-layout {
    display: grid;
    grid-template-columns: 280px 1fr 320px;
    gap: 30px;
    min-height: 600px;
}

/* Sidebars */
.pcd-sidebar {
    background: #fff;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.pcd-sidebar h3,
.pcd-sidebar h4 {
    margin-top: 0;
    margin-bottom: 15px;
    color: #333;
    font-size: 18px;
    font-weight: 600;
}

/* Model Selection */
.pcd-model-selection .pcd-form-group {
    margin-bottom: 15px;
}

.pcd-select {
    width: 100%;
    padding: 10px;
    border: 2px solid #e1e5e9;
    border-radius: 6px;
    font-size: 14px;
    background: #fff;
    transition: border-color 0.3s ease;
}

.pcd-select:focus {
    outline: none;
    border-color: #2196F3;
    box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.1);
}

.pcd-select:disabled {
    background: #f8f9fa;
    color: #6c757d;
    cursor: not-allowed;
}

/* Buttons */
.pcd-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.3s ease;
    gap: 8px;
}

.pcd-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.pcd-btn-primary {
    background: #2196F3;
    color: white;
}

.pcd-btn-primary:hover:not(:disabled) {
    background: #1976D2;
    transform: translateY(-1px);
}

.pcd-btn-secondary {
    background: #6c757d;
    color: white;
}

.pcd-btn-secondary:hover:not(:disabled) {
    background: #5a6268;
}

.pcd-btn-success {
    background: #28a745;
    color: white;
}

.pcd-btn-success:hover:not(:disabled) {
    background: #218838;
}

.pcd-btn-danger {
    background: #dc3545;
    color: white;
}

.pcd-btn-danger:hover:not(:disabled) {
    background: #c82333;
}

.pcd-btn-small {
    padding: 8px 12px;
    font-size: 12px;
}

.pcd-btn-with-icon {
    gap: 8px;
    padding: 10px 16px;
}

.pcd-btn-with-icon svg {
    flex-shrink: 0;
}

.pcd-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 6px;
    background: #2196F3;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-right: 10px;
}

.pcd-icon-btn:hover {
    background: #1976D2;
    transform: translateY(-1px);
}

/* Canvas Container */
.pcd-canvas-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: transparent;
    padding: 20px;
    min-height: 600px;
    max-width: 100%;
    overflow: hidden; /* Prevent horizontal scroll */
}

#pcd-canvas-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    max-width: 100%;
    width: 100%;
}

.pcd-model-name {
    font-size: 18px;
    font-weight: 600;
    color: #333;
    text-align: center;
}

.pcd-canvas-area {
    position: relative;
    display: inline-block;
    max-width: 100%;
    max-height: 700px; /* Increased limit */
    overflow: hidden;
    /* Remove any potential shadows or borders */
    box-shadow: none !important;
    border: none !important;
}

#pcd-canvas {
    /* Remove max-width constraints - let JS handle responsive sizing */
    width: auto !important;
    height: auto !important;
    display: block;
    /* Removed shadow and border-radius for cleaner appearance */
}

/* Ensure Fabric.js canvas layers are properly sized */
.canvas-container {
    position: relative !important;
    display: inline-block !important;
}

.canvas-container canvas {
    position: absolute !important;
    left: 0 !important;
    top: 0 !important;
}

/* Specific fixes for Fabric.js canvas classes */
.canvas-container .upper-canvas,
.canvas-container .lower-canvas {
    width: auto !important;
    height: auto !important;
    display: block !important;
}

/* Prevent any theme/plugin interference with canvas sizing */
.pcd-canvas-area canvas,
.pcd-canvas-area .canvas-container,
.pcd-canvas-area .canvas-container canvas {
    max-width: none !important;
    max-height: none !important;
    border: none !important;
    outline: none !important;
}

.pcd-phone-frame {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 5;
}



/* Bottom Controls */
.pcd-bottom-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    width: 100%;
    max-width: 400px;
}

.pcd-control-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.pcd-sliders {
    display: flex;
    gap: 20px;
    width: 100%;
}

.pcd-slider-group {
    flex: 1;
    text-align: center;
}

.pcd-slider-group label {
    display: block;
    margin-bottom: 5px;
    font-size: 12px;
    color: #666;
    font-weight: 500;
}

.pcd-slider-group input[type="range"] {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: #e1e5e9;
    outline: none;
    appearance: none;
}

.pcd-slider-group input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #2196F3;
    cursor: pointer;
    border: 2px solid #fff;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.pcd-slider-group input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #2196F3;
    cursor: pointer;
    border: 2px solid #fff;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.pcd-add-to-cart {
    width: 100%;
}

.pcd-add-to-cart .pcd-btn {
    width: 100%;
    padding: 15px 20px;
    font-size: 16px;
    font-weight: 600;
}

/* Design Tools */
.pcd-tool-section {
    margin-bottom: 25px;
    border-bottom: 1px solid #e1e5e9;
    padding-bottom: 20px;
}

.pcd-tool-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.pcd-tool-content {
    margin-top: 15px;
}

.pcd-form-group {
    margin-bottom: 15px;
}

.pcd-form-group label {
    display: block;
    margin-bottom: 5px;
    font-size: 13px;
    color: #666;
    font-weight: 500;
}

.pcd-form-group input[type="color"] {
    width: 100%;
    height: 40px;
    border: 2px solid #e1e5e9;
    border-radius: 6px;
    cursor: pointer;
    background: none;
    padding: 0;
}

.pcd-form-group input[type="range"] {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: #e1e5e9;
    outline: none;
    appearance: none;
}

.pcd-form-group input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #2196F3;
    cursor: pointer;
    border: 2px solid #fff;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.pcd-form-group input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #2196F3;
    cursor: pointer;
    border: 2px solid #fff;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

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

.pcd-modal-content {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    max-width: 90%;
    max-height: 90%;
    overflow: auto;
}

.pcd-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 20px 0;
    border-bottom: 1px solid #e1e5e9;
}

.pcd-modal-header h3 {
    margin: 0;
    font-size: 18px;
    color: #333;
}

.pcd-modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: #666;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pcd-modal-close:hover {
    color: #333;
}

.pcd-modal-body {
    padding: 20px;
}

.pcd-modal-footer {
    padding: 0 20px 20px;
    text-align: right;
}

/* Font Grid */
.pcd-font-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 10px;
    max-width: 600px;
}

.pcd-font-option {
    padding: 15px;
    border: 2px solid #e1e5e9;
    border-radius: 6px;
    cursor: pointer;
    text-align: center;
    transition: all 0.3s ease;
}

.pcd-font-option:hover {
    border-color: #2196F3;
    background: #f8f9fa;
}

.pcd-font-option.selected {
    border-color: #2196F3;
    background: #E3F2FD;
}

.pcd-font-option span {
    font-size: 16px;
    display: block;
}

/* Loading */
.pcd-loading-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    padding: 40px;
    text-align: center;
}

.pcd-loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #e1e5e9;
    border-left: 4px solid #2196F3;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Save Indicator */
.pcd-save-indicator {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #28a745;
    color: white;
    padding: 10px 15px;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    z-index: 1001;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Responsive Design */
@media (max-width: 1200px) {
    .pcd-designer-layout {
        grid-template-columns: 260px 1fr 280px;
        gap: 20px;
    }
}

@media (max-width: 1024px) {
    .pcd-designer-layout {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .pcd-sidebar {
        order: 2;
    }
    
    .pcd-canvas-container {
        order: 1;
    }
    
    .pcd-sidebar-right {
        order: 3;
    }
    
    .pcd-sliders {
        flex-direction: column;
        gap: 15px;
    }
}

@media (max-width: 768px) {
    /* Move model selection to top on mobile */
    .pcd-sidebar {
        order: 1;
    }
    
    .pcd-canvas-container {
        order: 2;
    }
    
    .pcd-sidebar-right {
        order: 3;
    }
}

@media (max-width: 768px) {
    .pcd-designer-container {
        padding: 15px;
    }
    
    .pcd-product-info {
        padding: 20px;
    }
    
    .pcd-product-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .pcd-product-title {
        font-size: 24px;
    }
    
    .pcd-product-price {
        font-size: 20px;
    }
    
    .pcd-canvas-container {
        padding: 10px;
    }
    
    /* Canvas sizing now handled by JavaScript */
    
    /* Canvas sizing now handled by JavaScript - removed conflicting overrides */
    
    .pcd-bottom-controls {
        max-width: 100%;
    }
    
    .pcd-control-group {
        flex-wrap: wrap;
        justify-content: center;
        gap: 8px;
    }
    
    .pcd-btn-with-icon {
        padding: 8px 12px;
        font-size: 13px;
    }
    
    .pcd-font-grid {
        grid-template-columns: 1fr;
    }
}

/* Additional mobile-specific sizing for very small screens */
@media (max-width: 480px) {
    /* Center full-size canvas and hide overflow for mobile trick */
    .pcd-canvas-area {
        position: relative;
        left: 50%;
        transform: translateX(-50%);
        overflow: hidden;
        max-width: 100vw;
    }
    
    .pcd-canvas-container {
        overflow: hidden;
        position: relative;
    }
}

/* WordPress Integration Fixes */
.pcd-designer-container * {
    box-sizing: border-box;
}

.pcd-designer-container .pcd-btn:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.3);
}

/* Hide default WooCommerce elements for designer products */
.pcd-designer-product .woocommerce-product-gallery,
.pcd-designer-product .product_meta,
.pcd-designer-product .woocommerce-tabs,
.pcd-designer-product .single_add_to_cart_button,
.pcd-designer-product .quantity,
.pcd-designer-product .cart,
.pcd-designer-product .single_variation_wrap,
.pcd-designer-product .variations,
.pcd-designer-product .woocommerce-variation-add-to-cart {
    display: none !important;
}

/* Hide the entire product summary section since we show custom product info */
.pcd-designer-product .entry-summary,
.pcd-designer-product .summary,
.pcd-designer-product .woocommerce-product-details__short-description,
.pcd-designer-product .price,
.pcd-designer-product .product_title,
.pcd-designer-product .woocommerce-product-rating,
.pcd-designer-product h1.entry-title,
.pcd-designer-product h1.product_title {
    display: none !important;
}

/* Additional fallback selectors for stubborn themes */
.pcd-designer-product .single-product .entry-header,
.pcd-designer-product .single-product .entry-content > h1,
.pcd-designer-product .single-product .entry-content > .price {
    display: none !important;
}

/* Hide related products and upsells for designer products */
.pcd-designer-product .related,
.pcd-designer-product .upsells,
.pcd-designer-product .cross-sells {
    display: none !important;
}
