/**
 * BBWA Cart Table Widget Styles
 *
 * @package BB_WooAutomate
 * @since 2.0.0
 */

/* ============================================
   Cart Table Wrapper
   ============================================ */

.bbwa-cart-table-wrapper {
    width: 100%;
}

.bbwa-cart-table {
    width: 100%;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    overflow: hidden;
}

/* ============================================
   Cart Header Row
   ============================================ */

.bbwa-cart-header-row {
    display: grid;
    grid-template-columns: 1fr auto auto auto;
    gap: 16px;
    align-items: center;
    padding: 12px 16px;
    background: #f8fafc;
    border-bottom: 1px solid #e5e7eb;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #64748b;
}

/* With thumbnail - match cart item grid */
.bbwa-cart-header-row.bbwa-has-thumbnail {
    grid-template-columns: 80px 1fr auto auto auto;
}

.bbwa-cart-header-cell {
    white-space: nowrap;
}

.bbwa-header-image {
    width: 80px;
}

.bbwa-header-product {
    text-align: left;
}

.bbwa-header-quantity {
    text-align: center;
    min-width: 122px; /* Match qty selector width */
}

.bbwa-header-subtotal {
    text-align: right;
    min-width: 100px;
}

.bbwa-header-actions {
    width: 32px;
}

/* ============================================
   Cart Items Container
   ============================================ */

.bbwa-cart-items {
    width: 100%;
}

/* ============================================
   Cart Actions (Update Button)
   ============================================ */

.bbwa-cart-actions {
    display: flex;
    justify-content: flex-end;
    padding: 16px;
    border-top: 1px solid #e5e7eb;
    background: #f9fafb;
}

.bbwa-update-cart-btn {
    padding: 10px 24px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.bbwa-update-cart-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.bbwa-update-cart-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: #94a3b8;
}

.bbwa-update-cart-btn.bbwa-updating {
    position: relative;
    color: transparent;
}

.bbwa-update-cart-btn.bbwa-updating::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: bbwa-spin 0.8s linear infinite;
}

/* ============================================
   Cart Item Row
   ============================================ */

.bbwa-cart-item {
    display: grid;
    grid-template-columns: 80px 1fr auto auto auto;
    gap: 16px;
    align-items: center;
    padding: 16px;
    border-bottom: 1px solid #e5e7eb;
    background: #fff;
    transition: background-color 0.2s ease;
}

/* Without thumbnail */
.bbwa-cart-table-wrapper[data-no-thumbnail="true"] .bbwa-cart-item {
    grid-template-columns: 1fr auto auto auto;
}

.bbwa-cart-item:last-child {
    border-bottom: none;
}

.bbwa-cart-item:hover {
    background-color: #f9fafb;
}

/* ============================================
   Product Thumbnail
   ============================================ */

.bbwa-cart-item-thumbnail {
    width: 80px;
    height: 80px;
    flex-shrink: 0;
}

.bbwa-cart-item-thumbnail a {
    display: block;
}

.bbwa-cart-item-thumbnail img {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
}

/* ============================================
   Product Details
   ============================================ */

.bbwa-cart-item-details {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.bbwa-cart-item-name {
    font-size: 15px;
    font-weight: 500;
    line-height: 1.4;
}

.bbwa-cart-item-name a {
    color: #1e293b;
    text-decoration: none;
    transition: color 0.2s ease;
}

.bbwa-cart-item-name a:hover {
    color: #667eea;
}

.bbwa-cart-item-name .variation {
    display: block;
    font-size: 13px;
    font-weight: 400;
    color: #64748b;
    margin-top: 4px;
}

.bbwa-cart-item-name .variation dt,
.bbwa-cart-item-name .variation dd {
    display: inline;
    margin: 0;
}

.bbwa-cart-item-name .variation dt::after {
    content: ': ';
}

.bbwa-cart-item-name .variation dd::after {
    content: '';
    display: block;
}

.bbwa-cart-item-sku {
    display: block;
    font-size: 12px;
    color: #94a3b8;
    margin-top: 4px;
}

.bbwa-cart-item-price {
    font-size: 14px;
    color: #64748b;
}

/* ============================================
   Quantity Controls
   ============================================ */

.bbwa-cart-item-quantity {
    display: flex;
    align-items: center;
}

.bbwa-qty-wrapper {
    display: flex;
    align-items: center;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
}

.bbwa-qty-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: #667eea;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 0;
}

.bbwa-qty-btn:hover {
    background: #667eea;
    color: #fff;
}

.bbwa-qty-btn:active {
    transform: scale(0.95);
}

/* Trash icon in qty selector */
.bbwa-qty-trash {
    color: #ef4444;
}

.bbwa-qty-trash:hover {
    background: #fef2f2;
    color: #dc2626;
}

.bbwa-qty-wrapper.bbwa-qty-trash-mode {
    border-color: #fecaca;
}

.bbwa-qty-btn svg {
    width: 16px;
    height: 16px;
}

