/* Enhanced Manual POS Sales Styles - Mobile-First Responsive Design */
#manual-pos-sales {
    max-width: 100%;
    margin: 10px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    font-size: 14px;
}

/* Header Section */
.pos-header {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    color: white;
    padding: 15px 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.pos-header h2 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    color: white;
    text-align: center;
}

.pos-customer-info {
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
}

.customer-label {
    font-weight: 500;
    font-size: 14px;
    white-space: nowrap;
}

.customer-name-input {
    background: rgba(255,255,255,0.9);
    color: #333;
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 4px;
    padding: 6px 10px;
    font-size: 14px;
    font-weight: 500;
    min-width: 150px;
    flex: 1;
    max-width: 200px;
    transition: all 0.2s ease;
}

.customer-name-input:focus {
    outline: none;
    background: white;
    border-color: #2563eb;
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}

/* Main Content Grid */
.pos-main-content {
    display: flex;
    flex-direction: column;
    min-height: 500px;
}

/* Controls Sidebar */
.pos-controls-sidebar {
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    padding: 20px;
}

/* Enhanced Item Selection Section */
.pos-item-section {
    margin-bottom: 25px;
}

.item-select-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.item-select-group label {
    font-weight: 500;
    color: #374151;
    font-size: 14px;
}

/* Enhanced Search Dropdown Container */
.search-dropdown-container {
    position: relative;
    flex: 1;
}

.search-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

#item-search {
    width: 100%;
    padding: 10px 40px 10px 12px;
    border: 2px solid #d1d5db;
    border-radius: 6px;
    font-size: 16px;
    transition: all 0.2s ease;
    min-height: 40px;
    box-sizing: border-box;
    background: white;
}

#item-search:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.dropdown-arrow {
    position: absolute;
    right: 12px;
    cursor: pointer;
    color: #6b7280;
    font-size: 12px;
    transition: transform 0.2s ease, color 0.2s ease;
    user-select: none;
    z-index: 2;
}

.dropdown-arrow:hover {
    color: #2563eb;
}

.dropdown-arrow.open {
    transform: rotate(180deg);
    color: #2563eb;
}

.item-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 2px solid #2563eb;
    border-top: none;
    border-radius: 0 0 6px 6px;
    max-height: 300px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    display: none;
}

.item-dropdown.show {
    display: block;
}

.dropdown-loading {
    padding: 20px;
    text-align: center;
    color: #6b7280;
    font-style: italic;
}

.item-dropdown-item {
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid #f1f5f9;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.item-dropdown-item:last-child {
    border-bottom: none;
}

.item-dropdown-item:hover, .item-dropdown-item.selected {
    background: #eff6ff;
    border-left: 3px solid #2563eb;
}

.item-dropdown-item:active {
    background: #dbeafe;
}

.item-name {
    font-weight: 500;
    color: #374151;
    font-size: 14px;
}

.item-details {
    font-size: 12px;
    color: #6b7280;
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.item-detail {
    display: flex;
    gap: 4px;
}

.item-detail-label {
    font-weight: 500;
}

.item-price {
    color: #059669;
    font-weight: 600;
}

.item-stock {
    color: #dc2626;
}

.item-stock.in-stock {
    color: #059669;
}

.no-items-found {
    padding: 20px;
    text-align: center;
    color: #9ca3af;
    font-style: italic;
}

/* Selected Item Display */
.selected-item-display {
    margin-top: 8px;
    padding: 12px;
    background: #ecfdf5;
    border: 1px solid #10b981;
    border-radius: 6px;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.selected-item-info {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.selected-item-name {
    font-weight: 600;
    color: #065f46;
    font-size: 14px;
}

.selected-item-details {
    display: flex;
    gap: 15px;
    font-size: 12px;
}

.selected-item-price {
    color: #059669;
    font-weight: 600;
}

.selected-item-stock {
    color: #374151;
}

#add-item-btn {
    margin-top: 12px;
    padding: 12px 16px;
    background: #2563eb;
    color: white;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    min-height: 44px;
    width: 100%;
}

#add-item-btn:hover:not(:disabled) {
    background: #1d4ed8;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

#add-item-btn:disabled {
    background: #9ca3af;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

#add-item-btn:active:not(:disabled) {
    transform: translateY(0);
}

.item-status {
    margin-top: 8px;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 13px;
    min-height: 16px;
    transition: all 0.3s ease;
}

.item-status.success {
    background: #d1fae5;
    color: #065f46;
    border: 1px solid #10b981;
}

.item-status.error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #ef4444;
}

