:root {
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-tertiary: #1a1a25;
    --bg-elevated: #222230;
    --text-primary: #ffffff;
    --text-secondary: #a0a0b0;
    --text-muted: #606070;
    --accent-primary: #6366f1;
    --accent-secondary: #818cf8;
    --accent-glow: rgba(99, 102, 241, 0.3);
    --success: #22c55e;
    --success-glow: rgba(34, 197, 94, 0.3);
    --warning: #f59e0b;
    --danger: #ef4444;
    --danger-glow: rgba(239, 68, 68, 0.4);
    --border-subtle: rgba(255, 255, 255, 0.08);
    --border-medium: rgba(255, 255, 255, 0.15);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --radius-xl: 28px;
    --shadow-lg: 0 20px 40px rgba(0, 0, 0, 0.4);
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
}

#app.scanning {
    --accent-primary: #ef4444;
    --accent-secondary: #f87171;
    --accent-glow: rgba(239, 68, 68, 0.3);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html,
body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
}

#app {
    height: 100%;
    display: flex;
    flex-direction: column;
}

/* Views */
.view {
    display: none;
    flex: 1;
    flex-direction: column;
    overflow: hidden;
}

.view.active {
    display: flex;
}

/* Camera Container */
.camera-container {
    flex: 1;
    position: relative;
    background: #000;
    overflow: hidden;
}

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

#overlay-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

/* Scan Frame */
.scan-frame {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 85%;
    max-width: 400px;
    aspect-ratio: 3 / 1;
    pointer-events: none;
}

.corner {
    position: absolute;
    width: 24px;
    height: 24px;
    border: 3px solid var(--accent-primary);
}

.corner.tl {
    top: 0;
    left: 0;
    border-right: none;
    border-bottom: none;
    border-radius: 4px 0 0 0;
}

.corner.tr {
    top: 0;
    right: 0;
    border-left: none;
    border-bottom: none;
    border-radius: 0 4px 0 0;
}

.corner.bl {
    bottom: 0;
    left: 0;
    border-right: none;
    border-top: none;
    border-radius: 0 0 0 4px;
}

.corner.br {
    bottom: 0;
    right: 0;
    border-left: none;
    border-top: none;
    border-radius: 0 0 4px 0;
}

/* Scanning Indicator */
#scanning-indicator {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    color: var(--accent-secondary);
    font-weight: 600;
}

#scanning-indicator .pulse-ring {
    display: none;
}

@keyframes pulse {
    0% {
        transform: scale(0.8);
        opacity: 1;
    }

    100% {
        transform: scale(1.5);
        opacity: 0;
    }
}

/* Status Bar */
.status-bar {
    position: absolute;
    top: env(safe-area-inset-top, 12px);
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    gap: 16px;
    padding: 12px;
}

.status-item {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(10px);
    padding: 8px 12px;
    border-radius: var(--radius-md);
    font-size: 12px;
}

.status-item .icon {
    font-size: 14px;
}

.status-item .label {
    color: var(--text-muted);
}

.status-item .value {
    font-weight: 600;
    color: var(--text-secondary);
}

.status-item.connected .value {
    color: var(--success);
}

.status-item.error .value {
    color: var(--danger);
}

/* Bottom Sheet */
.bottom-sheet {
    background: var(--bg-secondary);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    padding: 12px 20px 20px;
    padding-bottom: calc(20px + env(safe-area-inset-bottom, 0));
}

.sheet-handle {
    width: 36px;
    height: 4px;
    background: var(--border-medium);
    border-radius: 2px;
    margin: 0 auto 16px;
}

/* Controls */
.controls {
    display: flex;
    gap: 12px;
}

.primary-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    color: white;
    border: none;
    padding: 16px 24px;
    border-radius: var(--radius-lg);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 20px var(--accent-glow);
}

.primary-btn:active {
    transform: scale(0.98);
}

.primary-btn.scanning {
    background: linear-gradient(135deg, var(--danger), #f87171);
    box-shadow: 0 4px 20px var(--danger-glow);
}

.secondary-btn {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-subtle);
    padding: 14px 24px;
    border-radius: var(--radius-md);
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.secondary-btn:active {
    background: var(--bg-elevated);
}

.icon-btn {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.text-btn {
    background: none;
    border: none;
    color: var(--accent-primary);
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    padding: 8px;
}

/* Detection Result */
.detection-result {
    margin-top: 16px;
    padding: 16px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
}

.detection-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    font-size: 13px;
    color: var(--text-muted);
}

.detection-plate {
    font-family: var(--font-mono);
    font-size: 28px;
    font-weight: 700;
    letter-spacing: 2px;
}

.detection-status {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.detection-status.match {
    color: var(--success);
}

/* Plate Search Styles */
.search-container {
    padding: 20px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-subtle);
}

.search-box {
    display: flex;
    gap: 12px;
}

.search-box input {
    flex: 1;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    font-size: 16px;
    color: var(--text-primary);
    font-family: var(--font-mono);
}

.search-box input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px var(--accent-glow);
}

