/* Modern, Premium Wholesale Form CSS System */

:root {
    --wholesale-primary: #4f46e5;
    --wholesale-primary-hover: #4338ca;
    --wholesale-primary-light: #e0e7ff;
    --wholesale-text: #1e293b;
    --wholesale-text-light: #64748b;
    --wholesale-border: #e2e8f0;
    --wholesale-bg-card: #ffffff;
    --wholesale-bg-body: #f8fafc;
    --wholesale-success: #10b981;
    --wholesale-error: #ef4444;
    --wholesale-accent: #f59e0b;
    --wholesale-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.05), 0 2px 4px -2px rgb(0 0 0 / 0.05);
    --wholesale-shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.07), 0 4px 6px -4px rgb(0 0 0 / 0.07);
}

.wholesale-order-container {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
    color: var(--wholesale-text);
    background: var(--wholesale-bg-body);
    padding: 30px;
    border-radius: 12px;
    border: 1px solid var(--wholesale-border);
    box-shadow: var(--wholesale-shadow);
    max-width: 1200px;
    margin: 30px auto;
    position: relative;
}

.wholesale-title {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 6px;
    color: var(--wholesale-text);
    letter-spacing: -0.5px;
}

.wholesale-subtitle {
    font-size: 15px;
    color: var(--wholesale-text-light);
    margin-bottom: 25px;
}

/* Filter Bar */
.wholesale-filter-bar {
    display: flex;
    gap: 15px;
    margin-bottom: 25px;
    background: var(--wholesale-bg-card);
    padding: 16px;
    border-radius: 8px;
    border: 1px solid var(--wholesale-border);
    box-shadow: var(--wholesale-shadow);
}

.wholesale-filter-search {
    flex-grow: 1;
    position: relative;
    display: flex;
    align-items: center;
}

.wholesale-filter-search .search-icon {
    position: absolute;
    left: 12px;
    color: var(--wholesale-text-light);
}

.wholesale-search-input {
    width: 100%;
    padding: 10px 12px 10px 40px !important;
    border: 1px solid var(--wholesale-border) !important;
    border-radius: 6px !important;
    font-size: 14px;
    background: #fdfdfd;
    transition: all 0.2s ease-in-out;
}

.wholesale-search-input:focus {
    outline: none !important;
    border-color: var(--wholesale-primary) !important;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15) !important;
    background: #fff;
}

.wholesale-filter-category {
    min-width: 200px;
}

.wholesale-category-select {
    width: 100%;
    padding: 10px 30px 10px 12px !important;
    border: 1px solid var(--wholesale-border) !important;
    border-radius: 6px !important;
    font-size: 14px;
    background: #fdfdfd url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2364748b'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E") no-repeat right 12px center !important;
    background-size: 16px !important;
    appearance: none !important;
    cursor: pointer;
}

.wholesale-category-select:focus {
    outline: none !important;
    border-color: var(--wholesale-primary) !important;
}

/* Table Design */
.wholesale-table-wrapper {
    background: var(--wholesale-bg-card);
    border-radius: 8px;
    border: 1px solid var(--wholesale-border);
    overflow: hidden;
    box-shadow: var(--wholesale-shadow);
    margin-bottom: 110px; /* Space for sticky footer */
}

.wholesale-order-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    margin: 0;
}

