/* License Plate Scanner CSS */

.btn-search {
    background: #2196F3;
    color: white;
    border: none;
    border-radius: 8px;
    padding: 15px 25px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    width: 30%;
}

.btn-search:active {
    background: #1976D2;
}

.scanner-header {
    display: flex;
    align-items: stretch;
    justify-content: flex-start;
    gap: 8px;
    margin-bottom: 10px;
}

.scanner-container {
    max-width: 600px;
    margin: 0 auto;
    padding: 15px;
    width: 100%;
}

.scanner-title {
    color: #2196F3;
    font-size: 18px;
    margin: 0;
}

.collapse-btn {
    background: #f0f0f0;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 3px 8px;
    font-size: 11px;
    cursor: pointer;
    color: #555;
    white-space: nowrap;
}

.collapse-btn:hover {
    background: #e0e0e0;
}

.collapse-btn-full {
    width: 100%;
    text-align: left;
    margin-bottom: 4px;
    font-size: 12px;
    padding: 6px 10px;
}

.collapsible {
    overflow: hidden;
}

.collapsible.hidden {
    display: none !important;
}

.result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.result-match {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.result-text-main {
    font-size: 24px;
    font-weight: bold;
    color: #2196F3;
    letter-spacing: 2px;
    margin: 0;
}

.ocr-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 0;
    border-top: 1px solid #eee;
    margin-top: 4px;
    font-size: 11px;
}

.ocr-label { color: #999; }
.ocr-value { font-weight: 600; color: #333; }
.ocr-conf  { color: #666; margin-left: auto; }

.hidden {
    display: none !important;
}

#camera-view {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.video-wrapper {
    position: relative;
    width: 100%;
    height: 55vh; /* Increased from 38vh for better visibility */
    min-height: 300px;
    overflow: hidden;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    background: #000;
}

video {
    width: 100%;
    height: 100%;
    background: #000;
    border-radius: 6px;
    display: block;
    object-fit: cover;
}

.roi-box {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    border: 2px solid rgba(33, 150, 243, 0.3);
    border-radius: 8px;
    pointer-events: none;
    z-index: 10;
    box-shadow: 0 0 0 100vmax rgba(0,0,0,0.5); /* Use vmax for better mobile compatibility */
    transition: all 0.3s ease;
    width: 180px; /* Default size */
    height: 60px;
}

.roi-corner {
    position: absolute;
    width: 15px;
    height: 15px;
    border: 3px solid #fff;
    pointer-events: none;
    z-index: 12;
}

.corner-tl { top: -3px; left: -3px; border-right: 0; border-bottom: 0; }
.corner-tr { top: -3px; right: -3px; border-left: 0; border-bottom: 0; }
.corner-bl { bottom: -3px; left: -3px; border-right: 0; border-top: 0; }
.corner-br { bottom: -3px; right: -3px; border-left: 0; border-top: 0; }

/* Scanning line animation */
.roi-box-scanner {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background: linear-gradient(to right, transparent, #2196F3, transparent);
    box-shadow: 0 0 8px #2196F3;
    z-index: 11;
    animation: scan 2s linear infinite;
}

@keyframes scan {
    0% { top: 0%; opacity: 0; }
    10% { opacity: 1; }
    90% { opacity: 1; }
    100% { top: 100%; opacity: 0; }
}

canvas.hidden {
    display: none;
}

#debug-canvas {
    width: auto;
    max-width: 100%;
    max-height: 70px;
    height: auto;
    background: #000;
    border: 2px solid #2196F3;
    border-radius: 4px;
    margin: 6px auto 0;
    display: block;
}

.debug-section {
    margin: 4px 0;
}

.paused .roi-box-scanner { animation-play-state: paused; opacity: 0; }

.pause-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    z-index: 20;
    cursor: pointer;
}
.pause-overlay.hidden { display: none !important; }
.pause-overlay-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}
.pause-play-btn {
    width: 72px;
    height: 72px;
    background: rgba(255,255,255,0.95);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    color: #2196F3;
    box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}
.pause-label {
    color: white;
    font-size: 15px;
    font-weight: 600;
    text-shadow: 0 1px 4px rgba(0,0,0,0.5);
}

.scanner-controls {
    display: flex;
    gap: 10px;
}

.btn-stats {
    background: #9C27B0;
    color: white;
    border: none;
    border-radius: 8px;
    padding: 15px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    width: 20%;
}

