/* Parts Scanner Styles */

/* Header */
.app-header {
    background: #1a202c;
    border: 1px solid #4a5568;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    max-width: 1200px;
    margin: 0 auto;
}

.header-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0;
    color: #ffffff;
}

.btn-back,
.btn-icon {
    background: none;
    border: none;
    padding: 0.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fbbf24;
    transition: all 0.2s ease;
    border-radius: 8px;
    min-width: 44px;
    min-height: 44px;
}

.btn-back:hover,
.btn-icon:hover {
    background: rgba(251, 191, 36, 0.1);
}

.btn-back:active,
.btn-icon:active {
    transform: scale(0.95);
}

/* Scanner Content */
.scanner-content {
    padding: 0;
    background: #1a202c;
    color: #ffffff;
}

/* Job Info Card */
.job-info-card {
    background: #2d3748;
    padding: 1rem;
    border: 1px solid #4a5568;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.job-info-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.job-booking-number {
    font-size: 1.1rem;
    font-weight: 600;
    color: #ffffff;
    margin-bottom: 0.25rem;
}

.job-vehicle-info {
    font-size: 0.9rem;
    color: #718096;
}

.job-parts-count {
    text-align: right;
    font-size: 0.9rem;
    color: #718096;
}

.job-parts-count span {
    font-size: 1.4rem;
    font-weight: 700;
    color: #fbbf24;
    display: block;
}

/* Scanner Section */
.scanner-section {
    padding: 1rem;
}

/* Scanner Preview Container */
.scanner-preview-container {
    position: relative;
    width: 100%;
    background: #000;
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 1rem;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.scanner-preview {
    width: 100%;
    min-height: 400px;
    background: #1a1a1a;
    position: relative;
}

#scannerPreview video {
    width: 100%;
    height: auto;
    display: block;
}

#scannerPreview canvas {
    display: none !important;
}

/* Scan Overlay */
.scan-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.scan-frame {
    width: 300px;
    height: 300px;
    border: 3px solid rgba(251, 191, 36, 0.8);
    border-radius: 12px;
    box-shadow: 
        0 0 0 9999px rgba(0, 0, 0, 0.5),
        inset 0 0 0 2px rgba(255, 255, 255, 0.3);
    position: relative;
    animation: scanPulse 2s ease-in-out infinite;
}

.scan-frame::before,
.scan-frame::after {
    content: '';
    position: absolute;
    width: 30px;
    height: 30px;
    border: 4px solid #fbbf24;
}

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

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

@keyframes scanPulse {
    0%, 100% {
        box-shadow: 
            0 0 0 9999px rgba(0, 0, 0, 0.5),
            inset 0 0 0 2px rgba(255, 255, 255, 0.3);
    }
    50% {
        box-shadow: 
            0 0 0 9999px rgba(0, 0, 0, 0.5),
            inset 0 0 0 2px rgba(255, 255, 255, 0.6),
            0 0 20px rgba(251, 191, 36, 0.8);
    }
}

.scan-instructions {
    margin-top: 1.5rem;
    color: white;
    font-size: 0.95rem;
    text-align: center;
    background: rgba(0, 0, 0, 0.7);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    backdrop-filter: blur(4px);
}

/* Scan Status */
.scan-status {
    position: absolute;
    top: 1rem;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    backdrop-filter: blur(4px);
    z-index: 10;
}

.scan-status-ready {
    background: rgba(251, 191, 36, 0.9);
}

.scan-status-scanning {
    background: rgba(25, 135, 84, 0.9);
    animation: statusPulse 1.5s ease-in-out infinite;
}

.scan-status-error {
    background: rgba(220, 53, 69, 0.9);
}

@keyframes statusPulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

/* Scanner Controls */
.scanner-controls {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.scanner-controls .btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.875rem;
    font-weight: 600;
    min-height: 54px;
}

.scanner-controls svg {
    flex-shrink: 0;
}

/* Manual Entry Section */
.manual-entry-section {
    margin-bottom: 1.5rem;
}

.section-divider {
    text-align: center;
    position: relative;
    margin: 1.5rem 0 1rem;
}

.section-divider::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background: #4a5568;
}

.section-divider span {
    position: relative;
    background: #1a202c;
    padding: 0 1rem;
    color: #ffffff;
    font-size: 0.875rem;
}

.manual-entry-section .input-group {
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    border-radius: 8px;
    overflow: hidden;
}

.manual-entry-section .form-control {
    border: 1px solid #ced4da;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    min-height: 48px;
}

.manual-entry-section .btn {
    padding: 0.75rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    white-space: nowrap;
}

/* Scan Results Section */
.scan-results-section {
    background: #2d3748;
    margin: 1rem;
    margin-top: 2rem;
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.1);
    overflow: hidden;
}

.scan-results-section .section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    border: 1px solid #4a5568;
    background: #1a202c;
    color: #ffffff;
}

.scan-results-section h2 {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0;
}

.btn-close-results {
    background: none;
    border: none;
    font-size: 2rem;
    line-height: 1;
    color: #718096;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s;
}

.btn-close-results:hover {
    background: #374151;
    color: #ffffff;
}

/* Part Details Card */
.part-details-card {
    padding: 1.25rem;
}

.part-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1rem;
    color: #718096;
}

