/* SunPal BOQ Calculator Styles */
.sunpal-calculator {
    margin: 20px 0;
    padding: 20px;
    background: #f9f9f9;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.sunpal-calculator h3 {
    margin-top: 0;
    color: #333;
    text-align: center;
    border-bottom: 2px solid var(--wp--preset--color--accent) !important;
    padding-bottom: 15px;
    font-size: 1.3em;
    line-height: 1.4;
}

/* Calculator Notes */
.calculator-notes {
    background: linear-gradient(135deg, #fff3cd 0%, #fef9e7 100%);
    border: 1px solid #ffeaa7;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 25px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
    margin-bottom: 25px;
}

.calculator-notes h4 {
    color: #856404;
    margin: 0 0 15px 0;
    font-weight: bold;
    font-size: 1.1em;
    text-align: center;
}

.notes-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

.note-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 8px;
    background: rgba(255, 255, 255, 0.6);
    border-radius: 6px;
    border-left: 3px solid #f39c12;
    text-align: left;
}

.note-icon {
    font-size: 16px;
    flex-shrink: 0;
    margin-top: 2px;
}

.note-text {
    color: #856404;
    font-size: 14px;
    line-height: 1.4;
    font-weight: 500;
    text-align: left;
}

/* Form Styles */
.calculator-form {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 15px;
    margin-bottom: 20px;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group label {
    font-weight: bold;
    margin-bottom: 5px;
    color: #555;
}

.form-group input,
.form-group select {
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 16px;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--wp--preset--color--accent) !important;
    box-shadow: 0 0 5px rgba(0,115,170,0.3);
}

.calculate-btn {
    grid-column: 1 / -1;
    /* background: var(--wp--preset--color--accent) !important;
    color: white;
    padding: 15px 30px;
    border: none;
    border-radius: 4px;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.3s ease;
    margin-top: 10px; */
}

.calculate-btn:hover {
    background: #0056b3;
}

.calculate-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* Results Table */
.calculator-results {
    margin-top: 30px;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    width: 100%;
    max-width: none;
    overflow-x: auto; /* Enable horizontal scrolling */
}

.results-header {
    background: var(--wp--preset--color--accent) !important;
    color: white;
    padding: 20px;
    text-align: center;
}

.results-header h4 {
    color: white;
    margin: 0 0 5px 0;
    font-size: 20px;
    font-weight: bold;
}

.results-header p {
    margin: 0;
    font-size: 14px;
    opacity: 0.9;
}

.bom-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px; /* Reduced since fewer columns */
    table-layout: fixed; /* Fixed layout for better control */
}

.bom-table th {
    background: #f8f9fa;
    padding: 12px;
    text-align: left;
    border-bottom: 2px solid #dee2e6;
    font-weight: bold;
    color: #495057;
}

.bom-table td {
    padding: 5px 10px; /* Updated padding as requested */
    border-bottom: 1px solid #dee2e6;
    vertical-align: middle;
}

/* Set specific column widths for new layout */
.bom-table th:nth-child(1), /* Image/SKU */
.bom-table td:nth-child(1) {
    width: 15%;
    min-width: 90px;
    text-align: center;
}

.bom-table th:nth-child(2), /* Description */
.bom-table td:nth-child(2) {
    width: 35%;
    min-width: 200px;
    text-align: left; /* Left align as requested */
}

.bom-table th:nth-child(3), /* Price */
.bom-table td:nth-child(3) {
    width: 15%;
    min-width: 80px;
    text-align: right;
}

.bom-table th:nth-child(4), /* Unit */
.bom-table td:nth-child(4) {
    width: 15%;
    min-width: 80px;
    text-align: center;
}

.bom-table th:nth-child(5), /* Quantity */
.bom-table td:nth-child(5) {
    width: 10%;
    min-width: 60px;
    text-align: center;
}

.bom-table th:nth-child(6), /* Total */
.bom-table td:nth-child(6) {
    width: 15%;
    min-width: 80px;
    text-align: right;
}

/* Image and SKU cell styling */
.image-sku-cell {
    text-align: center;
    padding: 8px 5px;
}

.product-image {
    width: 45px;
    height: 45px;
    object-fit: contain;
    border-radius: 4px;
    display: block;
    margin: 0 auto 4px auto;
}

.product-sku {
    font-size: 11px;
    color: #666;
    font-weight: 500;
    line-height: 1.2;
}

/* Description cell styling */
.product-description {
    text-align: left;
}

.product-name {
    font-weight: bold;
    color: #333;
    line-height: 1.3;
}

/* Other cell styling */
.price-cell, .total-cell {
    font-weight: 500;
    color: #2c3e50;
}

.unit-cell {
    font-size: 14px;
    font-weight: 500;
}

.quantity-cell {
    font-weight: bold;
    color: var(--wp--preset--color--accent) !important;
    font-size: 16px;
}

.bom-table tr:hover {
    background: #f8f9fa;
}

.product-image {
    width: 50px;
    height: 50px;
    object-fit: contain;
    border-radius: 4px;
}

.product-name {
    font-weight: bold;
    color: #333;
}

.product-sku {
    color: #666;
    font-size: 14px;
}

.quantity-cell {
    text-align: center;
    font-weight: bold;
    color: var(--wp--preset--color--accent) !important;
    font-size: 16px;
}

.add-to-cart-btn {
    background: #28a745;
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    transition: background-color 0.3s ease;
    white-space: nowrap; /* Prevent text wrapping */
    min-width: 80px; /* Ensure minimum button width */
}

.add-to-cart-btn:hover {
    background: #218838;
}

.add-to-cart-btn:disabled {
    background: #6c757d;
    cursor: not-allowed;
}

