/**
 * Composite Products Frontend Styles
 * 
 * Styles for the component selector interface on product pages
 */

/* Main container */
.woo-adst-composite-selector {
    margin: 20px 0;
    padding: 20px;
    background: #f9f9f9;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
}

.woo-adst-composite-title {
    margin: 0 0 15px 0;
    font-size: 1.5em;
    font-weight: 600;
    color: #333;
}

/* Discount notice */
.woo-adst-composite-discount-notice {
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 4px;
    padding: 10px 15px;
    margin-bottom: 20px;
}

.woo-adst-composite-discount-notice p {
    margin: 0;
    color: #856404;
    font-weight: 500;
}

/* Components container */
.woo-adst-composite-components {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 20px;
}

/* Individual component item */
.woo-adst-component-item {
    display: grid;
    grid-template-columns: 100px 1fr auto;
    gap: 15px;
    align-items: center;
    background: #fff;
    padding: 15px;
    border: 1px solid #ddd;
    border-radius: 4px;
    transition: box-shadow 0.2s;
}

.woo-adst-component-item:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Component image */
.woo-adst-component-image {
    width: 100px;
    height: 100px;
    overflow: hidden;
    border-radius: 4px;
    border: 1px solid #e0e0e0;
}

.woo-adst-component-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Component details */
.woo-adst-component-details {
    flex: 1;
}

.woo-adst-component-name {
    margin: 0 0 8px 0;
    font-size: 1.1em;
    font-weight: 600;
    color: #333;
}

