/* Frontend Styles - Persian Bulk Order Plugin */
/* RTL Support - Base */
.pbo-order-form {
    direction: rtl;
    font-family: Tahoma, Arial, sans-serif;
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    background: #fff;
}

/* Main Layout - Flexbox for sticky sidebar */
.pbo-content {
    display: flex;
    gap: 30px;
    position: relative;
}

/* Main Products Section */
.pbo-main {
    flex: 1;
    min-width: 0;
}

/* Sidebar - Fixed/Sticky */
.pbo-sidebar {
    width: 380px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 20px;
    position: sticky;
    top: 20px;
    align-self: flex-start;
    max-height: calc(100vh - 40px);
}

/* Title */
.pbo-title {
    text-align: center;
    color: #2c3e50;
    font-size: 28px;
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 3px solid #3498db;
}

/* Filters Section - Fixed visibility */
.pbo-filters {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 25px;
    border: 1px solid #e0e0e0;
}

.filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    align-items: flex-end;
}

.filter-item {
    flex: 1;
    min-width: 150px;
}

.filter-item label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #2c3e50;
    font-size: 14px;
}

.filter-item select,
.filter-item input[type="text"] {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #3498db;
    border-radius: 8px;
    font-size: 14px;
    background: #fff;
    color: #2c3e50;
    transition: border-color 0.3s, box-shadow 0.3s;
}

.filter-item select:focus,
.filter-item input[type="text"]:focus {
    outline: none;
    border-color: #2980b9;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.2);
}

/* Fix filter visibility - ensure options are clearly visible */
.filter-item select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%232c3e50' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: left 15px center;
    padding-left: 40px;
}

.filter-item select option {
    padding: 10px;
    background: #fff;
    color: #2c3e50;
    font-size: 14px;
}

/* Search filter */
.filter-search {
    flex: 1.5;
}

/* Filter Button */
.pbo-btn {
    padding: 12px 25px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s ease;
}

.pbo-btn-primary {
    background: #3498db;
    color: white;
}

.pbo-btn-primary:hover {
    background: #2980b9;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.4);
}

/* Products Section */
.pbo-products-section {
    background: #fff;
    border-radius: 10px;
}

.pbo-products-section h3 {
    color: #2c3e50;
    font-size: 20px;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid #ecf0f1;
}

.pbo-products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 20px;
    max-height: 600px;
    overflow-y: auto;
    padding: 10px 5px;
}

/* Scrollbar styling for products */
.pbo-products-grid::-webkit-scrollbar {
    width: 8px;
}

.pbo-products-grid::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.pbo-products-grid::-webkit-scrollbar-thumb {
    background: #3498db;
    border-radius: 4px;
}

.pbo-products-grid::-webkit-scrollbar-thumb:hover {
    background: #2980b9;
}

/* Product Card */
.pbo-product-card {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
}

.pbo-product-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.12);
    border-color: #3498db;
}

.pbo-product-image {
    height: 180px;
    overflow: hidden;
    background: #f8f9fa;
}

.pbo-product-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.pbo-product-card:hover .pbo-product-image img {
    transform: scale(1.05);
}

.pbo-no-image {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #95a5a6;
    font-size: 14px;
}

