/* Mobile Cart Card Styles */

/* Hide table on mobile, show cards */
@media (max-width: 768px) {
    .cart-table-container {
        display: none !important;
    }
    
    .cart-cards-container {
        display: block !important;
    }
}

/* Show table on desktop, hide cards */
@media (min-width: 769px) {
    .cart-cards-container {
        display: none !important;
    }
}

/* Cart Card Item Styling */
.cart-card-item {
    background: #ffffff;
    border: 2px solid #e3e6f0;
    border-radius: 8px;
    padding: 10px;
    margin-bottom: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: all 0.3s ease;
    cursor: pointer;
}

.cart-card-item:hover {
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
    border-color: #4e73df;
    background: #f8f9fc;
}

.cart-card-item:active {
    transform: scale(0.99);
}

/* Single Line Layout */
.cart-card-single-line {
    display: flex;
    align-items: center;
    gap: 10px;
}

.cart-card-number {
    background: linear-gradient(135deg, #4e73df 0%, #224abe 100%);
    color: white;
    min-width: 26px;
    height: 26px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    box-shadow: 0 2px 4px rgba(78, 115, 223, 0.3);
    flex-shrink: 0;
}

.cart-card-info {
    flex: 1;
    min-width: 0;
    font-size: 13px;
    line-height: 1.4;
}

.cart-card-info .product-name {
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cart-card-info .product-details {
    color: #5a5c69;
    font-size: 12px;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 3px;
}

.cart-card-delete {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.cart-card-delete:hover {
    transform: scale(1.05);
}

/* Compact line value styling */
.product-details .price-value {
    color: #28a745;
    font-weight: bold;
}

.product-details .discount-value {
    color: #e74a3b;
    font-weight: bold;
}

.product-details .qty-label {
    color: #858796;
    font-weight: 500;
}

.product-details .qty-value {
    color: #f6c23e;
    font-weight: bold;
}

.product-details .total-value {
    color: #1cc88a;
    font-weight: bold;
}

.product-details .separator {
    color: #858796;
}

/* Empty Cart State */
.empty-cart-cards {
    padding: 40px 20px;
    text-align: center;
}

.empty-cart-cards i {
    color: #d1d3e2;
    margin-bottom: 15px;
}

.empty-cart-cards p {
    color: #858796;
    font-size: 14px;
    margin: 0;
}

/* Mobile specific adjustments */
@media (max-width: 576px) {
    .cart-card-item {
        padding: 8px;
        margin-bottom: 6px;
    }
    
    .cart-card-info {
        font-size: 12px;
    }
    
    .cart-card-info .product-name {
        font-size: 13px;
    }
    
    .cart-card-info .product-details {
        font-size: 11px;
    }
}

/* Modern Mobile Modal Styles */
.modern-mobile-modal {
    border-radius: 12px;
    overflow: hidden;
}

.modern-mobile-modal .modal-header {
    border-radius: 12px 12px 0 0;
}

.compact-mobile-body {
    background: #f8f9fc;
    max-height: 70vh;
    overflow-y: auto;
}

.product-info-compact {
    border-left: 4px solid #4e73df;
    background: linear-gradient(to right, #f8f9fc, #ffffff);
}

.compact-label {
    font-size: 12px;
    font-weight: 600;
    color: #5a5c69;
    margin-bottom: 4px;
}

.compact-mobile-body .form-control {
    border-radius: 6px;
    border: 2px solid #e3e6f0;
    font-size: 14px;
    transition: all 0.2s ease;
}

.compact-mobile-body .form-control:focus {
    border-color: #4e73df;
    box-shadow: 0 0 0 0.2rem rgba(78, 115, 223, 0.15);
}

.preview-card {
    background: linear-gradient(135deg, #f8f9fc 0%, #ffffff 100%);
    border: 2px solid #1cc88a !important;
}

/* Modern input group styling */
.compact-mobile-body .input-group-text {
    font-weight: bold;
    font-size: 13px;
    border: 2px solid #e3e6f0;
    border-right: none;
}

.compact-mobile-body .input-group .form-control {
    border-left: none;
}

/* Quantity Suggestions - Quick Select */
.qty-suggestions {
    display: flex;
    flex-wrap: nowrap;
    gap: 4px;
    overflow-x: auto;
    padding: 2px 0;
    -webkit-overflow-scrolling: touch;
}

.qty-suggestions::-webkit-scrollbar {
    height: 3px;
}

.qty-suggestions::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.qty-suggestions::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 3px;
}

.qty-btn {
    flex: 0 0 auto;
    min-width: 40px;
    height: 28px;
    padding: 0 8px;
    border: 2px solid #4e73df;
    background: white;
    color: #4e73df;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.qty-btn:hover,
.qty-btn:active {
    background: #4e73df;
    color: white;
    transform: scale(1.05);
}

.qty-btn:active {
    transform: scale(0.95);
}

.qty-btn.active {
    background: linear-gradient(135deg, #4e73df 0%, #224abe 100%);
    color: white;
    box-shadow: 0 2px 4px rgba(78, 115, 223, 0.3);
}

/* Button group modern styling -->
.compact-mobile-body .btn-group-toggle label {
    transition: all 0.2s ease;
}

.compact-mobile-body .btn-group-toggle label.active {
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Modal footer buttons */
.modern-mobile-modal .modal-footer {
    gap: 6px;
    display: flex;
    justify-content: flex-end;
}

.modern-mobile-modal .modal-footer .btn {
    min-width: 70px;
    font-weight: 600;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.modern-mobile-modal .modal-footer .btn:active {
    transform: scale(0.97);
}

/* Responsive modal sizing */
@media (max-width: 576px) {
    .modern-mobile-modal .modal-dialog {
        margin: 0.5rem;
        max-width: calc(100% - 1rem);
    }
    
    .compact-mobile-body {
        padding: 12px !important;
    }
    
    .modern-mobile-modal .modal-footer {
        padding: 8px !important;
    }
    
    .modern-mobile-modal .modal-footer .btn {
        min-width: 60px;
        padding: 6px 10px;
    }
}

/* Mobile Product Search Modal Styles */
.mobile-search-modal {
    overflow: hidden;
}

.mobile-search-modal .modal-dialog {
    margin: 0;
    max-width: 100%;
    height: 100vh;
    display: flex;
    align-items: stretch;
}

.mobile-search-modal .modal-content {
    border: none;
    border-radius: 0;
    box-shadow: none;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

.mobile-search-modal .modal-header {
    background: linear-gradient(135deg, #4e73df 0%, #224abe 100%);
    padding: 12px 15px;
    border-bottom: none;
    flex-shrink: 0;
}

.mobile-search-modal .modal-title {
    font-size: 16px;
    font-weight: 700;
}

.mobile-search-modal .close {
    font-size: 28px;
    text-shadow: none;
    opacity: 0.9;
    padding: 0;
    margin: 0;
    line-height: 1;
}

.mobile-search-modal .close:hover {
    opacity: 1;
}

/* Search Input Container */
.mobile-search-container {
    padding: 10px 15px;
    background: #ffffff;
    border-bottom: 2px solid #e3e6f0;
    flex-shrink: 0;
}

.mobile-search-input-group {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
}

.mobile-search-wrapper {
    flex: 1;
    position: relative;
}

.mobile-search-input {
    width: 100%;
    padding: 8px 35px 8px 12px;
    font-size: 14px;
    border: 2px solid #e3e6f0;
    border-radius: 8px;
    background: #f8f9fc;
    transition: all 0.3s ease;
    height: 38px;
}

.mobile-search-input:focus {
    border-color: #4e73df;
    box-shadow: 0 0 0 0.2rem rgba(78, 115, 223, 0.15);
    outline: none;
    background: white;
}

.mobile-search-icon {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #858796;
    font-size: 14px;
    pointer-events: none;
}

.mobile-camera-btn {
    width: 38px;
    height: 38px;
    border-radius: 8px;
    background: linear-gradient(135deg, #1cc88a 0%, #13855c 100%);
    border: none;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    box-shadow: 0 2px 6px rgba(28, 200, 138, 0.3);
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.mobile-camera-btn:hover,
.mobile-camera-btn:active {
    background: linear-gradient(135deg, #17a673 0%, #0f6b47 100%);
    box-shadow: 0 4px 10px rgba(28, 200, 138, 0.4);
    transform: scale(1.05);
}

.mobile-camera-btn:active {
    transform: scale(0.98);
}

/* Search Results */
.mobile-search-results {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    background: #f8f9fc;
}

.mobile-product-item {
    background: white;
    border: 2px solid #e3e6f0;
    border-radius: 10px;
    padding: 14px;
    margin-bottom: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.mobile-product-item:hover,
.mobile-product-item:active {
    border-color: #28a745;
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    box-shadow: 0 3px 8px rgba(40, 167, 69, 0.3);
    transform: translateY(-1px);
}

.mobile-product-item:active {
    transform: scale(0.99);
}

.mobile-product-info {
    flex: 1;
    min-width: 0;
}

.mobile-product-name {
    font-size: 14px;
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mobile-product-item:hover .mobile-product-name,
.mobile-product-item:active .mobile-product-name {
    color: white;
}

.mobile-product-details {
    font-size: 12px;
    color: #5a5c69;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    align-items: center;
}

.mobile-product-item:hover .mobile-product-details,
.mobile-product-item:active .mobile-product-details {
    color: white;
}

.mobile-product-code {
    background: #e3e6f0;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 600;
    font-size: 11px;
}

.mobile-product-item:hover .mobile-product-code,
.mobile-product-item:active .mobile-product-code {
    background: rgba(255, 255, 255, 0.3);
    color: white;
}

.mobile-product-price {
    color: #28a745;
    font-weight: 700;
    font-size: 15px;
    white-space: nowrap;
}

.mobile-product-item:hover .mobile-product-price,
.mobile-product-item:active .mobile-product-price {
    color: white;
}

.mobile-product-stock {
    font-size: 11px;
    color: #858796;
}

.mobile-product-item:hover .mobile-product-stock,
.mobile-product-item:active .mobile-product-stock {
    color: white;
}

.mobile-product-stock.in-stock {
    color: #1cc88a;
    font-weight: 600;
}

.mobile-product-stock.low-stock {
    color: #f6c23e;
    font-weight: 600;
}

.mobile-product-stock.out-of-stock {
    color: #e74a3b;
    font-weight: 600;
}

/* Empty Search State */
.mobile-search-empty {
    text-align: center;
    padding: 40px 20px;
    color: #858796;
}

.mobile-search-empty i {
    font-size: 48px;
    color: #d1d3e2;
    margin-bottom: 15px;
}

.mobile-search-empty p {
    font-size: 14px;
    margin: 0;
}

/* Loading State */
.mobile-search-loading {
    text-align: center;
    padding: 20px;
}

.mobile-search-loading .spinner-border {
    width: 2rem;
    height: 2rem;
    color: #4e73df;
}

/* Scrollbar styling for search results */
.mobile-search-results::-webkit-scrollbar {
    width: 6px;
}

.mobile-search-results::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.mobile-search-results::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 3px;
}

.mobile-search-results::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Animation for modal */
@keyframes slideInUp {
    from {
        transform: translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.mobile-search-modal.show .modal-dialog {
    animation: slideInUp 0.3s ease-out;
}

/* Full screen modal backdrop */
.mobile-search-modal .modal-backdrop {
    background-color: rgba(0, 0, 0, 0.8);
}

/* Only show on mobile */
@media (min-width: 769px) {
    .mobile-search-modal {
        display: none !important;
    }
}

@media (max-width: 768px) {
    /* Ensure modal is always full screen on mobile */
    .mobile-search-modal.fade .modal-dialog {
        transform: translateY(100%);
    }
    
    .mobile-search-modal.show .modal-dialog {
        transform: translateY(0);
    }
    
    .mobile-search-modal .modal-dialog {
        margin: 0;
        width: 100%;
        max-width: 100%;
        height: 100vh;
    }
}

/* Quick Actions Button - Mobile Only */
@media (max-width: 768px) {
    .mobile-quick-actions-btn {
        position: fixed;
        bottom: 20px;
        right: 20px;
        width: 60px;
        height: 60px;
        border-radius: 50%;
        background: linear-gradient(135deg, #4e73df 0%, #224abe 100%);
        color: white;
        border: none;
        box-shadow: 0 4px 12px rgba(78, 115, 223, 0.4);
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 24px;
        z-index: 1000;
        transition: all 0.3s ease;
    }
    
    .mobile-quick-actions-btn:hover,
    .mobile-quick-actions-btn:active {
        transform: scale(1.1);
        box-shadow: 0 6px 16px rgba(78, 115, 223, 0.5);
    }
    
    .mobile-quick-actions-btn:active {
        transform: scale(0.95);
    }
}

/* Quick Actions Modal */
.quick-actions-modal .modal-dialog {
    margin: 0;
    max-width: 100%;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
}

.quick-actions-modal .modal-content {
    border-radius: 20px 20px 0 0;
    border: none;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.2);
}

.quick-actions-modal .modal-header {
    background: linear-gradient(135deg, #4e73df 0%, #224abe 100%);
    color: white;
    border-radius: 20px 20px 0 0;
    padding: 15px 20px;
    border-bottom: none;
}

.quick-actions-modal .modal-title {
    font-size: 18px;
    font-weight: 700;
}

.quick-actions-modal .modal-body {
    padding: 10px;
    max-height: 70vh;
    overflow-y: auto;
}

/* Quick Action Item */
.quick-action-item {
    background: white;
    border: 2px solid #e3e6f0;
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 15px;
}

.quick-action-item:hover,
.quick-action-item:active {
    border-color: #4e73df;
    background: #f8f9fc;
    box-shadow: 0 3px 8px rgba(78, 115, 223, 0.2);
    transform: translateX(5px);
}

.quick-action-item:active {
    transform: scale(0.98);
}

.quick-action-icon {
    width: 45px;
    height: 45px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: white;
    flex-shrink: 0;
}

.quick-action-icon.bg-success {
    background: linear-gradient(135deg, #1cc88a 0%, #13855c 100%);
}

.quick-action-icon.bg-info {
    background: linear-gradient(135deg, #36b9cc 0%, #258391 100%);
}

.quick-action-icon.bg-warning {
    background: linear-gradient(135deg, #f6c23e 0%, #dda20a 100%);
}

.quick-action-icon.bg-danger {
    background: linear-gradient(135deg, #e74a3b 0%, #be2617 100%);
}

.quick-action-icon.bg-primary {
    background: linear-gradient(135deg, #4e73df 0%, #224abe 100%);
}

.quick-action-icon.bg-secondary {
    background: linear-gradient(135deg, #858796 0%, #60616f 100%);
}

.quick-action-content {
    flex: 1;
    min-width: 0;
}

.quick-action-title {
    font-size: 15px;
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 3px;
}

.quick-action-description {
    font-size: 12px;
    color: #858796;
    margin: 0;
    line-height: 1.3;
}

/* Animation for Quick Actions Modal */
@keyframes slideUp {
    from {
        transform: translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.quick-actions-modal.show .modal-content {
    animation: slideUp 0.3s ease-out;
}

/* Hide on desktop */
@media (min-width: 769px) {
    .mobile-quick-actions-btn {
        display: none !important;
    }
    .quick-actions-modal {
        display: none !important;
    }
}

/* Hide action buttons on mobile - show Quick Actions instead */
@media (max-width: 768px) {
    .pos-header-compact .d-flex.justify-content-end button:not(#btnAddCustomer) {
        display: none !important;
    }
    
    /* Compact Cash and UPI inputs in single line on mobile */
    .mobile-totals-content .row.mb-2.no-gutters {
        display: flex;
        align-items: center;
        gap: 6px;
        margin-bottom: 8px !important;
    }
    
    .mobile-totals-content .row.mb-2.no-gutters .col-6 {
        flex: 1;
        padding: 0 !important;
    }
    
    .mobile-totals-content .row.mb-2.no-gutters .col-6 label {
        font-size: 9px !important;
        margin-bottom: 2px !important;
        white-space: nowrap;
    }
    
    .mobile-totals-content .row.mb-2.no-gutters .col-6 input {
        font-size: 11px !important;
        padding: 4px 6px !important;
        height: 28px !important;
    }
    
    .mobile-totals-content .row.mb-2.no-gutters .col-6 label i {
        font-size: 8px;
    }
}

/* ============================================= */
/* Mobile Modal Z-Index Fix for Nested Modals */
/* ============================================= */

/* Transport GST Modal should appear in front of Shipping Modal on Mobile */
@media (max-width: 768px) {
    #transportGSTModal {
        z-index: 1060 !important;
    }

    #transportGSTModal .modal-backdrop {
        z-index: 1055 !important;
    }

    /* Shipping Modal default z-index */
    #shippingDetailsModal {
        z-index: 1050 !important;
    }

    /* General fix for nested modals on mobile */
    .modal.show ~ .modal.show {
        z-index: 1060 !important;
    }

    .modal.show ~ .modal.show ~ .modal-backdrop {
        z-index: 1055 !important;
    }
    
    /* Ensure any modal opened from another modal has higher z-index */
    .modal-backdrop.show:nth-of-type(2) {
        z-index: 1055 !important;
    }
    
    /* All modals opened on top of other modals */
    .modal:nth-of-type(2) {
        z-index: 1060 !important;
    }
}