.wholesale-order-table th {
    background: #f8fafc;
    padding: 16px 20px;
    font-size: 13px;
    font-weight: 600;
    color: var(--wholesale-text-light);
    border-bottom: 2px solid var(--wholesale-border);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.wholesale-order-table td {
    padding: 16px 20px;
    border-bottom: 1px solid var(--wholesale-border);
    vertical-align: middle;
    font-size: 14px;
}

.wholesale-product-row {
    transition: background 0.15s ease-in-out;
}

.wholesale-product-row:hover {
    background: #fafafa;
}

/* Columns */
.col-image {
    width: 70px;
}
.col-name {
    min-width: 250px;
}
.col-sku {
    width: 120px;
}
.col-price {
    width: 180px;
}
.col-stock {
    width: 160px;
}
.col-qty {
    width: 150px;
}

.wholesale-prod-thumb {
    width: 50px;
    height: 50px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid var(--wholesale-border);
}

.wholesale-prod-title {
    font-weight: 600;
    color: var(--wholesale-text);
    font-size: 15px;
    line-height: 1.4;
}

.wholesale-sku-badge {
    font-family: monospace;
    background: #f1f5f9;
    padding: 4px 8px;
    border-radius: 4px;
    color: #475569;
    font-size: 12px;
}

/* Pricing displays */
.retail-price-crossed {
    text-decoration: line-through;
    color: var(--wholesale-text-light);
    font-size: 12px;
    margin-right: 6px;
    display: inline-block;
}

.wholesale-price-active {
    font-weight: 700;
    color: var(--wholesale-primary);
    font-size: 15px;
    display: inline-block;
}

.no-wholesale-badge {
    background: #fef3c7;
    color: #d97706;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 20px;
    font-weight: 600;
    margin-left: 6px;
    display: inline-block;
    vertical-align: middle;
}

/* Stock Badge */
.stock-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.stock-badge.instock {
    background: #ecfdf5;
    color: #047857;
}

.stock-badge.outofstock {
    background: #fef2f2;
    color: #b91c1c;
}

.stock-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

.instock .stock-dot {
    background: var(--wholesale-success);
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.4);
}

.outofstock .stock-dot {
    background: var(--wholesale-error);
    box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.4);
}

/* Quantity inputs */
.wholesale-qty-selector {
    display: inline-flex;
    align-items: center;
    border: 1px solid var(--wholesale-border);
    border-radius: 6px;
    overflow: hidden;
    width: 110px;
    height: 32px;
    box-sizing: border-box;
    flex-shrink: 0;
}

.qty-btn {
    width: 32px;
    height: 100%;
    background: #f8fafc;
    border: none;
    color: var(--wholesale-text);
    cursor: pointer;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
    flex-shrink: 0;
    padding: 0 !important;
    margin: 0 !important;
    box-shadow: none !important;
}

.qty-btn:hover {
    background: #e2e8f0;
}

.wholesale-qty-input {
    width: 46px;
    height: 100%;
    border: none !important;
    text-align: center;
    font-size: 14px;
    font-weight: 600;
    -moz-appearance: textfield;
    padding: 0 !important;
    margin: 0 !important;
    min-width: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    flex-grow: 1;
}

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

.qty-disabled {
    color: var(--wholesale-text-light);
    font-style: italic;
}

.wholesale-no-products {
    text-align: center;
    padding: 40px !important;
    color: var(--wholesale-text-light);
    font-style: italic;
}

/* Sticky Action Footer */
.wholesale-sticky-footer {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: calc(100% - 60px);
    max-width: 1140px;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(226, 232, 240, 0.8);
    border-radius: 12px;
    padding: 16px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 30px;
    box-shadow: var(--wholesale-shadow-lg);
    z-index: 9999;
    box-sizing: border-box;
}