.pbo-product-info {
    padding: 15px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.pbo-product-name {
    font-size: 16px;
    font-weight: 600;
    color: #2c3e50;
    margin: 0 0 8px 0;
    line-height: 1.4;
}

.pbo-product-sku {
    font-size: 12px;
    color: #7f8c8d;
    margin: 0 0 10px 0;
}

.pbo-product-stock {
    margin-bottom: 12px;
}

.pbo-in-stock {
    color: #27ae60;
    font-size: 13px;
    font-weight: 600;
    background: #d4edda;
    padding: 4px 10px;
    border-radius: 20px;
}

.pbo-out-stock {
    color: #e74c3c;
    font-size: 13px;
    font-weight: 600;
    background: #f8d7da;
    padding: 4px 10px;
    border-radius: 20px;
}

.pbo-product-actions {
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.pbo-quantity {
    display: flex;
    align-items: center;
    gap: 10px;
}

.pbo-quantity label {
    font-size: 13px;
    color: #7f8c8d;
    white-space: nowrap;
}

.pbo-qty-input {
    width: 80px;
    padding: 8px 12px;
    border: 2px solid #ecf0f1;
    border-radius: 6px;
    text-align: center;
    font-size: 14px;
    transition: border-color 0.3s;
}

.pbo-qty-input:focus {
    outline: none;
    border-color: #3498db;
}

.pbo-btn-add {
    background: #27ae60;
    color: white;
    padding: 12px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 100%;
}

.pbo-btn-add:hover {
    background: #219a52;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(39, 174, 96, 0.3);
}

.pbo-btn-add:disabled {
    background: #bdc3c7;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Sidebar Sections */
.pbo-cart-section,
.pbo-customer-section {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    overflow: hidden;
}

.pbo-cart-section h3,
.pbo-customer-section h3 {
    background: #3498db;
    color: white;
    padding: 15px 20px;
    margin: 0;
    font-size: 16px;
}

.pbo-customer-section h3 {
    background: #2c3e50;
}

/* Cart Items */
.pbo-cart-items {
    padding: 20px;
    min-height: 100px;
    max-height: 200px;
    overflow-y: auto;
}

.pbo-empty-cart {
    color: #95a5a6;
    text-align: center;
    padding: 20px;
    margin: 0;
}

.pbo-cart-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.pbo-cart-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    background: #f8f9fa;
    border-radius: 8px;
    margin-bottom: 10px;
}

.pbo-cart-item:last-child {
    margin-bottom: 0;
}

.pbo-cart-item-name {
    flex: 1;
    font-size: 13px;
    color: #2c3e50;
    font-weight: 500;
}

.pbo-cart-item-qty {
    width: 70px;
}

.pbo-cart-qty {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    text-align: center;
    font-size: 13px;
}

.pbo-remove-item {
    background: #e74c3c;
    color: white;
    border: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    transition: background 0.3s;
}

.pbo-remove-item:hover {
    background: #c0392b;
}

.pbo-cart-info {
    padding: 0 20px 15px;
}

.pbo-cart-info p {
    margin: 0;
    color: #2c3e50;
    font-size: 14px;
}

.pbo-item-count {
    font-weight: bold;
    color: #3498db;
}

/* Customer Form */
.pbo-customer-section {
    display: flex;
    flex-direction: column;
}

#pbo-order-form {
    padding: 20px;
    flex: 1;
    overflow-y: auto;
}

.pbo-form-group {
    margin-bottom: 18px;
}

.pbo-form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #2c3e50;
    font-size: 14px;
}

.pbo-form-group label .required {
    color: #e74c3c;
}

.pbo-form-group input,
.pbo-form-group textarea {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #ecf0f1;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.3s, box-shadow 0.3s;
    box-sizing: border-box;
}

.pbo-form-group input:focus,
.pbo-form-group textarea:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.15);
}

.pbo-form-group textarea {
    resize: vertical;
    min-height: 80px;
}

/* Submit Button - Always Visible */
.pbo-btn-submit {
    width: 100%;
    background: linear-gradient(135deg, #27ae60, #219a52);
    color: white;
    padding: 16px 30px;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 10px;
    box-shadow: 0 4px 15px rgba(39, 174, 96, 0.3);
}

.pbo-btn-submit:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(39, 174, 96, 0.4);
}

.pbo-btn-submit:disabled {
    background: #bdc3c7;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Messages */
#pbo-messages {
    padding: 0 20px 20px;
}

.pbo-message {
    padding: 12px 15px;
    border-radius: 8px;
    margin-bottom: 10px;
    font-size: 14px;
}