/* .add-all-to-cart {
    background: #007bff;
    color: white;
    border: none;
    padding: 15px 30px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    margin: 20px;
    transition: background-color 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
} */

.add-all-to-cart:hover {
    background: #0056b3;
}

.add-all-to-cart:disabled {
    background: #6c757d;
    cursor: not-allowed;
}

.btn-loading {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.loading-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid #ffffff40;
    border-top: 2px solid #ffffff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.cart-message {
    padding: 12px 20px;
    border-radius: 4px;
    font-weight: bold;
    text-align: center;
    margin: 10px auto;
    max-width: 600px;
}

.cart-message.success {
    background-color: #d4edda;
    border: 1px solid #c3e6cb;
    color: #155724;
}

.cart-message.error {
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
}

.cart-message.warning {
    background-color: #fff3cd;
    border: 1px solid #ffeaa7;
    color: #856404;
}

.loading {
    text-align: center;
    padding: 40px;
    color: #666;
    font-size: 18px;
}

.loading::after {
    content: "";
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid var(--wp--preset--color--accent) !important;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-left: 10px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Default desktop styles - table visible, cards hidden */
.bom-table-container {
    display: block;
}

.mobile-card-view {
    display: none;
}

/* Responsive design */
@media (max-width: 768px) {
    .sunpal-calculator {
        margin: 10px;
        padding: 15px;
    }
    
    .sunpal-calculator h3 {
        font-size: 1.1em;
        line-height: 1.3;
    }
    
    .calculator-form {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .notes-grid {
        gap: 8px;
    }
    
    .note-item {
        padding: 6px;
    }
    
    .note-text {
        font-size: 13px;
    }
    
    /* Keep table visible on tablets and show horizontal scroll */
    .calculator-results {
        border: 1px solid #ddd;
        margin: 15px -15px; /* Extend to edges */
        border-radius: 0;
    }
    
    .bom-table {
        font-size: 12px;
        min-width: 500px; /* Smaller but still scrollable */
    }
    
    .bom-table th,
    .bom-table td {
        padding: 4px 6px;
    }
    
    .bom-table th {
        font-size: 11px;
        padding: 6px 4px;
    }
    
    /* Mobile-specific column adjustments */
    .product-image {
        width: 35px;
        height: 35px;
    }
    
    .product-sku {
        font-size: 10px;
    }
    
    .product-name {
        font-size: 13px;
        line-height: 1.2;
    }
    
    .quantity-cell {
        font-size: 14px;
    }
    
    .price-cell, .total-cell {
        font-size: 12px;
    }
    
    .unit-cell {
        font-size: 11px;
    }
    
    /* Keep table visible, cards still hidden */
    .bom-table-container {
        display: block;
    }
    
    .mobile-card-view {
        display: none;
    }
}

/* Ultra-small screens - Card layout */
@media (max-width: 480px) {
    .bom-table-container {
        display: none;
    }
    
    .mobile-card-view {
        display: block;
    }
    
    .bom-card {
        background: white;
        border: 1px solid #ddd;
        border-radius: 8px;
        margin-bottom: 15px;
        padding: 15px;
        box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    }
    
    .bom-card-header {
        display: flex;
        align-items: center;
        gap: 10px;
        margin-bottom: 10px;
        padding-bottom: 10px;
        border-bottom: 1px solid #eee;
    }
    
    .bom-card .product-image {
        width: 50px;
        height: 50px;
        flex-shrink: 0;
    }
    
    .bom-card-info {
        flex: 1;
    }
    
    .bom-card .product-name {
        font-size: 14px;
        font-weight: bold;
        margin-bottom: 4px;
    }
    
    .bom-card .product-sku {
        font-size: 12px;
        color: #666;
    }
    
    .bom-card-details {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
        font-size: 13px;
    }
    
    .bom-card-detail {
        display: flex;
        justify-content: space-between;
        align-items: center;
    }
    
    .bom-card-detail strong {
        color: #333;
    }
}

@media (max-width: 1024px) and (min-width: 769px) {
    .calculator-form {
        grid-template-columns: 1fr 1fr;
    }
}

/* WooCommerce Integration Styles */
.calculator-message {
    padding: 10px 15px;
    margin-bottom: 15px;
    border-radius: 4px;
    font-weight: bold;
}

.calculator-message.success {
    background-color: #d4edda;
    border: 1px solid #c3e6cb;
    color: #155724;
}

.calculator-message.error {
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
}

.calculator-message.warning {
    background-color: #fff3cd;
    border: 1px solid #ffeaa7;
    color: #856404;
}

.total-row {
    background-color: #f8f9fa;
    font-weight: bold;
    border-top: 2px solid var(--wp--preset--color--accent) !important;
}

.grand-total {
    font-size: 1.2em;
    color: var(--wp--preset--color--accent) !important;
}

.total-cell {
    font-weight: bold;
    color: #2c3e50;
}

.view-cart-btn {
    display: inline-block;
    padding: 10px 20px;
    background-color: #2c3e50;
    color: white;
    text-decoration: none;
    border-radius: 4px;
    transition: background-color 0.3s;
}

.view-cart-btn:hover {
    background-color: #34495e;
    color: white;
    text-decoration: none;
}

.no-woocommerce {
    color: #7f8c8d;
    font-style: italic;
    font-size: 12px;
}

.add-to-cart-btn:disabled {
    background-color: #bdc3c7;
    cursor: not-allowed;
    opacity: 0.6;
}

.add-to-cart-btn:disabled:hover {
    background-color: #bdc3c7;
}

/* Product link styling */
.product-name a {
    color: var(--wp--preset--color--accent) !important;
    text-decoration: none;
}

.product-name a:hover {
    text-decoration: underline;
}