.woo-adst-component-description {
    font-size: 0.85em;
    color: #555555;
    margin-top: 2px;
    margin-bottom: 10px;
    line-height: 1.45;
    font-family: inherit;
    font-weight: normal;
    display: block;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.woo-adst-component-name .required-indicator {
    color: #e74c3c;
    font-weight: bold;
    margin-left: 4px;
}

.woo-adst-component-price {
    margin-bottom: 8px;
}

.woo-adst-component-price .price-display {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.woo-adst-component-price .regular-price {
    font-size: 1.2em;
    font-weight: 600;
    color: #333;
    transition: all 0.3s ease;
}

.woo-adst-component-price .discount-price {
    font-size: 1.2em;
    font-weight: 600;
    color: #27ae60;
    transition: all 0.3s ease;
}

.woo-adst-component-price .price-label {
    font-size: 0.85em;
    color: #666;
    display: block;
}

/* Price display when discount is active */
.woo-adst-component-item.discount-active .regular-price {
    text-decoration: line-through;
    color: #999;
    font-size: 0.95em;
    margin-right: 8px;
}

/* Component constraints */
.woo-adst-component-constraints {
    font-size: 0.9em;
    color: #666;
    margin-bottom: 5px;
}

.woo-adst-component-constraints span {
    margin-right: 10px;
}

/* Stock status */
.woo-adst-component-stock {
    font-size: 0.9em;
    margin-top: 5px;
}

.woo-adst-component-stock .in-stock {
    color: #27ae60;
}

.woo-adst-component-stock .low-stock {
    color: #f39c12;
    font-weight: 600;
}

.woo-adst-component-stock .out-of-stock {
    color: #e74c3c;
    font-weight: 600;
}

/* Footer row inside details column (contains price/constraints and quantity selector) */
.woo-adst-component-footer-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 15px;
    margin-top: 10px;
}

.woo-adst-component-price-col {
    flex: 1;
    min-width: 120px;
}

.woo-adst-component-quantity-col {
    display: flex;
    align-items: center;
}

/* Quantity controls */
.woo-adst-component-quantity {
    display: flex;
    align-items: center;
    gap: 5px;
    margin: 0;
}

.qty-btn {
    width: 36px;
    height: 36px;
    border: 1px solid #ddd;
    background: #fff;
    border-radius: 4px;
    cursor: pointer;
    font-size: 18px;
    font-weight: bold;
    color: #333;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.qty-btn:hover:not(:disabled) {
    background: #f0f0f0;
    border-color: #999;
}

.qty-btn:active:not(:disabled) {
    background: #e0e0e0;
}

.qty-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.qty-input {
    width: 60px;
    height: 36px;
    text-align: center;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 600;
}

.qty-input:focus {
    outline: none;
    border-color: #3498db;
}

.qty-input:disabled {
    background: #f5f5f5;
    cursor: not-allowed;
}

/* Component subtotal */
.woo-adst-component-subtotal {
    text-align: right;
    min-width: 100px;
}

.subtotal-label {
    display: block;
    font-size: 0.85em;
    color: #666;
    margin-bottom: 4px;
}

.subtotal-value {
    display: block;
    font-size: 1.1em;
    font-weight: 600;
    color: #333;
}

/* Summary section */
.woo-adst-composite-summary {
    background: #fff;
    padding: 20px;
    border: 2px solid #3498db;
    border-radius: 4px;
    margin-bottom: 15px;
}

.woo-adst-composite-total-quantity,
.woo-adst-composite-total-price {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
    font-size: 1.1em;
}

.woo-adst-composite-total-quantity:last-child,
.woo-adst-composite-total-price:last-child {
    margin-bottom: 0;
}

.woo-adst-composite-summary .label {
    font-weight: 600;
    color: #333;
}

.woo-adst-composite-summary .value {
    font-weight: 700;
    color: #3498db;
    font-size: 1.2em;
}

.woo-adst-composite-summary .constraint {
    font-size: 0.9em;
    color: #666;
    margin-left: 8px;
}

/* Discount status */
.woo-adst-composite-discount-status {
    margin-top: 15px;
    text-align: center;
}

.discount-badge {
    display: inline-block;
    background: #27ae60;
    color: #fff;
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.95em;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

/* Error messages */
.woo-adst-composite-errors {
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    border-radius: 4px;
    padding: 15px;
    margin-bottom: 15px;
}

.woo-adst-composite-errors ul {
    margin: 0;
    padding-left: 20px;
    list-style: disc;
}

.woo-adst-composite-errors li {
    color: #721c24;
    margin-bottom: 5px;
}

.woo-adst-composite-errors li:last-child {
    margin-bottom: 0;
}

/* No components message */
.woo-adst-composite-no-components {
    padding: 20px;
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 4px;
    color: #856404;
    text-align: center;
}

/* Responsive design */
@media (max-width: 768px) {
    .woo-adst-component-item {
        grid-template-columns: 80px 1fr;
        gap: 10px;
    }
    
    .woo-adst-component-image {
        width: 80px;
        height: 80px;
    }
    
    .woo-adst-component-footer-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .woo-adst-component-subtotal {
        grid-column: 1 / -1;
        text-align: center;
        margin-top: 10px;
    }
    
    .woo-adst-composite-summary .label,
    .woo-adst-composite-summary .value {
        font-size: 1em;
    }
}

@media (max-width: 480px) {
    .woo-adst-composite-selector {
        padding: 15px;
    }
    
    .woo-adst-component-item {
        grid-template-columns: 1fr;
        text-align: center;
    }
    
    .woo-adst-component-image {
        margin: 0 auto;
    }
    
    .woo-adst-component-details {
        text-align: center;
    }
    
    .qty-btn {
        width: 40px;
        height: 40px;
    }
    
    .qty-input {
        width: 70px;
        height: 40px;
    }
}

/* Cart Display Styles */

/* Cart component breakdown */
.woo-adst-cart-composite-breakdown {
    margin: 15px 0;
    padding: 15px;
    background: #f9f9f9;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
}

.woo-adst-cart-composite-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 2px solid #ddd;
}

.woo-adst-cart-composite-header strong {
    font-size: 1.05em;
    color: #333;
}

.woo-adst-discount-badge-inline {
    display: inline-block;
    background: #27ae60;
    color: #fff;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.85em;
    font-weight: 600;
}

/* Components table in cart */
.woo-adst-cart-components-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
}

.woo-adst-cart-components-table thead th {
    text-align: left;
    padding: 8px;
    background: #fff;
    border-bottom: 2px solid #ddd;
    font-weight: 600;
    font-size: 0.9em;
    color: #666;
}

.woo-adst-cart-components-table tbody td {
    padding: 10px 8px;
    border-bottom: 1px solid #e0e0e0;
    vertical-align: middle;
}