.btn-stats:active {
    background: #7B1FA2;
}

.btn-freeze {
    background: #FF9800;
    color: white;
    padding: 15px 25px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    width: 45%;
    margin-bottom: 0;
}

.btn-freeze:active {
    background: #F57C00;
}

.btn-scanner-primary, .btn-scanner-secondary {
    padding: 15px 25px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    width: 100%;
}

.btn-scanner-primary {
    background: #2196F3;
    color: white;
}

.btn-scanner-primary:active {
    background: #1976D2;
}

.btn-scanner-secondary {
    background: #757575;
    color: white;
}

.btn-scanner-secondary:active {
    background: #616161;
}

.result-box {
    background: white;
    padding: 10px 12px;
    border-radius: 8px;
    margin-bottom: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.confidence {
    text-align: center;
    color: #666;
    font-size: 10px;
    line-height: 1.3;
}

.scanner-status {
    margin-top: 15px;
    padding: 12px;
    border-radius: 8px;
    text-align: center;
    font-size: 14px;
}

.scanner-status.info {
    background: #E3F2FD;
    color: #1976D2;
}

.scanner-status.error {
    background: #FFEBEE;
    color: #C62828;
}

.scanner-status.success {
    background: #C8E6C9;
    color: #2E7D32;
    font-weight: bold;
}

.last-detection {
    text-align: center;
    color: #666;
    margin-top: 10px;
    font-size: 14px;
}

.preprocessing-controls {
    background: #f5f5f5;
    padding: 8px 10px;
    border-radius: 6px;
    margin-bottom: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    font-size: 12px;
}

.preprocessing-controls label {
    display: flex;
    align-items: center;
    gap: 5px;
    color: #333;
    font-weight: 500;
}

.preprocessing-controls input[type="range"] {
    width: 80px;
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    .scanner-container {
        padding: 8px;
        max-width: 100%;
    }
    
    .scanner-title {
        font-size: 16px;
        margin-bottom: 8px;
    }
    
    .scanner-subtitle {
        font-size: 14px;
        margin-bottom: 6px;
    }
    
    .video-wrapper {
        height: 28vh;
    }
    
    video {
        max-height: none;
        height: 100%;
    }
    
    #debug-canvas {
        max-height: 50px;
    }
    
    .debug-section {
        margin: 4px 0;
    }
    
    #camera-view {
        gap: 6px;
    }
    
    .result-text {
        font-size: 16px;
    }
    
    .comparison {
        gap: 6px;
    }
    
    .result-column {
        padding: 6px;
    }
    
    .result-box {
        padding: 8px;
        margin-bottom: 8px;
    }
    
    .btn-scanner-primary, .btn-scanner-secondary, .btn-freeze {
        padding: 10px 16px;
        font-size: 14px;
    }
}

@media (max-width: 480px) {
    .scanner-container {
        padding: 6px;
    }
    
    .scanner-title {
        font-size: 14px;
        margin-bottom: 6px;
    }
    
    .video-wrapper {
        height: 45vh; /* Increased from 28vh */
    }
    
    video { 
        object-fit: cover; 
    }
    
    .debug-section {
        margin: 2px 0;
    }
    
    #debug-canvas {
        max-height: 40px;
        margin-bottom: 4px;
    }
    
    .result-text { 
        font-size: 14px; 
    }
    
    .comparison {
        grid-template-columns: 1fr;
        gap: 4px;
    }
    
    .result-column {
        padding: 4px;
        font-size: 11px;
    }
    
    .result-column h3 {
        font-size: 9px;
        margin-bottom: 2px;
    }
    
    .result-box {
        padding: 6px;
        margin-bottom: 4px;
    }
    
    .result-box h2 {
        font-size: 12px !important;
    }
    
    #timestamp, .last-detection { 
        display: none; 
    }
    
    .scanner-status {
        font-size: 12px;
        padding: 8px;
        margin-top: 8px;
    }
    
    .preprocessing-controls {
        flex-direction: column;
        gap: 6px;
        padding: 6px;
        font-size: 11px;
    }
    
    .preprocessing-controls input[type="range"] {
        width: 80px;
    }
    
    .btn-scanner-primary, .btn-scanner-secondary, .btn-freeze {
        padding: 8px 12px;
        font-size: 13px;
    }
    
    #camera-view {
        gap: 4px;
    }
}
