﻿/* ── Variables ─────────────────────────────────────────────────────────── */
:root {
    --bg0: #0d0e12;
    --bg1: #13151c;
    --bg2: #1a1d27;
    --bg3: #21253a;
    --border: rgba(80, 110, 180, 0.18);
    --accent: #44aaff;
    --accent2: #6af5d0;
    --red: #ff4f4f;
    --text0: #eef0f8;
    --text1: #a8b4cc;
    --text2: #5a6a8a;
    --mono: 'Space Mono', monospace;
    --sans: 'DM Sans', sans-serif;
    --radius: 10px;
    --shadow: 0 8px 32px rgba(0,0,0,0.45);
}

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

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

body {
    font-family: var(--sans);
    background: var(--bg0);
    color: var(--text0);
    font-size: 14px;
    line-height: 1.5;
}

.screen {
    position: fixed;
    inset: 0;
    display: none;
}

    .screen.active {
        display: flex;
    }

.hidden {
    display: none !important;
}

/* ── Login ─────────────────────────────────────────────────────────────── */
#loginScreen {
    align-items: center;
    justify-content: center;
    background: var(--bg0);
}

.login-bg {
    position: absolute;
    inset: 0;
    overflow: hidden;
    background: radial-gradient(ellipse 80% 60% at 50% 0%, rgba(30,80,160,0.22) 0%, transparent 70%);
}

.grid-overlay {
    position: absolute;
    inset: 0;
    background-image: linear-gradient(rgba(68,170,255,0.04) 1px, transparent 1px), linear-gradient(90deg, rgba(68,170,255,0.04) 1px, transparent 1px);
    background-size: 40px 40px;
    animation: gridDrift 30s linear infinite;
}

@keyframes gridDrift {
    from {
        background-position: 0 0;
    }

    to {
        background-position: 40px 40px;
    }
}

.scan-line {
    position: absolute;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, rgba(68,170,255,0.3), transparent);
    animation: scan 6s ease-in-out infinite;
}

@keyframes scan {
    0%,100% {
        top: 0;
        opacity: 0;
    }

    10% {
        opacity: 1;
    }

    90% {
        opacity: 1;
    }

    100% {
        top: 100%;
    }
}

.login-card {
    position: relative;
    z-index: 10;
    background: var(--bg1);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 44px 40px;
    width: 400px;
    box-shadow: var(--shadow), 0 0 60px rgba(68,170,255,0.07);
    animation: cardIn 0.5s cubic-bezier(0.2,0.8,0.3,1) both;
}

