body {
    background-color: #f8f9fa;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.card {
    border-radius: 10px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    margin-bottom: 30px;
}

.card-header {
    border-radius: 10px 10px 0 0;
    padding: 15px;
}

.scanner-container {
    position: relative;
    width: 100%;
    background-color: #000;
}

.scanner-container.old-style {
    height: 300px;
    border: 1px solid #ddd;
    border-radius: 5px;
    overflow: hidden;
}

.scanner-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Quagga canvas overlay */
.scanner-container canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* Scanner close button */
.scanner-container .btn-danger {
    z-index: 10;
}

.form-label {
    font-weight: 500;
}

.list-group-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.delete-item {
    color: #dc3545;
    cursor: pointer;
}

.delete-item:hover {
    color: #b02a37;
}

.nav-tabs .nav-link {
    color: #495057;
    font-weight: 500;
}

.nav-tabs .nav-link.active {
    color: #0d6efd;
    font-weight: 600;
}

/* Mobile specific styles */
@media (max-width: 768px) {
    .card {
        margin-bottom: 20px;
    }
    
    .scanner-container {
        height: 400px; /* Larger on mobile for better scanning */
    }
    
    /* Make buttons more touch-friendly on mobile */
    .btn {
        min-height: 44px;
        font-size: 16px;
    }
    
    /* Prevent zoom on input focus on iOS */
    input[type="text"],
    input[type="number"],
    select,
    textarea {
        font-size: 16px;
    }
}

/* Landscape orientation for mobile */
@media (max-width: 768px) and (orientation: landscape) {
    .scanner-container {
        height: 250px;
    }
}

/* Custom Autocomplete Styles */
.autocomplete-container {
    position: relative;
    width: 100%;
}

.autocomplete-dropdown {
    position: absolute;
    top: calc(100% + 1px);
    left: 0;
    right: 0;
    background: #ffffff;
    border: 1px solid #ced4da;
    border-radius: 0 0 0.375rem 0.375rem;
    max-height: 160px; /* Reduced height for exactly 5 items */
    overflow-y: auto;
    z-index: 1050;
    display: none;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    margin-top: -1px;
    min-width: 100%;
}

.autocomplete-dropdown.show {
    display: block;
    animation: fadeIn 0.15s ease-in-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-5px); }
    to { opacity: 1; transform: translateY(0); }
}

.autocomplete-item {
    padding: 10px 15px;
    cursor: pointer;
    border-bottom: 1px solid #f8f9fa;
    font-size: 14px;
    color: #212529;
    background: white;
    transition: all 0.15s ease-in-out;
    line-height: 1.4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-height: 32px; /* Consistent height for exactly 5 items */
    display: flex;
    align-items: center;
    
    /* Arabic text support */
    direction: rtl;
    text-align: right;
    unicode-bidi: embed;
}

.autocomplete-item:last-child {
    border-bottom: none;
    border-radius: 0 0 0.375rem 0.375rem;
}

.autocomplete-item:first-child {
    border-top: 1px solid #ced4da;
}

.autocomplete-item:hover {
    background-color: #f8f9fa;
    color: #0d6efd;
    transform: translateX(-2px);
}

.autocomplete-item.selected {
    background-color: #0d6efd;
    color: white;
    font-weight: 500;
}

.autocomplete-item.selected:hover {
    background-color: #0b5ed7;
    transform: none;
}

.autocomplete-item.no-results {
    color: #6c757d;
    font-style: italic;
    cursor: default;
    text-align: center;
    direction: ltr;
}

.autocomplete-item.no-results:hover {
    background-color: transparent;
    transform: none;
}

/* Loading indicator */
.autocomplete-loading {
    padding: 12px 15px;
    color: #6c757d;
    font-style: italic;
    text-align: center;
    cursor: default;
    background: #f8f9fa;
    border-top: 1px solid #ced4da;
}

/* Enhanced focus styles */
.autocomplete-input:focus {
    border-color: #86b7fe;
    outline: 0;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

.autocomplete-input:focus + .autocomplete-dropdown {
    border-color: #86b7fe;
    box-shadow: 0 0.5rem 1rem rgba(13, 110, 253, 0.15);
}

/* Improved scrollbar for dropdown */
.autocomplete-dropdown::-webkit-scrollbar {
    width: 6px;
}

.autocomplete-dropdown::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.autocomplete-dropdown::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.autocomplete-dropdown::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Ensure proper z-index stacking */
.autocomplete-container .form-control {
    position: relative;
    z-index: 1;
}

/* Unified Scanner Styles */
#unifiedScanner .scanner-video {
    width: 100%;
    height: 400px;
    object-fit: cover;
}

.scanner-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 10;
}

.scan-region {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 85%;
    height: 70%;
    border: 3px solid #007bff;
    border-radius: 12px;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.4);
}

.scan-region::before {
    content: 'Position barcodes here';
    position: absolute;
    top: -30px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 123, 255, 0.9);
    color: white;
    padding: 4px 12px;
    border-radius: 15px;
    font-size: 12px;
    font-weight: 500;
}

.scan-region::after {
    content: '';
    position: absolute;
    top: -5px;
    left: -5px;
    right: -5px;
    bottom: -5px;
    border: 2px dashed #007bff;
    border-radius: 16px;
    animation: barcodePulse 2s infinite;
}

@keyframes barcodePulse {
    0%, 100% { opacity: 0.6; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.02); }
}

.scanner-results {
    font-family: monospace;
    font-size: 11px;
}

/* Scanner Styles */
.scanner-container {
    position: relative;
    width: 100%;
}

.scanner-video {
    width: 100%;
    height: 400px;
    object-fit: cover;
    background-color: #000;
}

.scanner-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 400px;
    pointer-events: none;
    z-index: 10;
}

.scan-region {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 250px;
    height: 100px;
    border: 3px solid #007bff;
    border-radius: 8px;
    background-color: transparent;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.3);
}

.scan-region::before,
.scan-region::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    border: 3px solid #007bff;
}

.scan-region::before {
    top: -3px;
    left: -3px;
    border-right: none;
    border-bottom: none;
}

.scan-region::after {
    bottom: -3px;
    right: -3px;
    border-left: none;
    border-top: none;
}

.scanner-status {
    position: relative;
    z-index: 10;
}

.scanner-results {
    font-family: monospace;
    font-size: 12px;
}

/* Mobile scanner adjustments */
@media (max-width: 768px) {
    .scanner-video {
        height: 300px;
    }
    
    .scanner-overlay {
        height: 300px;
    }
    
    .scan-region {
        width: 200px;
        height: 80px;
    }
}

/* Better mobile support */
@media (max-width: 768px) {
    .autocomplete-item {
        padding: 12px 15px;
        font-size: 16px; /* Prevent zoom on iOS */
    }
    
    .autocomplete-dropdown {
        max-height: 180px;
    }
    
    #unifiedScanner .scanner-video {
        height: 300px;
    }
    
    .scan-region {
        width: 90%;
        height: 70%;
    }
} 