:root {
    --bg-color: #030712;
    --panel-bg: rgba(17, 24, 39, 0.65);
    --border-color: rgba(55, 65, 81, 0.5);
    --text-main: #f9fafb;
    --text-muted: #9ca3af;
    --accent: #3b82f6;
    --accent-glow: rgba(59, 130, 246, 0.5);
    --accent-hover: #2563eb;
    --success: #10b981;
    --danger: #ef4444;
    --surface-hover: rgba(55, 65, 81, 0.3);
    --font-main: 'Outfit', sans-serif;
    --glass-blur: blur(16px);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-main);
    background-color: var(--bg-color);
    color: var(--text-main);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    overflow: hidden;
    position: relative;
}

/* Futuristic Background Effects */
.background-effects {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    z-index: 0;
    pointer-events: none;
}

.glow-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(100px);
    opacity: 0.15;
    animation: float 20s infinite ease-in-out;
}

.orb-1 {
    width: 600px;
    height: 600px;
    background: #3b82f6;
    top: -200px;
    left: -100px;
}

.orb-2 {
    width: 500px;
    height: 500px;
    background: #8b5cf6;
    bottom: -100px;
    right: -100px;
    animation-delay: -5s;
}

.orb-3 {
    width: 400px;
    height: 400px;
    background: #10b981;
    top: 40%;
    left: 50%;
    transform: translate(-50%, -50%);
    animation-delay: -10s;
    opacity: 0.08;
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0) scale(1);
    }

    50% {
        transform: translateY(-30px) scale(1.05);
    }
}

.app-container {
    position: relative;
    z-index: 10;
    display: flex;
    width: 96vw;
    height: 94vh;
    border-radius: 20px;
    background: var(--panel-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border-color);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7), inset 0 1px 0 rgba(255, 255, 255, 0.05);
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: 320px;
    border-right: 1px solid var(--border-color);
    background: rgba(17, 24, 39, 0.4);
    display: flex;
    flex-direction: column;
}

.logo-container {
    padding: 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    font-size: 28px;
    color: var(--accent);
    filter: drop-shadow(0 0 10px var(--accent-glow));
}

.logo-container h1 {
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.highlight {
    color: var(--accent);
}

.controls {
    padding: 24px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 32px;
}

.control-group label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    font-weight: 600;
}

/* Navigation Menu */
.nav-menu {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.nav-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 10px;
    color: var(--text-muted);
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
}

.nav-btn i {
    font-size: 1.2rem;
}

.nav-btn:hover {
    background: var(--surface-hover);
    color: var(--text-main);
}

.nav-btn.active {
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.3);
    color: #60a5fa;
    box-shadow: 0 0 15px rgba(59, 130, 246, 0.15);
}

.nav-btn.active i {
    color: var(--accent);
}

.view-controls {
    display: none;
    animation: fadeIn 0.3s ease;
}

.view-controls.active-controls {
    display: flex;
    flex-direction: column;
    gap: 32px;
}

/* Tabs */
.tabs {
    display: flex;
    background: rgba(3, 7, 18, 0.5);
    padding: 6px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.tab {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 12px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-family: inherit;
    font-weight: 500;
    font-size: 0.9rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.tab.active {
    background: rgba(55, 65, 81, 0.5);
    color: var(--text-main);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* Upload & Camera Actions */
.control-section {
    display: none;
}

.control-section.active-control {
    display: block;
    animation: fadeIn 0.3s ease;
}

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

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.upload-zone {
    border: 2px dashed rgba(156, 163, 175, 0.3);
    border-radius: 14px;
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: rgba(3, 7, 18, 0.4);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.upload-zone:hover {
    border-color: var(--accent);
    background: rgba(59, 130, 246, 0.05);
    transform: translateY(-2px);
}

.upload-icon {
    font-size: 2.5rem;
    color: var(--text-muted);
    transition: color 0.3s ease;
}

.upload-zone:hover .upload-icon {
    color: var(--accent);
}

.upload-zone p {
    font-size: 0.95rem;
    color: var(--text-main);
    font-weight: 500;
}

.upload-sub {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.action-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 14px;
    border: none;
    border-radius: 10px;
    font-family: inherit;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    background: linear-gradient(135deg, var(--accent), #2563eb);
    color: #fff;
    transition: all 0.3s ease;
    margin-bottom: 12px;
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.3);
}

.action-btn i {
    font-size: 1.2rem;
}

.action-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: #374151;
    box-shadow: none;
}

.action-btn.secondary {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-main);
    box-shadow: none;
}

.action-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.4);
    filter: brightness(1.1);
}