@keyframes cardIn {
    from {
        opacity: 0;
        transform: translateY(24px) scale(0.97);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

.login-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 28px;
}

.logo-text {
    font-family: var(--mono);
    font-size: 18px;
    color: var(--accent);
    letter-spacing: 0.04em;
}

.login-title {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 6px;
}

.login-subtitle {
    font-size: 13px;
    color: var(--text2);
    margin-bottom: 28px;
}

.field-group {
    margin-bottom: 16px;
}

    .field-group label {
        display: block;
        font-size: 12px;
        font-weight: 500;
        color: var(--text1);
        text-transform: uppercase;
        letter-spacing: 0.08em;
        margin-bottom: 6px;
    }

    .field-group input {
        width: 100%;
        padding: 10px 14px;
        background: var(--bg2);
        border: 1px solid var(--border);
        border-radius: 7px;
        color: var(--text0);
        font-family: var(--sans);
        font-size: 14px;
        outline: none;
        transition: border-color 0.2s;
    }

        .field-group input:focus {
            border-color: rgba(68,170,255,0.5);
            box-shadow: 0 0 0 3px rgba(68,170,255,0.1);
        }

.btn-primary {
    width: 100%;
    margin-top: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    background: linear-gradient(135deg, #2a7adb, #1a5cb0);
    border: none;
    border-radius: 8px;
    color: #fff;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

    .btn-primary:hover {
        background: linear-gradient(135deg, #3a8aeb, #2a6cc0);
        transform: translateY(-1px);
    }

.login-hint {
    margin-top: 12px;
    text-align: center;
    font-size: 12px;
    color: var(--text2);
    font-family: var(--mono);
}

.error-banner {
    background: rgba(255,60,60,0.1);
    border: 1px solid rgba(255,60,60,0.3);
    border-radius: 7px;
    padding: 10px 14px;
    color: #ff8080;
    font-size: 13px;
    margin-bottom: 16px;
}

/* ── Topbar ─────────────────────────────────────────────────────────────── */
#dashboardScreen {
    flex-direction: column;
}

.topbar {
    height: 54px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    background: var(--bg1);
    border-bottom: 1px solid var(--border);
    z-index: 100;
    gap: 16px;
}

.topbar-left, .topbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 160px;
}

.topbar-right {
    justify-content: flex-end;
}

.topbar-center {
    display: flex;
    align-items: center;
    gap: 14px;
    flex: 1;
    justify-content: center;
}

.topbar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: var(--mono);
    font-size: 14px;
    color: var(--accent);
    font-weight: 700;
}

.status-pill {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 4px 12px;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 100px;
    font-size: 12px;
    font-family: var(--mono);
    color: var(--text1);
    white-space: nowrap;
}

.dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    display: inline-block;
}

    .dot.red {
        background: var(--red);
        box-shadow: 0 0 6px var(--red);
    }

    .dot.green {
        background: #44ff88;
        box-shadow: 0 0 6px #44ff88;
        animation: pulseGreen 2s ease-in-out infinite;
    }

    .dot.yellow {
        background: #ffcc44;
        box-shadow: 0 0 6px #ffcc44;
    }

@keyframes pulseGreen {
    0%,100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

.username-chip {
    font-size: 12px;
    font-family: var(--mono);
    padding: 4px 10px;
    background: rgba(68,170,255,0.1);
    border: 1px solid rgba(68,170,255,0.2);
    border-radius: 4px;
    color: var(--accent);
}

.btn-icon {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 7px;
    padding: 6px;
    cursor: pointer;
    color: var(--text1);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

    .btn-icon:hover {
        border-color: rgba(68,170,255,0.4);
        color: var(--accent);
    }

/* ── Layout switcher ────────────────────────────────────────────────────── */
.layout-switcher {
    display: flex;
    align-items: center;
    gap: 4px;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 3px;
}

.layout-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    background: transparent;
    border: none;
    border-radius: 5px;
    color: var(--text2);
    font-size: 11px;
    font-family: var(--mono);
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}

    .layout-btn:hover {
        color: var(--text0);
        background: var(--bg3);
    }

    .layout-btn.active {
        background: rgba(68,170,255,0.15);
        color: var(--accent);
    }

/* ── Sidebar ────────────────────────────────────────────────────────────── */
.dash-body {
    flex: 1;
    display: flex;
    overflow: hidden;
}

.sidebar {
    width: 210px;
    flex-shrink: 0;
    background: var(--bg1);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-section {
    padding: 14px;
    border-bottom: 1px solid var(--border);
}

.sidebar-title {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.12em;
    color: var(--text2);
    text-transform: uppercase;
    margin-bottom: 10px;
    font-family: var(--mono);
}

.sidebar-hint {
    padding: 8px 14px;
    font-size: 11px;
    color: var(--text2);
    font-style: italic;
    line-height: 1.4;
}

.pc-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.pc-empty {
    font-size: 12px;
    color: var(--text2);
    padding: 8px 0;
    text-align: center;
    font-style: italic;
}

.pc-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 7px;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.15s;
    font-size: 13px;
    color: var(--text1);
    background: transparent;
    width: 100%;
    text-align: left;
}

    .pc-item:hover {
        background: var(--bg2);
        border-color: var(--border);
        color: var(--text0);
    }

    .pc-item.active {
        background: rgba(68,170,255,0.12);
        border-color: rgba(68,170,255,0.35);
        color: var(--accent);
    }

    .pc-item .pc-icon {
        width: 8px;
        height: 8px;
        border-radius: 50%;
        flex-shrink: 0;
    }

    .pc-item .pc-name {
        flex: 1;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        font-family: var(--mono);
        font-size: 12px;
    }

.sidebar-actions {
    margin-top: auto;
    padding: 14px;
}

.btn-secondary {
    display: flex;
    align-items: center;
    gap: 7px;
    width: 100%;
    padding: 9px 12px;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 7px;
    color: var(--text1);
    font-size: 12px;
    cursor: pointer;
    font-family: var(--sans);
    transition: all 0.15s;
}

    .btn-secondary:hover {
        border-color: rgba(68,170,255,0.3);
        color: var(--text0);
    }

/* ── Viewer area ─────────────────────────────────────────────────────────── */
.viewer-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    background: var(--bg0);
}