.wholesale-footer-details {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.wholesale-subtotal-info {
    display: flex;
    align-items: baseline;
    gap: 8px;
}

.wholesale-subtotal-info .label {
    font-size: 14px;
    font-weight: 600;
    color: var(--wholesale-text-light);
}

.wholesale-subtotal-info .value {
    font-size: 20px;
    font-weight: 800;
    color: var(--wholesale-primary);
}

/* Progress bar */
.wholesale-progress-container {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
}

.wholesale-progress-bar {
    height: 8px;
    background: #e2e8f0;
    border-radius: 4px;
    overflow: hidden;
    flex-grow: 1;
    max-width: 400px;
}

.wholesale-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #6366f1, #4f46e5);
    border-radius: 4px;
    width: 0%;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.wholesale-progress-fill.complete {
    background: linear-gradient(90deg, #34d399, #10b981);
}

.wholesale-progress-text {
    font-size: 12px;
    font-weight: 600;
    color: var(--wholesale-text-light);
    white-space: nowrap;
    transition: color 0.2s;
}

.wholesale-progress-text.met {
    color: var(--wholesale-success);
}

/* Buttons */
.wholesale-add-btn {
    background: var(--wholesale-primary) !important;
    color: #fff !important;
    border: none !important;
    padding: 12px 24px !important;
    font-size: 15px !important;
    font-weight: 600 !important;
    border-radius: 8px !important;
    cursor: pointer !important;
    box-shadow: 0 4px 6px -1px rgba(79, 70, 229, 0.2), 0 2px 4px -2px rgba(79, 70, 229, 0.2) !important;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1) !important;
    display: flex;
    align-items: center;
    height: auto !important;
    line-height: 1 !important;
}

.wholesale-add-btn:hover:not(:disabled) {
    background: var(--wholesale-primary-hover) !important;
    transform: translateY(-1px);
    box-shadow: 0 10px 15px -3px rgba(79, 70, 229, 0.3) !important;
}

.wholesale-add-btn:active:not(:disabled) {
    transform: translateY(0);
}

.wholesale-add-btn:disabled {
    background: #cbd5e1 !important;
    color: #94a3b8 !important;
    box-shadow: none !important;
    cursor: not-allowed !important;
}

/* Toast System */
.wholesale-toast {
    position: fixed;
    top: 30px;
    right: 30px;
    z-index: 100000;
    padding: 14px 24px;
    border-radius: 8px;
    color: white;
    font-size: 14px;
    font-weight: 600;
    box-shadow: var(--wholesale-shadow-lg);
    opacity: 0;
    transform: translateY(-20px);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    pointer-events: none;
    display: flex;
    align-items: center;
    gap: 8px;
}

.wholesale-toast.show {
    opacity: 1;
    transform: translateY(0);
}

.wholesale-toast.success {
    background: #0f172a;
    border-left: 4px solid var(--wholesale-success);
}

.wholesale-toast.error {
    background: #0f172a;
    border-left: 4px solid var(--wholesale-error);
}

/* Responsive Table */
@media screen and (max-width: 768px) {
    .wholesale-filter-bar {
        flex-direction: column;
    }
    
    .wholesale-filter-category {
        width: 100%;
    }
    
    .wholesale-sticky-footer {
        flex-direction: column;
        align-items: stretch;
        gap: 15px;
        bottom: 85px; /* Clear bottom mobile nav menu */
        width: calc(100% - 20px);
        padding: 15px;
    }
    
    .wholesale-progress-container {
        max-width: 100%;
    }
    
    .wholesale-progress-bar {
        max-width: 100%;
    }
    
    .wholesale-add-btn {
        width: 100%;
        justify-content: center;
    }
    
    .wholesale-table-wrapper {
        margin-bottom: 220px;
    }

    /* Stack Table */
    .wholesale-order-table, 
    .wholesale-order-table thead, 
    .wholesale-order-table tbody, 
    .wholesale-order-table th, 
    .wholesale-order-table td, 
    .wholesale-order-table tr {
        display: block;
    }
    
    .wholesale-order-table thead {
        display: none; /* Hide header rows */
    }
    
    .wholesale-order-table tr {
        border-bottom: 2px solid var(--wholesale-border);
        padding: 15px 0;
    }
    
    .wholesale-order-table td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        border-bottom: none;
        padding: 8px 10px;
        width: auto !important;
        text-align: right;
    }
    
    .wholesale-order-table td::before {
        content: attr(data-title);
        float: left;
        font-weight: 600;
        color: var(--wholesale-text-light);
        text-transform: uppercase;
        font-size: 11px;
    }
    
    .col-image {
        justify-content: center !important;
    }
    
    .col-image::before {
        display: none !important; /* Hide redundant "IMAGE" text label on mobile next to photo */
    }
    
    .col-image img {
        width: 80px;
        height: 80px;
    }
    
    .wholesale-prod-title {
        font-size: 16px;
    }
    
    .wholesale-qty-selector {
        margin-left: auto;
    }
}