.action-btn.secondary:hover:not(:disabled) {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.3);
    color: #f87171;
    box-shadow: 0 4px 15px rgba(239, 68, 68, 0.15);
}

.status-indicator {
    margin-top: auto;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.85rem;
    color: var(--text-muted);
    padding: 14px 16px;
    background: rgba(3, 7, 18, 0.6);
    border-radius: 10px;
    border: 1px solid var(--border-color);
    font-weight: 500;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--text-muted);
}

.status-dot.online {
    background: var(--success);
    box-shadow: 0 0 10px var(--success);
}

.status-dot.processing {
    background: #a78bfa;
    box-shadow: 0 0 12px #a78bfa;
    animation: pulse 1s infinite alternate;
}

@keyframes pulse {
    0% {
        transform: scale(0.9);
        opacity: 0.7;
    }

    100% {
        transform: scale(1.1);
        opacity: 1;
    }
}

/* Workspace */
.workspace {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

.top-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 32px;
    border-bottom: 1px solid var(--border-color);
    background: rgba(17, 24, 39, 0.2);
}

.top-nav h2 {
    font-size: 1.2rem;
    font-weight: 600;
    letter-spacing: -0.5px;
}

.badges {
    display: flex;
    gap: 12px;
}

.badge {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    border: 1px solid var(--border-color);
    background: rgba(3, 7, 18, 0.4);
}

.ai-badge {
    color: var(--success);
    border-color: rgba(16, 185, 129, 0.3);
}

.ocr-badge {
    color: #f59e0b;
    border-color: rgba(245, 158, 11, 0.3);
}

/* Views Management */
.view-panel {
    display: none;
    flex: 1;
    overflow: hidden;
    animation: slideUp 0.4s ease;
}

.view-panel.active-view {
    display: flex;
    flex-direction: column;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 24px;
    padding: 24px;
    flex: 1;
    min-height: 0;
}

.panel {
    background: rgba(17, 24, 39, 0.4);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
}

.panel-header {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(3, 7, 18, 0.3);
}

.header-title {
    display: flex;
    align-items: center;
    gap: 10px;
}

.header-title i {
    font-size: 1.2rem;
    color: var(--accent);
}

.panel-header h3 {
    font-size: 1rem;
    color: var(--text-main);
    font-weight: 600;
}

.latency {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    color: #60a5fa;
    font-weight: 500;
    font-family: monospace;
    background: rgba(59, 130, 246, 0.1);
    padding: 4px 10px;
    border-radius: 6px;
    border: 1px solid rgba(59, 130, 246, 0.2);
}

.count-badge {
    background: var(--accent);
    color: #fff;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 700;
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.4);
}

.feed-container {
    flex: 1;
    position: relative;
    background: transparent;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    background-image: radial-gradient(rgba(55, 65, 81, 0.4) 1px, transparent 1px);
    background-size: 20px 20px;
}

#visualizer-canvas {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    transition: opacity 0.3s ease;
    filter: drop-shadow(0 0 20px rgba(0, 0, 0, 0.5));
}

#camera-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.placeholder-content {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    color: var(--text-muted);
    pointer-events: none;
}

.placeholder-content i {
    font-size: 3rem;
    opacity: 0.5;
}

.placeholder-content p {
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--text-main);
}

.placeholder-content span {
    font-size: 0.9rem;
}

.results-list {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.results-list::-webkit-scrollbar {
    width: 6px;
}

.results-list::-webkit-scrollbar-track {
    background: transparent;
}

.results-list::-webkit-scrollbar-thumb {
    background: rgba(55, 65, 81, 0.8);
    border-radius: 10px;
}

.empty-state {
    text-align: center;
    color: var(--text-muted);
    padding: 60px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    border: 2px dashed rgba(55, 65, 81, 0.4);
    border-radius: 12px;
    margin: auto 0;
    background: rgba(3, 7, 18, 0.2);
}

.empty-state i {
    font-size: 2.5rem;
    color: rgba(156, 163, 175, 0.4);
}

/* Detection Card */
.detection-card {
    background: rgba(3, 7, 18, 0.6);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px;
    animation: slideIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

.detection-card::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--accent);
    box-shadow: 0 0 10px var(--accent);
}

.detection-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.4);
    border-color: rgba(59, 130, 246, 0.4);
    background: rgba(17, 24, 39, 0.8);
}