/* Payment Section */
.pos-payment-section {
    border-top: 2px solid #e2e8f0;
    padding-top: 20px;
}

.payment-inputs {
    display: grid;
    grid-template-columns: 1fr;
    gap: 15px;
    margin-bottom: 20px;
}

.input-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 6px;
    color: #374151;
    font-size: 14px;
}

#tendered-amount {
    width: 100%;
    padding: 12px;
    border: 2px solid #d1d5db;
    border-radius: 6px;
    font-size: 18px;
    font-weight: 600;
    min-height: 44px;
    box-sizing: border-box;
    text-align: center;
}

#tendered-amount:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.change-display {
    display: flex;
    flex-direction: column;
}

.change-display label {
    font-weight: 500;
    margin-bottom: 6px;
    color: #374151;
    font-size: 14px;
}

#change-amount {
    padding: 12px;
    background: #ecfdf5;
    border: 2px solid #10b981;
    border-radius: 6px;
    font-size: 18px;
    font-weight: 700;
    color: #059669;
    text-align: center;
    min-height: 20px;
    transition: all 0.3s ease;
}

.change-display.negative #change-amount {
    background: #fef2f2;
    border-color: #ef4444;
    color: #dc2626;
    animation: shake 0.5s ease;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

.action-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.btn-primary, .btn-secondary {
    padding: 12px 20px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    min-height: 44px;
}

.btn-primary {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.btn-primary:disabled {
    background: #9ca3af;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-secondary {
    background: #f3f4f6;
    color: #374151;
    border: 1px solid #d1d5db;
}

.btn-secondary:hover {
    background: #e5e7eb;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Cart Section */
.pos-cart-section {
    padding: 20px;
    flex: 1;
}

.pos-cart-section h3 {
    margin: 0 0 15px 0;
    color: #374151;
    font-size: 18px;
    font-weight: 600;
}

.cart-container {
    border-radius: 6px;
    overflow-x: auto;
    border: 1px solid #e2e8f0;
    -webkit-overflow-scrolling: touch;
    background: white;
}

.pos-cart-table {
    width: 100%;
    min-width: 500px;
    border-collapse: collapse;
    background: white;
}

.pos-cart-table th {
    background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
    padding: 12px 8px;
    text-align: left;
    font-weight: 600;
    color: #374151;
    border-bottom: 2px solid #e2e8f0;
    font-size: 13px;
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 10;
}

.pos-cart-table td {
    padding: 12px 8px;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
    font-size: 13px;
}

.pos-cart-table tbody tr {
    transition: background-color 0.2s ease;
}

.pos-cart-table tbody tr:hover {
    background: #f8fafc;
}

.empty-cart {
    text-align: center;
    color: #9ca3af;
    font-style: italic;
    padding: 30px 16px !important;
    background: #fafafa;
}

.item-name {
    font-weight: 500;
    color: #374151;
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.price-col, .total-col {
    text-align: right;
    width: 80px;
}

.qty-col {
    width: 100px;
}

.action-col {
    width: 70px;
}

.price-cell, .total-cell {
    font-weight: 600;
    color: #059669;
    text-align: right;
}

.qty-controls {
    display: flex;
    align-items: center;
    gap: 6px;
    justify-content: center;
}

.qty-btn {
    width: 28px;
    height: 28px;
    border: 1px solid #d1d5db;
    background: white;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    color: #374151;
    transition: all 0.2s ease;
    font-size: 14px;
}

.qty-btn:hover {
    background: #f3f4f6;
    border-color: #2563eb;
    color: #2563eb;
    transform: scale(1.05);
}

.qty-btn:active {
    transform: scale(0.95);
}

.qty-display {
    min-width: 35px;
    text-align: center;
    font-weight: 600;
    font-size: 14px;
    padding: 4px 8px;
    background: #f8fafc;
    border-radius: 4px;
    border: 1px solid #e2e8f0;
}

.remove-btn {
    background: #ef4444;
    color: white;
    border: none;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s ease;
}

.remove-btn:hover {
    background: #dc2626;
    transform: scale(1.05);
}

.remove-btn:active {
    transform: scale(0.95);
}

.grand-total-row td {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border-top: 2px solid #2563eb;
    font-size: 16px;
    padding: 18px 8px;
    font-weight: 700;
}

#grand-total {
    color: #2563eb;
    font-size: 18px;
}

/* Loading Overlay */
.pos-loading {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.8);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    color: white;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255,255,255,0.3);
    border-top: 4px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 15px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.pos-loading p {
    font-size: 16px;
    font-weight: 500;
}

/* Error Messages */
.manual-pos-error {
    background: #fee2e2;
    color: #991b1b;
    padding: 16px;
    border-radius: 8px;
    border: 1px solid #fecaca;
    margin: 20px;
    text-align: center;
    font-weight: 500;
}

/* Scrollbar Styling */
.item-dropdown::-webkit-scrollbar {
    width: 6px;
}

.item-dropdown::-webkit-scrollbar-track {
    background: #f1f5f9;
}

.item-dropdown::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

.item-dropdown::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Tablet Styles (768px and up) */
@media (min-width: 768px) {
    #manual-pos-sales {
        margin: 20px auto;
        max-width: 1200px;
    }
    
    .pos-header {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        padding: 20px 30px;
    }
    
    .pos-header h2 {
        font-size: 24px;
        text-align: left;
    }
    
    .pos-customer-info {
        justify-content: flex-end;
        background: rgba(255,255,255,0.15);
        padding: 8px 16px;
        border-radius: 20px;
        backdrop-filter: blur(10px);
    }
    
    .pos-main-content {
        display: grid;
        grid-template-columns: 350px 1fr;
        min-height: 600px;
    }
    
    .pos-controls-sidebar {
        border-right: 1px solid #e2e8f0;
        border-bottom: none;
        padding: 25px;
    }
    
    .payment-inputs {
        grid-template-columns: 1fr 1fr;
        gap: 20px;
    }
    
    .action-buttons {
        flex-direction: row;
        gap: 12px;
    }
    
    .pos-cart-section {
        padding: 25px;
    }
    
    .pos-cart-section h3 {
        font-size: 20px;
        margin-bottom: 20px;
    }
}