/* Part Found */
.part-found {
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.part-info {
    margin-bottom: 1.25rem;
    padding-bottom: 1.25rem;
    border: 1px solid #4a5568;
}

.part-name {
    font-size: 1.25rem;
    font-weight: 600;
    color: #ffffff;
    margin-bottom: 0.5rem;
}

.part-number,
.part-supplier {
    font-size: 0.9rem;
    color: #718096;
    margin-bottom: 0.25rem;
}

.part-pricing {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
    padding: 1rem;
    background: #1a202c;
    border-radius: 8px;
    color: #ffffff;
}

.part-cost,
.part-price {
    display: flex;
    flex-direction: column;
}

.part-cost .label,
.part-price .label {
    font-size: 0.8rem;
    color: #718096;
    margin-bottom: 0.25rem;
    text-transform: uppercase;
    font-weight: 600;
}

.part-cost .value {
    font-size: 1.5rem;
    font-weight: 700;
    color: #dc3545;
}

.part-price .value {
    font-size: 1.5rem;
    font-weight: 700;
    color: #198754;
}

.part-stock {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
    padding: 0.75rem 1rem;
    background: #e7f3ff;
    border-radius: 8px;
    border-left: 4px solid #fbbf24;
}

.stock-label {
    font-weight: 600;
    color: #fbbf24;
}

.stock-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: #fbbf24;
}

.stock-unit {
    color: #718096;
}

/* Quantity Input Group */
.quantity-input-group {
    margin-bottom: 1.25rem;
}

.quantity-input-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: #a0aec0;
}

.quantity-controls {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.btn-quantity {
    width: 48px;
    height: 48px;
    border: 2px solid #fbbf24;
    background: #2d3748;
    color: #fbbf24;
    border-radius: 8px;
    font-size: 1.5rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

.btn-quantity:hover {
    background: #fbbf24;
    color: white;
}

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

.quantity-controls .form-control {
    flex: 1;
    text-align: center;
    font-size: 1.25rem;
    font-weight: 600;
    padding: 0.75rem;
    border: 2px solid #4a5568;
    border-radius: 8px;
    height: 48px;
}

.quantity-controls .form-control:focus {
    border-color: #fbbf24;
    box-shadow: 0 0 0 0.25rem rgba(251, 191, 36, 0.15);
}

/* Part Not Found */
.part-not-found {
    text-align: center;
    padding: 2rem 1rem;
    animation: slideIn 0.3s ease-out;
}

.not-found-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.not-found-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: #dc3545;
    margin-bottom: 0.5rem;
}

.not-found-message {
    color: #718096;
    margin-bottom: 1.5rem;
}

.not-found-message strong {
    color: #ffffff;
    font-family: monospace;
}

.not-found-actions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.not-found-actions .btn {
    min-height: 48px;
}

/* Added Parts Section */
.added-parts-section {
    background: #2d3748;
    margin: 1rem;
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.1);
    overflow: hidden;
}

.added-parts-section .section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    border: 1px solid #4a5568;
    background: #1a202c;
    color: #ffffff;
}

.added-parts-section h2 {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0;
}

.added-parts-list {
    max-height: 300px;
    overflow-y: auto;
}

/* Added Part Card */
.added-part-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #f0f0f0;
    transition: background 0.2s;
    animation: slideIn 0.3s ease-out;
}

.added-part-card:last-child {
    border-bottom: none;
}

.added-part-card:hover {
    background: #1a202c;
    color: #ffffff;
}

.added-part-info {
    flex: 1;
}

.added-part-name {
    font-weight: 600;
    color: #ffffff;
    margin-bottom: 0.25rem;
}

.added-part-number {
    font-size: 0.85rem;
    color: #718096;
}

.added-part-quantity {
    font-size: 1.1rem;
    font-weight: 600;
    color: #fbbf24;
    min-width: 50px;
    text-align: center;
}

.added-part-price {
    font-size: 1.1rem;
    font-weight: 700;
    color: #198754;
    min-width: 80px;
    text-align: right;
}

/* Touch Optimizations */
@media (hover: none) and (pointer: coarse) {
    .btn {
        min-height: 48px;
    }
    
    .form-control {
        min-height: 48px;
        font-size: 16px; /* Prevents zoom on iOS */
    }
}

/* Tablet Landscape */
@media (min-width: 768px) and (orientation: landscape) {
    .scanner-section {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 1.5rem;
        padding: 1.5rem;
    }
    
    .scanner-preview-container {
        margin-bottom: 0;
    }
    
    .scan-results-section {
        margin: 0 1.5rem 1.5rem;
    }
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    backdrop-filter: blur(4px);
}

.loading-text {
    color: white;
    margin-top: 1rem;
    font-size: 1rem;
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    body {
        background-color: #ffffff;
        color: #374151;
    }

    .scanner-content {
        background: #0f172a;
    }

    .job-info-card,
    .scan-results-section,
    .added-parts-section {
        background: #2d2d2d;
        color: #374151;
    }

    .scan-results-section .section-header,
    .added-parts-section .section-header {
        background: #1a1a1a;
        color: #374151;
    }

    .part-card {
        background: #2d2d2d;
        color: #374151;
        border-color: #a0aec0;
    }

    .part-name,
    .part-number,
    .added-part-name {
        color: #374151 !important;
    }

    .part-description,
    .part-stock,
    .text-muted,
    .added-part-number {
        color: #adb5bd !important;
    }

    .part-pricing,
    .section-divider span {
        background: #1a1a1a;
        color: #374151;
    }

    .added-part-card {
        border-bottom-color: #a0aec0;
    }

    .added-part-card:hover {
        background: #1a1a1a;
    }

    .form-control {
        background: #2d2d2d;
        color: #374151;
        border-color: #a0aec0;
    }

    .form-control:focus {
        background: #1a1a1a;
        border-color: #4dabf7;
    }
}