.detection-details {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.detail-row:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.detail-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.plate-text {
    font-family: monospace;
    font-size: 1.25rem;
    font-weight: 700;
    color: #fbbf24;
    letter-spacing: 3px;
    background: rgba(245, 158, 11, 0.1);
    padding: 6px 12px;
    border-radius: 6px;
    border: 1px solid rgba(245, 158, 11, 0.2);
    box-shadow: inset 0 0 10px rgba(245, 158, 11, 0.1);
}

.state-text {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-main);
}

.conf-text {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--success);
    background: rgba(16, 185, 129, 0.1);
    padding: 2px 8px;
    border-radius: 4px;
}

/* Analytics View Styling */
.analytics-wrapper {
    padding: 24px;
    height: 100%;
}

.analytics-panel {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.refresh-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.3);
    color: #60a5fa;
    border-radius: 8px;
    font-family: inherit;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.refresh-btn:hover {
    background: rgba(59, 130, 246, 0.2);
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.2);
}

.charts-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    padding: 24px;
    flex: 1;
    overflow-y: auto;
}

.chart-card {
    background: rgba(3, 7, 18, 0.4);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    transition: transform 0.2s ease;
}

.chart-card:hover {
    border-color: rgba(55, 65, 81, 0.9);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.chart-header h4 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 4px;
}

.chart-header span {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.chart-img-container {
    flex: 1;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 10px;
    overflow: hidden;
}

.chart-img-container img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 4px;
    filter: brightness(0.9) contrast(1.1);
    /* Slight adjustment for dark mode reading */
}

.chart-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    color: var(--text-muted);
}

.chart-error i {
    font-size: 2.5rem;
    color: #f59e0b;
    opacity: 0.7;
}

@media (max-width: 1200px) {
    .charts-grid {
        grid-template-columns: 1fr;
    }
}

/* ── Novelty Additions ──────────────────────────────────────────────────── */

/* RTO Validator header badge */
.valid-badge {
    color: #34d399;
    border-color: rgba(52, 211, 153, 0.3);
}

/* Validity strip — sits above detection-details inside .detection-card */
.validity-strip {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 0.78rem;
    font-weight: 700;
    margin-bottom: 12px;
    letter-spacing: 0.5px;
    overflow: hidden;
}

.validity-strip i {
    font-size: 1rem;
    flex-shrink: 0;
}

.validity-detail {
    font-weight: 400;
    font-size: 0.73rem;
    opacity: 0.8;
    letter-spacing: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.validity-valid {
    background: rgba(16, 185, 129, 0.12);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: #34d399;
}

.validity-partial {
    background: rgba(245, 158, 11, 0.12);
    border: 1px solid rgba(245, 158, 11, 0.3);
    color: #fbbf24;
}

.validity-invalid {
    background: rgba(239, 68, 68, 0.12);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #f87171;
}

.validity-unknown {
    background: rgba(156, 163, 175, 0.1);
    border: 1px solid rgba(156, 163, 175, 0.2);
    color: var(--text-muted);
}

/* History Panel */
.history-header {
    border-top: 1px solid var(--border-color);
    margin-top: 4px;
}

.clear-history-btn {
    background: transparent;
    border: 1px solid rgba(239, 68, 68, 0.25);
    color: #f87171;
    border-radius: 6px;
    padding: 4px 8px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
}

.clear-history-btn:hover {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.5);
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.2);
}

.history-list {
    max-height: 200px;
    overflow-y: auto;
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.history-list::-webkit-scrollbar {
    width: 4px;
}

.history-list::-webkit-scrollbar-thumb {
    background: rgba(55, 65, 81, 0.8);
    border-radius: 10px;
}

.history-entry {
    background: rgba(3, 7, 18, 0.5);
    border: 1px solid rgba(55, 65, 81, 0.4);
    border-radius: 8px;
    padding: 8px 12px;
    animation: fadeIn 0.3s ease forwards;
}

.history-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.history-plate {
    font-family: monospace;
    font-size: 1rem;
    font-weight: 700;
    color: #fbbf24;
    letter-spacing: 2px;
}

.history-badge {
    font-size: 0.65rem;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 10px;
    letter-spacing: 0.5px;
}

.history-meta {
    display: flex;
    justify-content: space-between;
    font-size: 0.72rem;
    color: var(--text-muted);
    gap: 8px;
}

.history-meta span {
    display: flex;
    align-items: center;
    gap: 4px;
}

.history-empty {
    padding: 24px 20px;
}
