/* POS Barcode Scanner Styles - Mobile-First Responsive Design */
#pos-barcode-scanner {
    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: #31ad75;
    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;
}

.customer-name-input:focus {
    outline: none;
    background: white;
    border-color: #31ad75;
    box-shadow: 0 0 0 2px rgba(49, 173, 117, 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;
}

/* Scan Section */
.pos-scan-section {
    margin-bottom: 25px;
}

.scan-input-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.scan-input-group label {
    font-weight: 500;
    color: #374151;
    font-size: 14px;
}

.scan-input-group > div:last-child {
    display: flex;
    gap: 8px;
}

#barcode-input {
    flex: 1;
    padding: 10px 12px;
    border: 2px solid #d1d5db;
    border-radius: 6px;
    font-size: 16px;
    transition: all 0.2s ease;
    min-height: 40px;
}

#barcode-input:focus {
    outline: none;
    border-color: #31ad75;
    box-shadow: 0 0 0 3px rgba(49, 173, 117, 0.1);
}

#manual-add-btn {
    padding: 10px 16px;
    background: #31ad75;
    color: white;
    border: none;
    border-radius: 6px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s ease;
    white-space: nowrap;
    min-height: 40px;
}

#manual-add-btn:hover {
    background: #2d9968;
}

#manual-add-btn:active {
    transform: translateY(1px);
}

.scan-status {
    margin-top: 8px;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 13px;
    min-height: 16px;
}

.scan-status.success {
    background: #d1fae5;
    color: #065f46;
    border: 1px solid #10b981;
}

.scan-status.error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #ef4444;
}

/* Payment Section */
.pos-payment-section {
    border-top: 1px 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: 10px 12px;
    border: 2px solid #d1d5db;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 500;
    min-height: 40px;
    box-sizing: border-box;
}

#tendered-amount:focus {
    outline: none;
    border-color: #31ad75;
    box-shadow: 0 0 0 3px rgba(49, 173, 117, 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: 10px 12px;
    background: #ecfdf5;
    border: 2px solid #10b981;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 600;
    color: #059669;
    text-align: center;
    min-height: 20px;
}

.change-display.negative #change-amount {
    background: #fef2f2;
    border-color: #ef4444;
    color: #dc2626;
}

.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: #31ad75;
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: #2d9968;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(49, 173, 117, 0.3);
}

.btn-primary:disabled {
    background: #9ca3af;
    cursor: not-allowed;
}

.btn-secondary {
    background: #f3f4f6;
    color: #374151;
    border: 1px solid #d1d5db;
}

.btn-secondary:hover {
    background: #e5e7eb;
    transform: translateY(-1px);
}

/* 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;
}

.pos-cart-table {
    width: 100%;
    min-width: 500px;
    border-collapse: collapse;
    background: white;
}

.pos-cart-table th {
    background: #f1f5f9;
    padding: 12px 8px;
    text-align: left;
    font-weight: 600;
    color: #374151;
    border-bottom: 2px solid #e2e8f0;
    font-size: 13px;
    white-space: nowrap;
}

.pos-cart-table td {
    padding: 12px 8px;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
    font-size: 13px;
}

.pos-cart-table tbody tr:hover {
    background: #f8fafc;
}

.empty-cart {
    text-align: center;
    color: #9ca3af;
    font-style: italic;
    padding: 30px 16px !important;
}

.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: 500;
    color: #059669;
    text-align: right;
}

.qty-controls {
    display: flex;
    align-items: center;
    gap: 4px;
    justify-content: center;
}

.qty-btn {
    width: 24px;
    height: 24px;
    border: 1px solid #d1d5db;
    background: white;
    border-radius: 3px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    color: #374151;
    transition: all 0.2s ease;
    font-size: 12px;
}

.qty-btn:hover {
    background: #f3f4f6;
    border-color: #9ca3af;
}

.qty-display {
    min-width: 30px;
    text-align: center;
    font-weight: 500;
    font-size: 13px;
}

.remove-btn {
    background: #ef4444;
    color: white;
    border: none;
    padding: 4px 8px;
    border-radius: 3px;
    font-size: 11px;
    cursor: pointer;
    font-weight: 500;
    transition: background 0.2s ease;
}

.remove-btn:hover {
    background: #dc2626;
}

.grand-total-row td {
    background: #f8fafc;
    border-top: 2px solid #e2e8f0;
    font-size: 14px;
    padding: 15px 8px;
    font-weight: 600;
}

#grand-total {
    color: #059669;
    font-size: 16px;
}

/* Loading Overlay */
.pos-loading {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.7);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    color: white;
}

.loading-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid rgba(255,255,255,0.3);
    border-top: 3px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 15px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Error Messages */
.pos-error {
    background: #fee2e2;
    color: #991b1b;
    padding: 16px;
    border-radius: 8px;
    border: 1px solid #fecaca;
    margin: 20px;
    text-align: center;
    font-weight: 500;
}