/* Desktop Styles (1024px and up) */
@media (min-width: 1024px) {
    .pos-controls-sidebar {
        padding: 30px;
    }
    
    .pos-cart-section {
        padding: 30px;
    }
    
    .pos-cart-table {
        min-width: auto;
    }
    
    .item-name {
        max-width: 200px;
    }
    
    .price-col, .total-col {
        width: 100px;
    }
    
    .qty-col {
        width: 120px;
    }
    
    .action-col {
        width: 90px;
    }
}

/* Small Screen Optimizations */
@media (max-width: 480px) {
    #manual-pos-sales {
        margin: 5px;
        border-radius: 6px;
    }
    
    .pos-header {
        padding: 12px 15px;
    }
    
    .pos-header h2 {
        font-size: 18px;
    }
    
    .pos-controls-sidebar,
    .pos-cart-section {
        padding: 15px;
    }
    
    .qty-btn {
        width: 24px;
        height: 24px;
        font-size: 12px;
    }
    
    .qty-display {
        min-width: 30px;
        font-size: 12px;
    }
    
    .remove-btn {
        padding: 4px 6px;
        font-size: 10px;
    }
}

/* Touch Device Optimizations */
@media (hover: none) and (pointer: coarse) {
    .item-dropdown-item {
        padding: 16px;
    }
    
    .qty-btn {
        width: 32px;
        height: 32px;
        font-size: 16px;
    }
    
    .remove-btn {
        padding: 8px 12px;
        font-size: 14px;
    }
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    .pos-header {
        background: #000;
        color: #fff;
    }
    
    .btn-primary {
        background: #000;
        color: #fff;
        border: 2px solid #fff;
    }
    
    .btn-secondary {
        background: #fff;
        color: #000;
        border: 2px solid #000;
    }
    
    .pos-cart-table th {
        background: #000;
        color: #fff;
    }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Print Styles */
@media print {
    #manual-pos-sales {
        box-shadow: none;
        border: 1px solid #ccc;
    }
    
    .pos-controls-sidebar {
        display: none;
    }
    
    .pos-main-content {
        display: block;
    }
    
    .action-col,
    .pos-cart-table th:last-child,
    .pos-cart-table td:last-child {
        display: none;
    }
}