.pbo-message-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.pbo-message-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* No Products Message */
.pbo-no-products {
    text-align: center;
    padding: 60px 20px;
    color: #95a5a6;
}

.pbo-no-products p {
    margin: 0;
    font-size: 16px;
}

/* Loading State */
.pbo-loading {
    opacity: 0.6;
    pointer-events: none;
    position: relative;
}

.pbo-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}

/* ================================
   MOBILE RESPONSIVE LAYOUT
   ================================ */
@media (max-width: 1024px) {
    .pbo-content {
        flex-direction: column;
    }
    
    .pbo-sidebar {
        width: 100%;
        position: relative;
        top: 0;
        max-height: none;
    }
    
    .pbo-products-grid {
        max-height: 400px;
    }
}

@media (max-width: 768px) {
    .pbo-order-form {
        padding: 15px;
    }
    
    .pbo-title {
        font-size: 22px;
        margin-bottom: 20px;
    }
    
    .filter-row {
        flex-direction: column;
    }
    
    .filter-item {
        width: 100%;
    }
    
    .filter-search {
        order: -1;
        margin-bottom: 15px;
    }
    
    .pbo-products-grid {
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
        gap: 15px;
        max-height: 350px;
    }
    
    .pbo-product-image {
        height: 140px;
    }
    
    .pbo-product-name {
        font-size: 14px;
    }
    
    .pbo-quantity {
        flex-direction: row-reverse;
    }
    
    .pbo-cart-item {
        flex-wrap: wrap;
    }
    
    .pbo-cart-item-name {
        width: calc(100% - 100px);
        margin-bottom: 8px;
    }
}

@media (max-width: 480px) {
    .pbo-order-form {
        padding: 10px;
    }
    
    .pbo-title {
        font-size: 18px;
    }
    
    .pbo-filters {
        padding: 15px;
    }
    
    .pbo-products-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
        max-height: 400px;
    }
    
    .pbo-product-card {
        border-radius: 8px;
    }
    
    .pbo-product-info {
        padding: 10px;
    }
    
    .pbo-product-name {
        font-size: 13px;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }
    
    .pbo-product-sku {
        font-size: 11px;
    }
    
    .pbo-quantity label {
        font-size: 12px;
    }
    
    .pbo-qty-input {
        width: 60px;
        padding: 6px 8px;
        font-size: 13px;
    }
    
    .pbo-btn-add {
        padding: 10px 15px;
        font-size: 13px;
    }
    
    .pbo-sidebar {
        gap: 15px;
    }
    
    .pbo-cart-section h3,
    .pbo-customer-section h3 {
        padding: 12px 15px;
        font-size: 14px;
    }
    
    #pbo-order-form {
        padding: 15px;
    }
    
    .pbo-form-group {
        margin-bottom: 12px;
    }
    
    .pbo-form-group label {
        font-size: 13px;
    }
    
    .pbo-form-group input,
    .pbo-form-group textarea {
        padding: 10px 12px;
        font-size: 14px;
    }
    
    .pbo-btn-submit {
        padding: 14px 20px;
        font-size: 15px;
    }
}

/* ================================
   EXTRA SMALL DEVICES
   ================================ */
@media (max-width: 360px) {
    .pbo-products-grid {
        grid-template-columns: 1fr;
    }
    
    .pbo-product-image {
        height: 160px;
    }
}

/* ================================
   ACCESSIBILITY IMPROVEMENTS
   ================================ */
@media (prefers-reduced-motion: reduce) {
    * {
        animation: none !important;
        transition: none !important;
    }
}

/* Focus visible for keyboard navigation */
.pbo-btn:focus-visible,
.pbo-form-group input:focus-visible,
.pbo-form-group textarea:focus-visible,
.pbo-qty-input:focus-visible {
    outline: 2px solid #3498db;
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .pbo-filters {
        border-width: 3px;
    }
    
    .pbo-product-card {
        border-width: 2px;
    }
    
    .pbo-btn {
        border-width: 2px;
        border-style: solid;
    }
}