/* Tablet Styles (768px and up) */
@media (min-width: 768px) {
    #pos-barcode-scanner {
        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.2);
        padding: 8px 16px;
        border-radius: 20px;
    }
    
    .pos-main-content {
        display: grid;
        grid-template-columns: 320px 1fr;
        min-height: 600px;
    }
    
    .pos-controls-sidebar {
        border-right: 1px solid #e2e8f0;
        border-bottom: none;
        padding: 25px;
    }
    
    .scan-input-group > div:last-child {
        flex-direction: row;
    }
    
    .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;
    }
    
    .pos-cart-table th,
    .pos-cart-table td {
        padding: 14px 12px;
    }
    
    .pos-cart-table th {
        font-size: 14px;
    }
    
    .pos-cart-table td {
        font-size: 14px;
    }
    
    .item-name {
        max-width: 200px;
    }
    
    .qty-btn {
        width: 28px;
        height: 28px;
        font-size: 14px;
    }
    
    .qty-display {
        min-width: 35px;
        font-size: 14px;
    }
    
    .remove-btn {
        padding: 6px 12px;
        font-size: 12px;
    }
    
    .grand-total-row td {
        font-size: 16px;
        padding: 18px 12px;
    }
    
    #grand-total {
        font-size: 18px;
    }
}

/* Desktop Styles (1024px and up) */
@media (min-width: 1024px) {
    .pos-controls-sidebar {
        padding: 30px;
    }
    
    .pos-cart-section {
        padding: 30px;
    }
    
    .scan-input-group {
        gap: 10px;
    }
    
    .payment-inputs {
        gap: 25px;
    }
    
    .action-buttons {
        gap: 16px;
    }
    
    .pos-cart-table {
        min-width: auto;
    }
    
    .pos-cart-table th,
    .pos-cart-table td {
        padding: 16px;
    }
    
    .item-name {
        max-width: none;
    }
    
    .price-col, .total-col {
        width: 100px;
    }
    
    .qty-col {
        width: 120px;
    }
    
    .action-col {
        width: 90px;
    }
}

/* Large Desktop Styles (1200px and up) */
@media (min-width: 1200px) {
    .pos-main-content {
        grid-template-columns: 350px 1fr;
    }
    
    .pos-controls-sidebar {
        padding: 35px;
    }
    
    .scan-input-group {
        gap: 12px;
    }
    
    .payment-inputs {
        gap: 30px;
    }
    
    .pos-cart-table th,
    .pos-cart-table td {
        padding: 18px;
    }
    
    .grand-total-row td {
        padding: 20px 18px;
    }
}

/* Small Screen Optimizations */
@media (max-width: 480px) {
    #pos-barcode-scanner {
        margin: 5px;
        border-radius: 6px;
    }
    
    .pos-header {
        padding: 12px 15px;
    }
    
    .pos-header h2 {
        font-size: 18px;
    }
    
    .pos-controls-sidebar {
        padding: 15px;
    }
    
    .pos-cart-section {
        padding: 15px;
    }
    
    .pos-cart-table {
        min-width: 450px;
        font-size: 12px;
    }
    
    .pos-cart-table th,
    .pos-cart-table td {
        padding: 8px 6px;
    }
    
    .pos-cart-table th {
        font-size: 12px;
    }
    
    .item-name {
        max-width: 120px;
    }
    
    .qty-btn {
        width: 22px;
        height: 22px;
        font-size: 11px;
    }
    
    .qty-display {
        min-width: 25px;
        font-size: 12px;
    }
    
    .remove-btn {
        padding: 3px 6px;
        font-size: 10px;
    }
    
    .scan-input-group > div:last-child {
        flex-direction: column;
        gap: 8px;
    }
    
    #manual-add-btn {
        width: 100%;
    }
    
    .grand-total-row td {
        padding: 12px 6px;
        font-size: 13px;
    }
    
    #grand-total {
        font-size: 14px;
    }
    
    .customer-name-input {
        min-width: 120px;
        font-size: 13px;
    }
}

/* Ultra Small Screen (320px) */
@media (max-width: 320px) {
    .pos-cart-table {
        min-width: 300px;
    }
    
    .pos-cart-table th:nth-child(2),
    .pos-cart-table td:nth-child(2) {
        display: none;
    }
    
    .item-name {
        max-width: 100px;
    }
    
    .customer-name-input {
        min-width: 100px;
        max-width: 150px;
    }
}

/* Print Styles */
@media print {
    #pos-barcode-scanner {
        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;
    }
}

/* Focus and Accessibility Improvements */
button:focus,
input:focus {
    outline: 2px solid #31ad75;
    outline-offset: 2px;
}

button:focus:not(:focus-visible) {
    outline: none;
}

/* 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;
    }
}