.woo-adst-cart-components-table tbody tr:last-child td {
    border-bottom: none;
}

.woo-adst-cart-components-table .component-name {
    font-weight: 500;
    color: #333;
}

.woo-adst-cart-components-table .component-quantity {
    text-align: center;
    font-weight: 600;
}

.woo-adst-cart-components-table .component-price,
.woo-adst-cart-components-table .component-subtotal {
    text-align: right;
    font-weight: 500;
}

.woo-adst-cart-components-table .discount-indicator {
    margin-left: 5px;
    font-size: 1.1em;
}

.woo-adst-cart-components-table tfoot {
    border-top: 2px solid #ddd;
}

.woo-adst-cart-components-table tfoot td {
    padding: 10px 8px;
    font-size: 1.05em;
}

.woo-adst-cart-components-table .total-row td {
    background: #f5f5f5;
}

/* Simple component list (for item data) */
.woo-adst-cart-components {
    margin: 5px 0;
}

.woo-adst-cart-component-item {
    padding: 5px 0;
    font-size: 0.95em;
    line-height: 1.6;
}

.woo-adst-cart-component-item .component-name {
    font-weight: 500;
    color: #333;
}

.woo-adst-cart-component-item .component-quantity {
    font-weight: 600;
    color: #3498db;
}

.woo-adst-cart-component-item .component-price {
    color: #666;
}

.woo-adst-cart-component-item .component-subtotal {
    font-weight: 600;
    color: #333;
}

.woo-adst-cart-component-item .discount-indicator {
    margin-left: 3px;
    font-size: 1em;
}

/* Discount badge in item data */
.woo-adst-discount-badge {
    display: inline-block;
    background: #27ae60;
    color: #fff;
    padding: 3px 10px;
    border-radius: 10px;
    font-size: 0.85em;
    font-weight: 600;
}

/* Responsive cart display */
@media (max-width: 768px) {
    .woo-adst-cart-components-table {
        font-size: 0.9em;
    }
    
    .woo-adst-cart-components-table thead th,
    .woo-adst-cart-components-table tbody td,
    .woo-adst-cart-components-table tfoot td {
        padding: 6px 4px;
    }
    
    .woo-adst-cart-composite-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
}

@media (max-width: 480px) {
    .woo-adst-cart-components-table {
        font-size: 0.85em;
    }
    
    .woo-adst-cart-components-table thead {
        display: none;
    }
    
    .woo-adst-cart-components-table tbody tr {
        display: block;
        margin-bottom: 15px;
        border: 1px solid #e0e0e0;
        border-radius: 4px;
        padding: 10px;
    }
    
    .woo-adst-cart-components-table tbody td {
        display: block;
        text-align: left !important;
        padding: 5px 0;
        border: none;
    }
    
    .woo-adst-cart-components-table tbody td:before {
        content: attr(data-label);
        font-weight: 600;
        margin-right: 10px;
        color: #666;
    }
    
    .woo-adst-cart-components-table tfoot tr {
        display: block;
        border: 2px solid #3498db;
        border-radius: 4px;
        padding: 10px;
    }
    
    .woo-adst-cart-components-table tfoot td {
        display: inline;
        padding: 0;
    }
}

/* Sold Out Component Styles */
.woo-adst-component-item.sold-out {
    opacity: 0.6;
    pointer-events: none;
    position: relative;
}

.woo-adst-component-item.sold-out::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.7);
    pointer-events: none;
}

.woo-adst-component-item.sold-out .woo-adst-component-image img {
    filter: grayscale(100%);
}

.woo-adst-component-item.sold-out .woo-adst-component-name {
    color: #999;
}

.woo-adst-component-item.sold-out .qty-btn,
.woo-adst-component-item.sold-out .qty-input {
    cursor: not-allowed;
    background-color: #f5f5f5;
    color: #999;
}

.woo-adst-component-stock .sold-out-badge {
    background-color: #dc3545;
    color: white;
    padding: 4px 8px;
    border-radius: 3px;
    font-weight: bold;
    font-size: 0.9em;
    text-transform: uppercase;
}
