/* Product Display Widget Styles */
.pdw-product-display {
    background: #fafafa;
    border-radius: 17px;
    padding: 25px;
    margin: 20px 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.pdw-product-display * {
    box-sizing: border-box;
}

/* Layout Styles */
.pdw-layout-horizontal,
.pdw-layout-vertical {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.pdw-layout-horizontal .pdw-brand,
.pdw-layout-horizontal .pdw-price-section,
.pdw-layout-horizontal .pdw-quantity-section,
.pdw-layout-horizontal .pdw-add-to-cart-section,
.pdw-layout-vertical .pdw-brand,
.pdw-layout-vertical .pdw-price-section,
.pdw-layout-vertical .pdw-quantity-section,
.pdw-layout-vertical .pdw-add-to-cart-section {
    width: 100%;
}

/* Brand Section */
.pdw-brand {
    display: flex;
    align-items: center;
    gap: 8px;
}

.pdw-brand-label {
    font-weight: 600;
    color: #666;
    font-size: 14px;
}

.pdw-brand-name {
    font-weight: 700;
    color: #333;
    font-size: 16px;
    background: #f8f9fa;
    padding: 4px 8px;
    border-radius: 4px;
}

/* Price Section */
.pdw-price-section {
    display: flex;
    align-items: center;
    gap: 10px;
}

.pdw-price {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 20px;
    font-weight: 700;
}

.pdw-price-label {
    font-weight: 600;
    color: #666;
    font-size: 14px;
}

.pdw-unit {
    font-size: 14px;
    color: #666;
    font-weight: 500;
    margin-left: 5px;
}

.pdw-price .woocommerce-Price-amount {
    color: #e74c3c;
}

.pdw-price del {
    color: #999;
    font-size: 16px;
    margin-right: 8px;
}

.pdw-price ins {
    text-decoration: none;
    color: #e74c3c;
}

/* Discount Badge */
.pdw-discount-badge {
    background: #e74c3c;
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
}

/* Row and Column Layout */
.row {
    display: flex;
    flex-wrap: nowrap;
    gap: 20px;
    justify-content: space-between;
}

.col {
    flex: 1;
}

.col:first-child {
    flex: 0 0 auto;
}

.col:last-child {
    flex: 1;
}

/* Quantity and Cart Section - on same row */
.pdw-quantity-cart-section {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: nowrap;
}

.pdw-quantity-cart-section .pdw-quantity-section {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 0 0 auto;
    white-space: nowrap;
}

.pdw-quantity-cart-section .pdw-add-to-cart-section {
    flex: 1;
    min-width: 150px;
}

/* Quantity Section */
.pdw-quantity-section {
    display: flex;
    align-items: center;
    gap: 10px;
}

.pdw-quantity-label {
    font-weight: 600;
    color: #333;
    font-size: 14px;
}

.pdw-quantity-controls {
    display: flex;
    align-items: center;
    border: 1px solid #ddd;
    border-radius: 4px;
    overflow: hidden;
}

.qty-container {
    display: flex;
    align-items: center;
    border: 1px solid #ddd;
    border-radius: 4px;
    overflow: hidden;
    width: 120px !important; /* Ensure consistent width */
}

.pdw-quantity-btn {
    background: #f8f9fa;
    border: none;
    width: 35px;
    height: 35px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s;
}

.pdw-quantity-btn:hover {
    background: #e9ecef;
}

.pdw-quantity-btn:active {
    background: #dee2e6;
}

.pdw-quantity-input {
    border: none;
    width: 60px;
    height: 35px;
    text-align: center;
    font-size: 14px;
    font-weight: 600;
    background: white;
    border-left: 1px solid #ddd;
    border-right: 1px solid #ddd;
    appearance: textfield;
    -moz-appearance: textfield;
}

.pdw-quantity-input::-webkit-outer-spin-button,
.pdw-quantity-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.pdw-quantity-input:focus {
    outline: none;
    background: #f8f9fa;
}

.pdw-quantity-btn:disabled {
    background: #e9ecef;
    color: #6c757d;
    cursor: not-allowed;
    opacity: 0.6;
}

/* Add to Cart Section */
.pdw-add-to-cart-section {
    flex: 1;
    min-width: 150px;
}

.pdw-add-to-cart-btn {
    background: #2ecc71;
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 14px !important;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    width: 100%;
    position: relative;
    overflow: hidden;
}

.pdw-add-to-cart-btn:hover {
    background: #27ae60;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(46, 204, 113, 0.3);
}

.pdw-add-to-cart-btn:active {
    transform: translateY(0);
}

.pdw-add-to-cart-btn:disabled {
    background: #95a5a6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.pdw-btn-loading {
    display: none;
}

.pdw-add-to-cart-btn.loading .pdw-btn-text {
    display: none;
}

.pdw-add-to-cart-btn.loading .pdw-btn-loading {
    display: inline;
}

.pdw-out-of-stock {
    background: #e74c3c;
    color: white;
    padding: 12px 24px;
    border-radius: 6px;
    text-align: center;
    font-weight: 600;
    width: 100%;
}

/* Messages */
.pdw-messages {
    display: none; /* Hidden by default */
}

.pdw-messages:not(:empty) {
    display: block; /* Show only when it has content */
}

/* Hide empty p tags that WordPress might add after messages */
.pdw-messages + p:empty,
.pdw-product-display p:empty,
.pdw-product-display + p:empty {
    display: none !important;
    margin: 0 !important;
    padding: 0 !important;
    height: 0 !important;
    line-height: 0 !important;
}

/* Ensure no spacing around empty elements */
.pdw-product-display br + p:empty,
.pdw-product-display p:empty + br {
    display: none !important;
}

.pdw-message {
    padding: 10px 15px;
    border-radius: 4px;
    margin-bottom: 10px;
    font-weight: 500;
}

.pdw-message.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.pdw-message.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.pdw-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    padding: 15px;
    border-radius: 4px;
    margin: 20px 0;
}

/* Responsive Design */
@media (max-width: 768px) {
    .pdw-layout-horizontal {
        flex-direction: column;
        align-items: stretch;
    }
    
    .pdw-brand,
    .pdw-price-section {
        justify-content: center;
    }
    
    .pdw-quantity-cart-section {
        flex-direction: column;
        gap: 15px;
    }
    
    .pdw-quantity-cart-section .pdw-quantity-section {
        justify-content: center;
    }

}

@media (max-width: 480px) {
    .pdw-product-display {
        padding: 15px;
    }
    
    .pdw-price {
        font-size: 18px;
    }
    
    .pdw-quantity-controls {
        width: 100%;
        max-width: 180px;
    }
    
    .pdw-quantity-controls input {
        flex: 1;
    }
    
    .pdw-quantity-cart-section {
        gap: 10px;
    }
}

/* Animation for success/error messages */
.pdw-message {
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Loading spinner */
.pdw-btn-loading:after {
    content: '';
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid transparent;
    border-top: 2px solid currentColor;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-left: 8px;
}

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