.bbwa-qty-input {
    width: 50px;
    height: 36px;
    text-align: center;
    border: none;
    border-left: 1px solid #e5e7eb;
    border-right: 1px solid #e5e7eb;
    font-size: 14px;
    font-weight: 500;
    color: #1e293b;
    background: #fff;
    -moz-appearance: textfield;
    appearance: textfield;
}

.bbwa-qty-input::-webkit-outer-spin-button,
.bbwa-qty-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.bbwa-qty-input:focus {
    outline: none;
    background: #f8fafc;
}

.bbwa-qty-input-only {
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    width: 60px;
}

/* ============================================
   Subtotal
   ============================================ */

.bbwa-cart-item-subtotal {
    font-size: 15px;
    font-weight: 600;
    color: #1e293b;
    white-space: nowrap;
    min-width: 100px;
    text-align: right;
}

/* ============================================
   Remove Button
   ============================================ */

.bbwa-cart-item-actions {
    display: flex;
    align-items: center;
}

.bbwa-cart-item-remove {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: #ef4444;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s ease;
    padding: 0;
}

.bbwa-cart-item-remove:hover {
    background: #fef2f2;
    color: #dc2626;
}

.bbwa-cart-item-remove svg {
    width: 20px;
    height: 20px;
}

/* ============================================
   Empty Cart
   ============================================ */

.bbwa-cart-empty {
    text-align: center;
    padding: 60px 20px;
    background: #f8fafc;
    border-radius: 12px;
    border: 2px dashed #e2e8f0;
}

.bbwa-cart-empty-icon {
    color: #cbd5e1;
    margin-bottom: 16px;
}

.bbwa-cart-empty-icon svg {
    width: 64px;
    height: 64px;
}

.bbwa-cart-empty-text {
    font-size: 16px;
    color: #64748b;
    margin: 0 0 24px 0;
}

.bbwa-btn-return-shop {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.2s ease;
}

.bbwa-btn-return-shop:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
    color: #fff;
}

/* ============================================
   Loading State
   ============================================ */

.bbwa-cart-item.bbwa-loading {
    opacity: 0.5;
    pointer-events: none;
}

.bbwa-cart-item.bbwa-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 24px;
    height: 24px;
    margin: -12px 0 0 -12px;
    border: 2px solid #e5e7eb;
    border-top-color: #667eea;
    border-radius: 50%;
    animation: bbwa-spin 0.8s linear infinite;
}

@keyframes bbwa-spin {
    to {
        transform: rotate(360deg);
    }
}

/* ============================================
   Responsive - Tablet
   ============================================ */

@media (max-width: 768px) {
    .bbwa-cart-header-row {
        display: none;
    }
    
    .bbwa-cart-item {
        grid-template-columns: auto 1fr auto;
        grid-template-rows: auto auto;
        gap: 12px;
    }
    
    .bbwa-cart-item-thumbnail {
        grid-row: span 2;
    }
    
    .bbwa-cart-item-details {
        grid-column: 2;
    }
    
    .bbwa-cart-item-quantity {
        grid-column: 2;
        grid-row: 2;
        justify-self: start;
    }
    
    .bbwa-cart-item-subtotal {
        grid-column: 3;
        grid-row: 2;
    }
    
    .bbwa-cart-item-actions {
        grid-column: 3;
        grid-row: 1;
    }
}

/* ============================================
   Responsive - Mobile
   ============================================ */

@media (max-width: 480px) {
    .bbwa-cart-actions {
        padding: 12px;
    }
    
    .bbwa-update-cart-btn {
        width: 100%;
        padding: 12px;
        text-align: center;
    }
    
    .bbwa-cart-item {
        grid-template-columns: 60px 1fr auto;
        padding: 12px;
    }
    
    .bbwa-cart-item-thumbnail {
        width: 60px;
        height: 60px;
    }
    
    .bbwa-cart-item-thumbnail img {
        width: 60px;
        height: 60px;
    }
    
    .bbwa-cart-item-name {
        font-size: 14px;
    }
    
    .bbwa-cart-item-price {
        font-size: 13px;
    }
    
    .bbwa-qty-btn {
        width: 32px;
        height: 32px;
    }
    
    .bbwa-qty-input {
        width: 40px;
        height: 32px;
        font-size: 13px;
    }
    
    .bbwa-cart-item-subtotal {
        font-size: 14px;
        min-width: auto;
    }
}

/* ============================================
   Loading Overlay
   ============================================ */

.bbwa-cart-items.bbwa-loading-overlay {
    position: relative;
    pointer-events: none;
}

.bbwa-cart-items.bbwa-loading-overlay::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.7);
    z-index: 10;
}

.bbwa-cart-items.bbwa-loading-overlay::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 32px;
    height: 32px;
    margin: -16px 0 0 -16px;
    border: 3px solid #e5e7eb;
    border-top-color: #667eea;
    border-radius: 50%;
    z-index: 11;
    animation: bbwa-spin 0.8s linear infinite;
}

/* ============================================
   Elementor Editor Preview
   ============================================ */

.bbwa-editor-preview .bbwa-cart-item-remove {
    pointer-events: none;
}

.bbwa-editor-preview .bbwa-qty-btn {
    pointer-events: none;
}
