/* Reset e Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #2196F3;
    --secondary-color: #1976D2;
    --success-color: #4CAF50;
    --warning-color: #FF9800;
    --error-color: #f44336;
    --text-primary: #212121;
    --text-secondary: #757575;
    --bg-color: #fafafa;
    --card-bg: #ffffff;
    --shadow: 0 2px 8px rgba(0,0,0,0.1);
    --shadow-lg: 0 4px 16px rgba(0,0,0,0.15);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

#app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    padding: 1rem;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.status-bar {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 0.875rem;
}

.status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0.75rem;
    background: rgba(255,255,255,0.2);
    border-radius: 20px;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success-color);
    animation: pulse 2s infinite;
}

.status.offline .status-dot {
    background: var(--error-color);
}

.pending-badge {
    background: var(--warning-color);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Camera Container */
.camera-container {
    position: relative;
    width: 100%;
    height: 60vh;
    min-height: 400px;
    background: #000;
    overflow: hidden;
}

#video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Camera Overlay */
.camera-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.target-frame {
    width: 80%;
    max-width: 400px;
    aspect-ratio: 16/9;
    border: 3px solid rgba(255, 255, 255, 0.8);
    border-radius: 12px;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.3);
}

/* Camera Controls */
.camera-controls {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 2rem 1rem;
    background: linear-gradient(to top, rgba(0,0,0,0.8), transparent);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.zoom-controls {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    align-items: center;
}

.control-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.9);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--shadow);
    transition: all 0.2s;
}

.control-btn:active {
    transform: scale(0.95);
    background: rgba(255, 255, 255, 1);
}

.zoom-level {
    padding: 0.25rem 0.75rem;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 20px;
    font-size: 0.875rem;
    font-weight: 600;
}

.capture-btn {
    width: 80px;
    height: 80px;
    border: none;
    background: transparent;
    cursor: pointer;
    padding: 0;
    transition: transform 0.2s;
}

.capture-btn:active {
    transform: scale(0.95);
}

.capture-ring {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 4px solid white;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
}

.capture-inner {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: white;
}

/* Flash Effect */
.flash {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: white;
    opacity: 0;
    pointer-events: none;
}

.flash.active {
    animation: flash 0.3s;
}

@keyframes flash {
    0% { opacity: 0; }
    50% { opacity: 0.8; }
    100% { opacity: 0; }
}

/* Results Section */
.results-container {
    flex: 1;
    padding: 1.5rem 1rem;
    background: var(--bg-color);
}

.results-container h2 {
    font-size: 1.25rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.results-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.result-card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 1rem;
    box-shadow: var(--shadow);
    display: flex;
    gap: 1rem;
    animation: slideIn 0.3s;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.result-thumbnail {
    width: 100px;
    height: 75px;
    border-radius: 8px;
    object-fit: cover;
    background: #f0f0f0;
}

.result-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.result-plate {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
    font-family: 'Courier New', monospace;
    letter-spacing: 2px;
}

.result-plate.pending {
    color: var(--warning-color);
    font-size: 1.1rem;
}

.result-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.result-badge {
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-success {
    background: #E8F5E9;
    color: var(--success-color);
}

.badge-pending {
    background: #FFF3E0;
    color: var(--warning-color);
}

.badge-error {
    background: #FFEBEE;
    color: var(--error-color);
}

.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-secondary);
}

.empty-state p {
    margin-bottom: 0.5rem;
}

.hint {
    font-size: 0.875rem;
    opacity: 0.7;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    color: white;
}

.loading-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    bottom: 1rem;
    left: 1rem;
    right: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    z-index: 2000;
    pointer-events: none;
}

.toast {
    background: var(--card-bg);
    padding: 1rem;
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    animation: slideUp 0.3s;
    pointer-events: auto;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.toast.success {
    border-left: 4px solid var(--success-color);
}

.toast.error {
    border-left: 4px solid var(--error-color);
}

.toast.warning {
    border-left: 4px solid var(--warning-color);
}

.toast-icon {
    font-size: 1.5rem;
}

.toast-message {
    flex: 1;
    font-size: 0.875rem;
}

/* Responsive */
@media (min-width: 768px) {
    .camera-container {
        height: 70vh;
    }
    
    .results-container {
        padding: 2rem;
    }
    
    .results-list {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    }
}