.viewer-placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 40px;
    animation: fadeIn 0.4s ease;
}

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

    to {
        opacity: 1;
        transform: none;
    }
}

.placeholder-icon {
    margin-bottom: 20px;
    opacity: 0.7;
}

.placeholder-title {
    font-size: 18px;
    font-weight: 500;
    color: var(--text1);
    margin-bottom: 8px;
}

.placeholder-sub {
    font-size: 13px;
    color: var(--text2);
    max-width: 300px;
}

/* ── Tile grid ───────────────────────────────────────────────────────────── */
.tile-grid {
    display: grid;
    width: 100%;
    height: 100%;
    gap: 3px;
    background: #090a0e;
    grid-template-columns: 1fr;
    overflow: hidden;
}

    .tile-grid.visible {
        display: grid;
    }

.tile {
    display: flex;
    flex-direction: column;
    background: var(--bg1);
    border: 1px solid var(--border);
    overflow: hidden;
    min-height: 0;
}

    .tile:fullscreen {
        border: none;
    }

.tile-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 10px;
    background: var(--bg2);
    border-bottom: 1px solid var(--border);
    height: 36px;
    flex-shrink: 0;
}

.tile-pcname {
    font-family: var(--mono);
    font-size: 12px;
    color: var(--accent);
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.tile-badge {
    font-family: var(--mono);
    font-size: 10px;
    padding: 2px 7px;
    border-radius: 4px;
    white-space: nowrap;
}

    .tile-badge.live {
        background: rgba(68,255,136,0.1);
        color: #44ff88;
        border: 1px solid rgba(68,255,136,0.3);
        animation: pulseLive 2s ease-in-out infinite;
    }

    .tile-badge.fps {
        background: rgba(68,170,255,0.1);
        color: var(--accent);
        border: 1px solid rgba(68,170,255,0.2);
    }

@keyframes pulseLive {
    0%,100% {
        opacity: 1;
    }

    50% {
        opacity: 0.6;
    }
}

.tile-controls {
    display: flex;
    gap: 4px;
}

.btn-toolbar {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    width: 26px;
    height: 26px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 5px;
    cursor: pointer;
    color: var(--text1);
    transition: all 0.15s;
}

    .btn-toolbar:hover {
        border-color: rgba(68,170,255,0.4);
        color: var(--accent);
    }

    .btn-toolbar.btn-disconnect:hover {
        border-color: rgba(255,80,80,0.4);
        color: var(--red);
    }

.tile-canvas-wrap {
    flex: 1;
    overflow: auto;
    display: flex;
    align-items: flex-start;
    justify-content: flex-start;
    position: relative;
    outline: none;
    min-height: 0;
}

    .tile-canvas-wrap:focus {
        box-shadow: inset 0 0 0 2px rgba(68,170,255,0.4);
    }

    .tile-canvas-wrap canvas {
        display: block;
        max-width: 100%;
    }
