:root {
    --primary: #8b5cf6;
    --secondary: #ec4899;
    --accent: #f43f5e;
    --orange: #f97316;
    --bg-dark: #000000;
    --sidebar-bg: rgba(18, 18, 18, 0.4);
    --card-bg: rgba(25, 25, 25, 0.5);
    --text-main: #ffffff;
    --text-dim: rgba(255, 255, 255, 0.6);
    --glass-border: rgba(255, 255, 255, 0.08);
    --purple-main: #8a4fff;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
}

body {
    background-color: #000;
    color: var(--text-main);
    overflow-x: hidden;
    min-height: 100vh;
    width: 100%;
    max-width: 100vw;
}

/* Background - Shared with Landing */
.liquid-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -1;
    overflow: hidden;
    background: #000;
}

.liquid-bg {
    position: absolute;
    width: 200%;
    height: 200%;
    top: -50%;
    left: -50%;
    background: radial-gradient(circle at 20% 30%, var(--primary) 0%, transparent 40%),
        radial-gradient(circle at 80% 20%, var(--secondary) 0%, transparent 45%),
        radial-gradient(circle at 40% 80%, var(--accent) 0%, transparent 50%),
        radial-gradient(circle at 90% 90%, var(--orange) 0%, transparent 40%);
    filter: blur(100px);
    animation: liquidMove 40s linear infinite;
    opacity: 0.9;
}

.grain-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0.18;
    pointer-events: none;
    z-index: 1000;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
}

@keyframes liquidMove {
    0% {
        transform: translate(0, 0) rotate(0deg);
    }

    33% {
        transform: translate(5%, 5%) rotate(5deg);
    }

    66% {
        transform: translate(-5%, 8%) rotate(-5deg);
    }

    100% {
        transform: translate(0, 0) rotate(0deg);
    }
}

/* Landing Page Styles */
#canvas-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
}

.hero-content {
    position: relative;
    z-index: 10;
    height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    color: #fff;
    padding: 0 1rem;
}

.made-by {
    font-size: 0.8rem;
    /* default */
    letter-spacing: 0.5em;
    /* default */
    opacity: 0.6;
    text-transform: uppercase;
}

.made-by.top {
    margin-bottom: 2rem;
}

.made-by.bottom {
    margin-top: 5rem;
    font-size: 0.6rem;
    letter-spacing: 0.8em;
    opacity: 0.4;
}

.landing-title {
    font-size: clamp(3rem, 15vw, 10rem);
    line-height: 0.85;
    margin-bottom: 2rem;
    font-weight: 800;
    background: linear-gradient(to bottom, #fff 50%, rgba(255, 255, 255, 0.2));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.landing-subtitle {
    max-width: 600px;
    line-height: 1.6;
    opacity: 0.7;
    margin-bottom: 3rem;
    /* Adjusted for spacing */
}

.enter-btn {
    /* margin-top: 3rem; -- handled by subtitle margin */
    padding: 1.2rem 3rem;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    font-weight: 700;
    font-size: 1.1rem;
    border-radius: 100px;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    text-decoration: none;
    letter-spacing: 0.1em;
    display: inline-block;
}

.enter-btn:hover {
    background: #fff;
    color: #000;
    transform: scale(1.05);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

/* Page Layout */
.dashboard-container {
    display: flex;
    width: 100vw;
    height: 100vh;
    position: relative;
    z-index: 1;
}

/* Sidebar - Glass Styling */
.sidebar {
    width: 80px;
    background: var(--sidebar-bg);
    backdrop-filter: blur(20px);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 2rem 0;
    gap: 2rem;
    border-right: 1px solid var(--glass-border);
    transition: width 0.3s ease;
}

.nav-icon {
    font-size: 1.4rem;
    color: var(--text-dim);
    cursor: pointer;
    transition: all 0.3s ease;
    padding: 12px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}

.nav-icon:hover,
.nav-icon.active {
    color: #fff;
    background: var(--purple-main);
    box-shadow: 0 0 20px rgba(138, 79, 255, 0.4);
}

/* Main Area */
.main-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 2rem;
    overflow-y: auto;
}

.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    gap: 2rem;
}

.search-bar {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    padding: 0.8rem 1.5rem 0.8rem 3rem;
    border-radius: 14px;
    color: #fff;
    width: 300px;
    outline: none;
}

.add-btn {
    background: var(--purple-main);
    color: #fff;
    border: none;
    padding: 0.8rem 1.8rem;
    border-radius: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.2s ease;
}