/* Match Modal */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 9999;
    pointer-events: auto;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: var(--bg-secondary);
    border-radius: var(--radius-xl);
    padding: 28px;
    width: 100%;
    max-width: 380px;
    box-shadow: var(--shadow-lg);
    position: relative;
    z-index: 10000;
}

.match-modal {
    text-align: center;
    animation: matchPop 0.4s ease-out;
}

@keyframes matchPop {
    0% {
        transform: scale(0.8);
        opacity: 0;
    }

    50% {
        transform: scale(1.05);
    }

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

.match-icon {
    font-size: 64px;
    animation: shake 0.5s ease-in-out;
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    20%,
    60% {
        transform: translateX(-8px);
    }

    40%,
    80% {
        transform: translateX(8px);
    }
}

.match-modal h2 {
    color: var(--danger);
    font-size: 24px;
    margin: 16px 0;
    text-transform: uppercase;
    letter-spacing: 3px;
}

.match-plate {
    font-family: var(--font-mono);
    font-size: 36px;
    font-weight: 700;
    letter-spacing: 3px;
    padding: 16px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    margin: 16px 0;
}

.match-details {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 12px;
}

.match-location {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 16px;
}

.match-status {
    font-size: 14px;
    color: var(--success);
    margin-bottom: 20px;
}

/* Bottom Navigation */
.bottom-nav {
    display: flex;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-subtle);
    padding: 8px 0;
    padding-bottom: calc(8px + env(safe-area-inset-bottom, 0));
}

.nav-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    background: none;
    border: none;
    color: var(--text-muted);
    padding: 8px;
    cursor: pointer;
    transition: color 0.2s;
}

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

.nav-icon {
    font-size: 22px;
}

.nav-label {
    font-size: 11px;
    font-weight: 500;
}

/* View Header */
.view-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    padding-top: calc(16px + env(safe-area-inset-top, 0));
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-subtle);
}

.view-header h1 {
    font-size: 24px;
    font-weight: 700;
}

/* List Container */
.list-container {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    text-align: center;
    gap: 12px;
}

.empty-icon {
    font-size: 48px;
    opacity: 0.5;
}

.empty-hint {
    font-size: 13px;
    color: var(--text-muted);
}

/* Vehicle Card */
.vehicle-card {
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    padding: 16px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 16px;
}

.vehicle-plate {
    font-family: var(--font-mono);
    font-size: 20px;
    font-weight: 700;
    letter-spacing: 1px;
    background: var(--bg-elevated);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
}

.vehicle-info {
    flex: 1;
}

.vehicle-description {
    font-size: 14px;
    color: var(--text-secondary);
}

.vehicle-details {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

.vehicle-delete {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 18px;
    padding: 8px;
    cursor: pointer;
}

.vehicle-delete:hover {
    color: var(--danger);
}

/* Sighting Card */
.sighting-card {
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    overflow: hidden;
    margin-bottom: 12px;
}

.sighting-image {
    width: 100%;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    background: var(--bg-elevated);
}

.sighting-content {
    padding: 16px;
}

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

.sighting-plate {
    font-family: var(--font-mono);
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 1px;
}

.sighting-time {
    font-size: 12px;
    color: var(--text-muted);
}

.sighting-location {
    font-size: 13px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Form Styles */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-group input {
    width: 100%;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    font-size: 16px;
    color: var(--text-primary);
    font-family: var(--font-sans);
}

.form-group input:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.form-group input::placeholder {
    color: var(--text-muted);
}

.form-row {
    display: flex;
    gap: 12px;
}

.form-row .form-group {
    flex: 1;
}

.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

.form-actions button {
    flex: 1;
}

/* Modal Header */
.modal-content h2 {
    font-size: 20px;
    margin-bottom: 20px;
}

/* Utility Classes */
.hidden {
    display: none !important;
}

/* Permissions Modal */
.permissions-modal {
    text-align: center;
    animation: matchPop 0.4s ease-out;
}

.permissions-modal .primary-btn {
    width: 100%;
    min-height: 56px;
    font-size: 18px;
    cursor: pointer;
    touch-action: manipulation;
}

.permissions-icon {
    font-size: 64px;
    margin-bottom: 8px;
}

.permissions-text {
    color: var(--text-secondary);
    font-size: 15px;
    line-height: 1.5;
    margin-bottom: 24px;
}

.permissions-list {
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    padding: 16px;
    margin-bottom: 24px;
    text-align: left;
}

.permission-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    font-size: 14px;
    color: var(--text-secondary);
}

.permission-item:not(:last-child) {
    border-bottom: 1px solid var(--border-subtle);
}

.permission-icon {
    font-size: 24px;
}