/**
 * Frontend styles for Custom Product Addons
 *
 * @version 1.0.0
 */

/* Main Container */
.cpa-product-addons {
    margin: 20px 0;
    padding: 20px;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.cpa-product-addons h3 {
    margin: 0 0 20px 0;
    font-size: 20px;
    font-weight: 600;
    color: #333;
    border-bottom: 2px solid #0073aa;
    padding-bottom: 10px;
}

/* Block Styles */
.cpa-addon-block {
    margin-bottom: 30px;
    padding: 20px;
    background: #fafafa;
    border: 1px solid #e9ecef;
    border-radius: 6px;
}

.cpa-addon-block:last-child {
    margin-bottom: 0;
}

.cpa-block-title {
    margin: 0 0 15px 0;
    font-size: 18px;
    font-weight: 600;
    color: #495057;
}

/* Addon Item Styles */
.cpa-addon-item {
    margin-bottom: 20px;
    padding: 15px;
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    transition: border-color 0.2s ease;
}

.cpa-addon-item:hover {
    border-color: #0073aa;
}

.cpa-addon-item:last-child {
    margin-bottom: 0;
}

.cpa-addon-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 10px;
}

.cpa-addon-title {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #333;
    flex: 1;
}

.cpa-addon-required {
    color: #dc3545;
    font-size: 14px;
    font-weight: 500;
    margin-left: 10px;
}

.cpa-addon-price {
    font-size: 14px;
    font-weight: 600;
    color: #0073aa;
    margin-left: 10px;
}

.cpa-addon-description {
    margin: 5px 0 15px 0;
    font-size: 14px;
    color: #666;
    line-height: 1.4;
}

.cpa-addon-field {
    margin-top: 10px;
}

/* Input Styles */
.cpa-text-input,
.cpa-textarea-input,
.cpa-number-input,
.cpa-date-input,
.cpa-select-input {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid #e0e0e0;
    border-radius: 4px;
    font-size: 16px;
    transition: all 0.3s ease;
    background: #fff;
}

.cpa-text-input:focus,
.cpa-textarea-input:focus,
.cpa-number-input:focus,
.cpa-date-input:focus,
.cpa-select-input:focus {
    outline: none;
    border-color: #0073aa;
    box-shadow: 0 0 0 3px rgba(0, 115, 170, 0.1);
}

.cpa-textarea-input {
    resize: vertical;
    min-height: 100px;
}

.cpa-select-input {
    cursor: pointer;
    background-image: url('data:image/svg+xml;charset=US-ASCII,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 4 5"><path fill="%23666" d="M2 0L0 2h4zm0 5L0 3h4z"/></svg>');
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 12px;
    padding-right: 40px;
    appearance: none;
}

/* Option Styles */
.cpa-addon-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.cpa-addon-option {
    display: flex;
    align-items: center;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    background: #fff;
}

.cpa-addon-option:hover {
    border-color: #0073aa;
    background-color: #f8f9fa;
}

.cpa-addon-option.selected {
    border-color: #0073aa;
    background-color: #e8f4f8;
    box-shadow: 0 0 0 1px #0073aa;
}

.cpa-addon-option input[type="radio"],
.cpa-addon-option input[type="checkbox"] {
    margin: 0 12px 0 0;
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: #0073aa;
}

.cpa-addon-option-label {
    flex: 1;
    font-weight: 500;
    cursor: pointer;
    margin: 0;
    line-height: 1.4;
    color: #333;
}

.cpa-addon-option-price {
    color: #0073aa;
    font-weight: 600;
    font-size: 14px;
    margin-left: 10px;
}

/* Price Display */
.cpa-price-summary {
    margin-top: 20px;
    padding: 15px;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    text-align: right;
}

.cpa-price-summary h4 {
    margin: 0 0 10px 0;
    font-size: 16px;
    color: #333;
}

.cpa-price-breakdown {
    margin-bottom: 10px;
}

.cpa-price-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 5px;
    font-size: 14px;
    color: #666;
}

.cpa-price-total {
    display: flex;
    justify-content: space-between;
    font-size: 18px;
    font-weight: 600;
    color: #0073aa;
    border-top: 1px solid #dee2e6;
    padding-top: 10px;
    margin-top: 10px;
}

/* File Upload Styles */
.cpa-file-upload-container {
    margin: 10px 0;
}

.cpa-file-upload-area {
    border: 2px dashed #ddd;
    border-radius: 8px;
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: #fafafa;
}

.cpa-file-upload-area:hover,
.cpa-file-upload-area.cpa-drag-over {
    border-color: #0073aa;
    background: #f0f8ff;
}