/* Dashboard Grid - Responsive */
.dashboard-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.3fr) minmax(0, 0.7fr);
    gap: 1.5rem;
    width: 100%;
    max-width: 100%;
}

.card {
    background: var(--card-bg);
    backdrop-filter: blur(30px) saturate(160%);
    border: 1px solid var(--glass-border);
    border-radius: 32px;
    padding: 1.8rem;
    height: fit-content;
}

/* Video Feed */
.feed-card {
    grid-column: span 1;
    background: #000;
    border-radius: 32px;
    position: relative;
    overflow: hidden;
    min-height: 450px;
    max-height: 70vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* When overlay is visible, allow content to fit */
.feed-card.overlay-active {
    overflow: visible;
    aspect-ratio: unset;
    height: auto;
}

/* When video is playing, maintain aspect ratio */
.feed-card.video-active {
    aspect-ratio: 16/9;
    overflow: hidden;
}

.feed-card img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    position: relative;
    z-index: 1;
}

#drop-zone-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: rgba(0, 0, 0, 0.6);
    text-align: center;
    padding: 2.5rem 2rem;
    z-index: 10;
    min-height: 100%;
}

#drop-zone-overlay .mode-btn-wrap {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
    z-index: 10;
    position: relative;
}

.live-badge {
    position: absolute;
    top: 20px;
    left: 20px;
    z-index: 20;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.3;
    }
}

/* Mobile Optimizations */
@media (max-width: 1024px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .sidebar {
        width: 70px;
    }

    .feed-card {
        min-height: 400px;
        max-height: 60vh;
    }

    .feed-card.overlay-active {
        min-height: 450px;
    }
}

@media (max-width: 768px) {
    .dashboard-container {
        flex-direction: column-reverse;
        height: auto;
        min-height: 100vh;
    }

    .sidebar {
        width: 100%;
        height: 64px;
        flex-direction: row;
        justify-content: space-around;
        padding: 0 1rem;
        border-right: none;
        border-top: 1px solid var(--glass-border);
        position: fixed;
        bottom: 0;
        left: 0;
        z-index: 100;
        background: rgba(10, 10, 10, 0.85);
        backdrop-filter: blur(20px);
    }

    .nav-icon {
        font-size: 1.1rem;
        padding: 10px;
    }

    .main-wrapper {
        padding: 1rem;
        padding-bottom: 80px;
        overflow-x: hidden;
        width: 100%;
    }

    .dashboard-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
        margin-bottom: 1rem;
    }

    .dashboard-header h2 {
        font-size: 1.3rem;
    }

    .system-stats {
        display: flex;
        gap: 0.75rem;
        flex-wrap: wrap;
    }

    .search-bar {
        width: 100%;
    }

    .device-grid {
        grid-template-columns: 1fr;
    }

    .device-tabs {
        overflow-x: auto;
        padding-bottom: 15px;
    }

    .dashboard-header .header-actions {
        width: 100%;
        justify-content: space-between;
    }

    /* Feed Card - Mobile Fix */
    .feed-card {
        min-height: 350px !important;
        max-height: 50vh !important;
        height: auto !important;
        border-radius: 20px;
        width: 100%;
    }

    .feed-card.overlay-active {
        min-height: 400px !important;
        height: auto !important;
    }

    .feed-card.video-active {
        aspect-ratio: unset !important;
    }

    .feed-card #processed-stream {
        object-fit: contain !important;
        width: 100% !important;
        height: auto !important;
        max-height: 50vh !important;
        position: relative !important;
        min-height: 200px !important;
    }

    .feed-card .live-badge {
        top: 10px !important;
        left: 10px !important;
        font-size: 0.75rem !important;
        padding: 6px 12px !important;
    }

    #drop-zone-overlay {
        padding: 1.5rem 1rem !important;
    }

    /* Drop zone buttons on mobile */
    #drop-zone-overlay {
        padding: 1rem !important;
    }

    #drop-zone-overlay h3 {
        font-size: 1rem;
    }

    #drop-zone-overlay .mode-btn-wrap {
        flex-direction: column;
        gap: 0.6rem;
        width: 100%;
        max-width: 260px;
    }

    #drop-zone-overlay .mode-btn-wrap button {
        width: 100%;
    }

    /* Results Panel */
    #results-panel {
        max-height: 260px !important;
    }

    .log-row-title {
        font-size: 0.8rem !important;
    }

    .log-row-meta {
        font-size: 0.72rem !important;
    }

    /* Evidence Cache - 3 cols on mobile */
    .mini-feed-gallery {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 8px !important;
    }

    /* Cards */
    .card {
        border-radius: 20px;
        padding: 1.2rem;
        width: 100%;
        overflow: hidden;
    }

    .side-panel-wrapper {
        display: flex;
        flex-direction: column;
        gap: 1rem;
        width: 100%;
    }

    .dashboard-grid {
        width: 100%;
        overflow-x: hidden;
    }
}

