/**
 * TPS Quick Order System - List View Styles
 * Version: 5.0
 */

/* Reset and Base Styles */
.tps-qo-wrapper * {
    box-sizing: border-box;
}

/* Full width container - clean white background */
.tps-qo-fullwidth-wrapper {
    width: 100%;
    background-color: #fff;
    padding: 0;
    min-height: calc(100vh - 200px);
}

.tps-qo-wrapper {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

/* Header Section with Brand Color */
.tps-qo-header-section {
    background: linear-gradient(135deg, #45aad3 0%, #3a92b8 100%);
    padding: 25px 20px;
    margin: 0 -20px 25px -20px;
    border-radius: 0 0 20px 20px;
}

/* Page Title */
.tps-qo-page-title {
    font-size: 32px;
    font-weight: 700;
    color: #fff;
    margin: 0;
    text-align: center;
    text-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Main Content Layout */
.tps-qo-main-content {
    display: block;
}

/* Products List Container */
.tps-qo-products-section {
    margin-bottom: 25px;
}

.tps-qo-products-list {
    display: flex;
    flex-direction: column;
    gap: 0;
    border: 1px solid #e8e8e8;
    border-radius: 0 0 10px 10px;
    overflow: hidden;
}

/* List Header */
.tps-qo-list-header {
    display: grid;
    grid-template-columns: 1fr 140px 120px 200px;
    gap: 15px;
    padding: 12px 20px;
    background: #45aad3;
    border-radius: 10px 10px 0 0;
    font-size: 12px;
    font-weight: 600;
    color: white;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.tps-qo-list-header span {
    display: flex;
    align-items: center;
}

.tps-qo-list-header span:nth-child(2),
.tps-qo-list-header span:nth-child(3),
.tps-qo-list-header span:nth-child(4) {
    justify-content: center;
}

/* Product Row */
.tps-qo-product-row {
    display: grid;
    grid-template-columns: 1fr 140px 120px 200px;
    gap: 15px;
    align-items: center;
    padding: 14px 20px;
    background: white;
    border-bottom: 1px solid #eee;
    transition: all 0.2s ease;
}

.tps-qo-product-row:last-child {
    border-bottom: none;
}

/* Alternating row colors */
.tps-qo-product-row:nth-child(even) {
    background: #f9fbfc;
}

/* Row without variant - adjust grid */
.tps-qo-product-row.no-variant {
    grid-template-columns: 1fr 120px 200px;
}

.tps-qo-product-row:hover {
    background: #f0f7fa;
}

.tps-qo-product-row.disabled {
    opacity: 0.6;
    background: #f9f9f9;
}

/* Product Info */
.tps-qo-row-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.tps-qo-row-name {
    font-size: 15px;
    font-weight: 600;
    color: #333;
    margin: 0;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tps-qo-row-meta {
    display: flex;
    gap: 8px;
    align-items: center;
}

.tps-qo-row-stock {
    font-size: 11px;
    font-weight: 500;
    padding: 2px 8px;
    border-radius: 10px;
}

.tps-qo-row-stock.in-stock {
    background: #e8f5e9;
    color: #2e7d32;
}

.tps-qo-row-stock.out-of-stock {
    background: #ffebee;
    color: #f44336;
}

/* Variant Selector */
.tps-qo-row-variant {
    display: flex;
    align-items: center;
    justify-content: center;
}

.tps-qo-variant-select {
    width: 100%;
    max-width: 140px;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 13px;
    background: white;
    cursor: pointer;
    transition: all 0.2s ease;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 30px;
}

.tps-qo-variant-select:hover {
    border-color: #45aad3;
}

.tps-qo-variant-select:focus {
    outline: none;
    border-color: #45aad3;
    box-shadow: 0 0 0 3px rgba(69, 170, 211, 0.1);
}

.tps-qo-variant-select:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Price */
.tps-qo-row-price {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.tps-qo-row-current {
    font-size: 18px;
    font-weight: 700;
    color: #45aad3;
}

.tps-qo-row-original {
    font-size: 13px;
    color: #999;
    text-decoration: line-through;
}

.tps-qo-row-sale {
    font-size: 18px;
    font-weight: 700;
    color: #45aad3;
}

.tps-qo-row-discount {
    background: #ff4757;
    color: white;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
}

/* Quantity Controls */
.tps-qo-row-qty {
    display: flex;
    align-items: center;
    justify-content: center;
}

.tps-qo-qty-btn {
    width: 32px;
    height: 32px;
    border: 1px solid #ddd;
    background: #f8f8f8;
    cursor: pointer;
    font-size: 18px;
    color: #666;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tps-qo-qty-btn:hover:not(:disabled) {
    background: #45aad3;
    color: white;
    border-color: #45aad3;
}

.tps-qo-qty-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.tps-qo-qty-minus {
    border-radius: 6px 0 0 6px;
}

.tps-qo-qty-plus {
    border-radius: 0 6px 6px 0;
}

.tps-qo-qty-input {
    width: 50px;
    height: 32px;
    border: 1px solid #ddd;
    border-left: none;
    border-right: none;
    text-align: center;
    font-size: 14px;
    font-weight: 600;
    -moz-appearance: textfield;
}

.tps-qo-qty-input::-webkit-outer-spin-button,
.tps-qo-qty-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.tps-qo-qty-input:focus {
    outline: none;
}

/* Combined Actions (Qty + Add Button) */
.tps-qo-row-actions {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

/* Add to Cart Button */
.tps-qo-row-add {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 20px;
    background: #45aad3;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.tps-qo-row-add:hover:not(:disabled) {
    background: #3a92b8;
    transform: scale(1.02);
}

.tps-qo-row-add:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.tps-qo-row-add.loading {
    background: #00acc1;
}

.tps-qo-row-add.added {
    background: #4caf50;
}

.tps-qo-row-add-icon {
    flex-shrink: 0;
}

/* Out of Stock Section */
.tps-qo-out-of-stock-section {
    margin-top: 20px;
}

.tps-qo-oos-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 14px 20px;
    background: #f5f5f5;
    border: 1px dashed #ccc;
    border-radius: 8px;
    color: #666;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.tps-qo-oos-toggle:hover {
    background: #eee;
    border-color: #999;
    color: #333;
}

.tps-qo-oos-toggle.active {
    border-radius: 8px 8px 0 0;
    border-bottom: none;
    background: #f0f0f0;
}

.tps-qo-oos-toggle.active .tps-qo-oos-arrow {
    transform: rotate(180deg);
}

.tps-qo-oos-arrow {
    transition: transform 0.3s ease;
}

.tps-qo-oos-content {
    border: 1px dashed #ccc;
    border-top: none;
    border-radius: 0 0 8px 8px;
    overflow: hidden;
}

.tps-qo-oos-list {
    border: none !important;
    border-radius: 0 !important;
}

.tps-qo-oos-list .tps-qo-product-row {
    background: #fafafa;
}

.tps-qo-oos-list .tps-qo-product-row:nth-child(even) {
    background: #f5f5f5;
}

/* Cart Summary */
.tps-qo-cart-sidebar {
    width: 100%;
    max-width: 500px;
    margin: 30px auto 0;
}

.tps-qo-cart-container {
    background: white;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 2px 15px rgba(0,0,0,0.08);
    border: 1px solid #e8e8e8;
}

.tps-qo-cart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 16px;
    border-bottom: 2px solid #f0f0f0;
    margin-bottom: 16px;
}

.tps-qo-cart-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #333;
}

.tps-qo-cart-count {
    background: #45aad3;
    color: white;
    padding: 5px 14px;
    border-radius: 15px;
    font-size: 12px;
    font-weight: 600;
}

.tps-qo-cart-items {
    max-height: 200px;
    overflow-y: auto;
    margin-bottom: 16px;
}

.tps-qo-cart-empty {
    text-align: center;
    color: #999;
    padding: 30px;
    font-size: 14px;
}

.tps-qo-cart-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid #f5f5f5;
    gap: 10px;
}

.tps-qo-cart-item:last-child {
    border-bottom: none;
}

.tps-qo-cart-item-name {
    flex: 1;
    font-size: 14px;
    color: #333;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tps-qo-cart-item-qty {
    color: #888;
    font-size: 13px;
    min-width: 35px;
    text-align: center;
}

.tps-qo-cart-item-price {
    font-weight: 600;
    color: #45aad3;
    min-width: 60px;
    text-align: right;
}

.tps-qo-cart-footer {
    border-top: 2px solid #f0f0f0;
    padding-top: 16px;
}

.tps-qo-cart-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    font-size: 18px;
    font-weight: 600;
}

.tps-qo-cart-total span:last-child {
    color: #45aad3;
    font-size: 24px;
}

.tps-qo-checkout-btn,
.tps-qo-view-cart-btn {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-bottom: 10px;
    text-decoration: none !important;
    display: block;
    text-align: center;
}

.tps-qo-checkout-btn {
    background: #45aad3;
    color: white !important;
}

.tps-qo-checkout-btn:hover {
    background: #3a92b8;
    color: white !important;
}

.tps-qo-view-cart-btn {
    background: white;
    color: #45aad3 !important;
    border: 2px solid #45aad3;
    margin-bottom: 0;
}

.tps-qo-view-cart-btn:hover {
    background: #f0fafb;
    color: #3a92b8 !important;
}

/* Loading State */
.tps-qo-loading {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255,255,255,0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.tps-qo-spinner {
    width: 45px;
    height: 45px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #45aad3;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* No Products Message */
.tps-no-products {
    text-align: center;
    padding: 60px 20px;
    color: #999;
    font-size: 16px;
    background: white;
    border-radius: 8px;
}

/* Toast Notifications */
.tps-qo-toast {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background: #333;
    color: white;
    padding: 14px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    z-index: 10000;
    animation: slideInUp 0.3s ease;
    max-width: 300px;
    font-size: 14px;
}

.tps-qo-toast.success {
    background: #4caf50;
}

.tps-qo-toast.error {
    background: #f44336;
}

@keyframes slideInUp {
    from {
        transform: translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */

/* Tablet */
@media (max-width: 992px) {
    .tps-qo-header-section {
        margin: 0 -20px 20px -20px;
        padding: 20px;
    }
    
    .tps-qo-list-header { display: none; }
    
    .tps-qo-products-list {
        border-radius: 10px;
    }
    
    .tps-qo-product-row,
    .tps-qo-product-row.no-variant {
        display: flex;
        flex-wrap: wrap;
        gap: 12px;
        padding: 16px;
    }
    
    .tps-qo-row-info {
        width: 100%;
        order: 1;
    }
    
    .tps-qo-row-price {
        order: 2;
        flex-direction: row;
        gap: 10px;
        align-items: center;
    }
    
    .tps-qo-row-variant {
        order: 3;
        flex: 1;
        min-width: 120px;
    }
    
    .tps-qo-variant-select {
        max-width: none;
        width: 100%;
    }
    
    .tps-qo-row-actions {
        order: 4;
        width: 100%;
        justify-content: flex-end;
    }
}

/* Mobile */
@media (max-width: 576px) {
    .tps-qo-fullwidth-wrapper {
        padding: 0;
    }
    
    .tps-qo-wrapper {
        padding: 0 12px;
    }
    
    .tps-qo-header-section {
        margin: 0 -12px 20px -12px;
        padding: 15px;
        border-radius: 0 0 15px 15px;
    }
    
    .tps-qo-page-title {
        font-size: 24px;
    }
    
    .tps-qo-products-list {
        gap: 0;
        border-radius: 10px;
    }
    
    .tps-qo-product-row,
    .tps-qo-product-row.no-variant {
        padding: 14px;
        display: flex;
        flex-direction: column;
        gap: 10px;
    }
    
    .tps-qo-row-name {
        font-size: 14px;
    }
    
    .tps-qo-row-meta {
        flex-wrap: wrap;
    }
    
    .tps-qo-row-price {
        order: 2;
        flex-direction: row;
        gap: 8px;
        align-items: center;
    }
    
    .tps-qo-row-variant {
        order: 3;
        width: 100%;
    }
    
    .tps-qo-row-current,
    .tps-qo-row-sale {
        font-size: 16px;
    }
    
    .tps-qo-row-actions {
        order: 4;
        width: 100%;
        justify-content: space-between;
    }
    
    .tps-qo-row-qty {
        flex: 0 0 auto;
    }
    
    .tps-qo-qty-btn {
        width: 36px;
        height: 36px;
    }
    
    .tps-qo-qty-input {
        width: 45px;
        height: 36px;
    }
    
    .tps-qo-row-add {
        flex: 1;
        max-width: 100px;
        padding: 10px 12px;
    }
    
    /* Cart Summary Mobile */
    .tps-qo-cart-sidebar {
        margin-top: 20px;
    }
    
    .tps-qo-cart-container {
        padding: 16px;
        border-radius: 10px;
    }
    
    .tps-qo-cart-total span:last-child {
        font-size: 20px;
    }
    
    .tps-qo-checkout-btn,
    .tps-qo-view-cart-btn {
        padding: 12px;
        font-size: 15px;
    }
    
    /* Toast Mobile */
    .tps-qo-toast {
        left: 12px;
        right: 12px;
        bottom: 20px;
        max-width: none;
    }
}

/* Touch-friendly adjustments */
@media (hover: none) and (pointer: coarse) {
    .tps-qo-qty-btn,
    .tps-qo-row-add {
        min-height: 44px;
    }
    
    .tps-qo-product-row {
        -webkit-tap-highlight-color: transparent;
    }
}
