/**
 * Frontend Styles for DJ Motor Product Add-ons
 * Based on varsoe-mockup.html design
 */

/* Main container */
.djmpa-product-addons {
    background: #f8f9fa;
    padding: 25px;
    border-radius: 8px;
    margin-bottom: 20px;
    margin-top: 20px;
}

/* Addon group */
.djmpa-addon-group {
    margin-bottom: 25px;
}

.djmpa-addon-group:last-of-type {
    margin-bottom: 0;
}

/* Label */
.djmpa-addon-label {
    display: block;
    font-size: 16px;
    font-weight: 600;
    color: #333;
    margin-bottom: 10px;
}

.djmpa-addon-label .djmpa-required {
    color: #dc3545;
    margin-left: 3px;
}

/* Select dropdown */
.djmpa-addon-select {
    display: none; /* Hide native select */
}

/* Custom dropdown container */
.djmpa-custom-dropdown {
    position: relative;
    width: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

.djmpa-dropdown-toggle {
    width: 100%;
    padding: 12px 15px;
    font-size: 15px;
    border: 2px solid #ddd;
    border-radius: 6px;
    background: white;
    color: #333;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 48px;
    position: relative;
}

.djmpa-dropdown-toggle::after {
    content: '';
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    width: 12px;
    height: 8px;
    background-image: url('data:image/svg+xml;charset=UTF-8,%3Csvg width="12" height="8" viewBox="0 0 12 8" fill="none" xmlns="http://www.w3.org/2000/svg"%3E%3Cpath d="M1 1L6 6L11 1" stroke="%23666" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/%3E%3C/svg%3E');
    background-repeat: no-repeat;
    background-position: center;
    transition: transform 0.3s ease;
}

.djmpa-custom-dropdown.open .djmpa-dropdown-toggle::after {
    transform: translateY(-50%) rotate(180deg);
}

.djmpa-dropdown-toggle:hover {
    border-color: #00bcd4;
}

.djmpa-dropdown-toggle.error {
    border-color: #dc3545;
    animation: shake 0.5s;
}

.djmpa-dropdown-selected {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.djmpa-dropdown-image {
    width: 40px;
    height: 40px;
    object-fit: cover;
    border-radius: 4px;
    border: 1px solid #ddd;
    flex-shrink: 0;
}

.djmpa-dropdown-text {
    flex: 1;
    padding-right: 30px;
}

.djmpa-dropdown-name {
    font-weight: 500;
    color: #333;
}

.djmpa-dropdown-price {
    color: #00bcd4;
    font-weight: 600;
    font-size: 14px;
    margin-top: 2px;
}

.djmpa-dropdown-placeholder {
    color: #999;
}

/* Dropdown options panel */
.djmpa-dropdown-options {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 2px solid #00bcd4;
    border-top: none;
    border-radius: 0 0 6px 6px;
    max-height: 300px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    display: none;
}

.djmpa-custom-dropdown.open .djmpa-dropdown-options {
    display: block;
}

.djmpa-dropdown-option {
    padding: 12px 15px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    transition: background 0.2s ease;
    border-bottom: 1px solid #f0f0f0;
}

.djmpa-dropdown-option:last-child {
    border-bottom: none;
}

.djmpa-dropdown-option:hover {
    background: #f8f9fa;
}

.djmpa-dropdown-option.selected {
    background: #e3f2fd;
}

.djmpa-dropdown-option.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: #f5f5f5;
}

.djmpa-dropdown-option.disabled:hover {
    background: #f5f5f5;
}

.djmpa-option-image {
    width: 50px;
    height: 50px;
    object-fit: cover;
    border-radius: 4px;
    border: 1px solid #ddd;
    flex-shrink: 0;
}

.djmpa-option-info {
    flex: 1;
}

.djmpa-option-name {
    font-weight: 500;
    color: #333;
    margin-bottom: 4px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

.djmpa-option-meta {
    display: flex;
    gap: 12px;
    font-size: 13px;
}

.djmpa-option-price {
    color: #00bcd4;
    font-weight: 600;
}

.djmpa-option-stock {
    color: #28a745;
}

.djmpa-option-stock.out-of-stock {
    color: #dc3545;
}

/* Actions */
.djmpa-actions {
    margin-top: 15px;
    margin-bottom: 20px;
    text-align: right;
}

.djmpa-clear-button {
    padding: 8px 20px;
    background: #6c757d;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.djmpa-clear-button:hover {
    background: #5a6268;
    transform: translateY(-1px);
}

.djmpa-clear-button:active {
    transform: translateY(0);
}

/* Price summary */
.djmpa-price-summary {
    background: white;
    border: 2px solid #00bcd4;
    border-radius: 8px;
    padding: 20px;
    margin-top: 20px;
}

.djmpa-price-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    font-size: 15px;
}

.djmpa-price-row.djmpa-base-price {
    color: #666;
    border-bottom: 1px solid #e0e0e0;
}

.djmpa-price-row.djmpa-addon-price {
    color: #00bcd4;
    font-weight: 600;
}

.djmpa-price-row.djmpa-total-price {
    margin-top: 10px;
    padding-top: 15px;
    border-top: 2px solid #00bcd4;
    font-size: 18px;
    font-weight: 700;
    color: #333;
}

.djmpa-price-label {
    font-weight: 600;
}

.djmpa-price-amount {
    font-weight: 700;
}

/* Validation error */
.djmpa-addon-select.djmpa-error {
    border-color: #dc3545;
    animation: shake 0.5s;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

/* Error message */
.djmpa-error-message {
    color: #dc3545;
    font-size: 13px;
    margin-top: 5px;
    display: none;
}

.djmpa-addon-select.djmpa-error + .djmpa-error-message {
    display: block;
}

/* Responsive design */
@media (max-width: 768px) {
    .djmpa-product-addons {
        padding: 20px 15px;
    }
    
    .djmpa-addon-label {
        font-size: 15px;
    }
    
    .djmpa-dropdown-toggle {
        font-size: 14px;
        padding: 10px 12px;
    }
    
    .djmpa-dropdown-image {
        width: 35px;
        height: 35px;
    }
    
    .djmpa-option-image {
        width: 45px;
        height: 45px;
    }
    
    .djmpa-price-summary {
        padding: 15px;
    }
    
    .djmpa-price-row {
        font-size: 14px;
    }
    
    .djmpa-price-row.djmpa-total-price {
        font-size: 16px;
    }
}

/* Integration with WooCommerce */
.woocommerce-variation-add-to-cart .djmpa-product-addons {
    margin-top: 0;
}

/* Loading state */
.djmpa-product-addons.djmpa-loading {
    opacity: 0.6;
    pointer-events: none;
}

.djmpa-product-addons.djmpa-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 30px;
    height: 30px;
    margin: -15px 0 0 -15px;
    border: 3px solid #00bcd4;
    border-radius: 50%;
    border-top-color: transparent;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}