.cpa-file-upload-icon .dashicons {
    font-size: 48px;
    color: #0073aa;
    margin-bottom: 15px;
}

.cpa-file-main-text {
    font-size: 16px;
    font-weight: 600;
    color: #333;
    margin: 0 0 8px 0;
}

.cpa-file-sub-text {
    font-size: 14px;
    color: #666;
    margin: 0;
    line-height: 1.4;
}

.cpa-file-preview {
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 15px;
    background: #fff;
    margin-top: 10px;
}

.cpa-file-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.cpa-file-name {
    font-weight: 600;
    color: #333;
    flex: 1;
    margin-right: 10px;
    word-break: break-all;
}

.cpa-file-size {
    font-size: 12px;
    color: #666;
    margin-right: 10px;
}

.cpa-file-remove {
    background: #dc3232;
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
}

.cpa-file-remove:hover {
    background: #a00;
}

.cpa-file-error {
    margin-top: 10px;
    padding: 10px;
    background: #ffeaea;
    border: 1px solid #dc3232;
    border-radius: 4px;
    color: #dc3232;
    font-size: 14px;
}

/* Number Input Controls */
.cpa-number-controls {
    display: inline-flex;
    margin-left: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    overflow: hidden;
}

.cpa-number-controls button {
    background: #f7f7f7;
    border: none;
    padding: 8px 12px;
    cursor: pointer;
    transition: background-color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cpa-number-controls button:hover:not(:disabled) {
    background: #0073aa;
    color: white;
}

.cpa-number-controls button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.cpa-number-controls .cpa-number-decrease {
    border-right: 1px solid #ddd;
}

/* Validation Styles */
.cpa-addon-item.cpa-error {
    border-color: #dc3545;
    background-color: #fff5f5;
}

.cpa-error-message {
    color: #dc3545;
    font-size: 12px;
    margin-top: 5px;
    font-weight: 500;
}

.cpa-addon-item input:invalid,
.cpa-addon-item select:invalid,
.cpa-addon-item textarea:invalid {
    border-color: #dc3545;
}

/* Loading State */
.cpa-loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #0073aa;
    border-radius: 50%;
    animation: cpa-spin 1s linear infinite;
    margin-left: 10px;
}

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

/* Responsive Design */
@media (max-width: 768px) {
    .cpa-product-addons {
        margin: 15px 0;
        padding: 15px;
    }
    
    .cpa-addon-block {
        padding: 15px;
    }
    
    .cpa-addon-item {
        padding: 12px;
    }
    
    .cpa-addon-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 5px;
    }
    
    .cpa-addon-required,
    .cpa-addon-price {
        margin-left: 0;
    }
    
    .cpa-text-input,
    .cpa-textarea-input,
    .cpa-number-input,
    .cpa-date-input,
    .cpa-select-input {
        font-size: 16px; /* Prevent zoom on iOS */
    }
    
    .cpa-addon-option {
        padding: 10px;
    }
    
    .cpa-addon-option input[type="radio"],
    .cpa-addon-option input[type="checkbox"] {
        margin-right: 10px;
    }
    
    .cpa-file-upload-area {
        padding: 30px 15px;
    }
    
    .cpa-file-upload-icon .dashicons {
        font-size: 36px;
    }
    
    .cpa-file-main-text {
        font-size: 14px;
    }
    
    .cpa-file-sub-text {
        font-size: 12px;
    }
    
    .cpa-file-info {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .cpa-file-name {
        margin-right: 0;
    }
    
    .cpa-price-summary {
        text-align: left;
    }
    
    .cpa-price-item,
    .cpa-price-total {
        font-size: 14px;
    }
}

/* Print Styles */
@media print {
    .cpa-product-addons {
        box-shadow: none;
        border: 1px solid #000;
    }
    
    .cpa-addon-option:hover {
        background-color: transparent;
        border-color: #e0e0e0;
    }
    
    .cpa-file-upload-area {
        border-style: solid;
    }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .cpa-addon-option {
        border-width: 3px;
    }
    
    .cpa-text-input:focus,
    .cpa-textarea-input:focus,
    .cpa-number-input:focus,
    .cpa-date-input:focus,
    .cpa-select-input:focus {
        border-width: 3px;
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    .cpa-addon-option,
    .cpa-text-input,
    .cpa-textarea-input,
    .cpa-number-input,
    .cpa-date-input,
    .cpa-select-input,
    .cpa-file-upload-area {
        transition: none;
    }
    
    .cpa-loading {
        animation: none;
    }
}