/* Extra Small Mobile (Portrait Phones) */
@media (max-width: 480px) {
    .feed-card {
        min-height: 180px !important;
        max-height: 45vh !important;
    }

    .feed-card #processed-stream {
        min-height: 180px !important;
        max-height: 45vh !important;
    }

    .dashboard-header h2 {
        font-size: 1.1rem !important;
    }

    .system-stats {
        font-size: 0.75rem;
    }

    .stat-item {
        font-size: 0.7rem;
    }
}

/* === JSON Syntax Highlighting === */
.json-viewer {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.72rem;
    line-height: 1.7;
    white-space: pre-wrap;
    word-break: break-word;
    overflow-wrap: break-word;
}

.json-key {
    color: #c084fc;
}

.json-str {
    color: #86efac;
}

.json-num {
    color: #67e8f9;
}

.json-bool {
    color: #fbbf24;
}

.json-null {
    color: #f87171;
}

.json-url {
    color: #38bdf8;
    text-decoration: underline;
    cursor: pointer;
}

/* JSON Table View */
.json-table {
    width: 100%;
    border-collapse: collapse;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
}

.json-table tr {
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.json-table td {
    padding: 0.6rem 0.8rem;
    vertical-align: top;
    word-break: break-word;
}

.json-table td:first-child {
    color: #c084fc;
    font-weight: 600;
    width: 35%;
    min-width: 100px;
}

.json-table td:last-child {
    color: #86efac;
    width: 65%;
}

/* === Modal Mobile === */
@media (max-width: 768px) {
    #detail-modal>div {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        height: 100vh !important;
        border-radius: 0 !important;
        padding: 1.2rem !important;
        overflow-y: auto;
    }

    .modal-inner-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
        overflow: visible !important;
    }

    .modal-main-img-wrap {
        max-height: 220px;
        min-height: 160px;
    }

    #modal-thumb {
        max-height: 220px;
        width: 100%;
    }

    .modal-plate-box {
        padding: 0.8rem !important;
    }

    #modal-plate-text {
        font-size: 1.1rem !important;
    }

    .modal-json-box {
        max-height: none !important;
        overflow-y: auto;
    }

    .json-viewer {
        font-size: 0.68rem !important;
    }

    .json-table {
        font-size: 0.7rem !important;
    }

    .json-table td {
        padding: 0.5rem 0.6rem !important;
    }

    .json-table td:first-child {
        width: 40% !important;
    }
}

/* === Log Row Styles === */
.log-row {
    background: rgba(255, 255, 255, 0.05);
    padding: 12px 14px;
    border-radius: 10px;
    border-left: 4px solid #ef4444;
    cursor: pointer;
    transition: background 0.2s;
    position: relative;
}

.log-row:hover {
    background: rgba(255, 255, 255, 0.1);
}

.log-row-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.log-row-title {
    font-weight: 700;
    font-size: 0.85rem;
    color: #fff;
}

.log-row-time {
    font-size: 0.7rem;
    opacity: 0.55;
    white-space: nowrap;
}

.log-row-meta {
    margin-top: 5px;
    font-size: 0.78rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.log-row-id {
    opacity: 0.6;
    font-family: 'JetBrains Mono', monospace;
}

.log-row-plate {
    color: #facc15;
    font-family: 'JetBrains Mono', monospace;
    font-weight: 700;
    letter-spacing: 1px;
}

/* Switches & Controls */
.switch {
    width: 48px;
    height: 26px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 100px;
    position: relative;
    cursor: pointer;
    transition: background 0.3s ease;
}

.switch.on {
    background: var(--purple-main);
}

.switch::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    background: white;
    border-radius: 50%;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.switch.on::after {
    left: 25px;
}

/* Detections Gallery */
.mini-feed-gallery {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-top: 1.5rem;
}

.mini-thumb {
    aspect-ratio: 1/1;
    background: #1a1a1a;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--glass-border);
    cursor: pointer;
    transition: transform 0.2s ease;
}

.mini-thumb:hover {
    transform: scale(1.05);
}

.mini-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}