/* VPSRox — browser VNC remote desktop session */

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

body.page-vnc {
    --rvnc-header-h: 56px;
    --rvnc-log-w: 320px;
    --rvnc-canvas: #071410;
    --rvnc-ok: var(--accent-green);
    --rvnc-warn: #f59e0b;
    --rvnc-danger: #ef4444;

    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
    background: var(--rvnc-canvas);
    color: var(--text-light-secondary);
    font-family: var(--font-family);
    -webkit-font-smoothing: antialiased;
}

body.page-vnc::before,
body.page-vnc::after {
    display: none;
}

/* ── Top session header ── */

.rvnc-header {
    flex-shrink: 0;
    height: var(--rvnc-header-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 0 18px;
    background: linear-gradient(90deg, #071410 0%, var(--bg-card) 52%, #0c2419 100%);
    border-bottom: 1px solid rgba(42, 211, 135, 0.14);
    box-shadow: 0 8px 32px rgba(7, 20, 16, 0.28);
    z-index: 40;
}

.rvnc-header-start,
.rvnc-header-end {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.rvnc-header-center {
    flex: 1;
    display: flex;
    justify-content: center;
    min-width: 0;
}

.rvnc-brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    transition: opacity 0.2s;
}

.rvnc-brand:hover {
    opacity: 0.88;
}

.rvnc-brand-mark {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    background: rgba(42, 211, 135, 0.16);
    border: 1px solid rgba(42, 211, 135, 0.28);
    color: var(--accent-green);
    font-size: 15px;
    font-weight: 800;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.rvnc-brand-text {
    font-size: 17px;
    font-weight: 800;
    letter-spacing: -0.03em;
    color: var(--text-light);
}

.rvnc-header-divider {
    width: 1px;
    height: 24px;
    background: rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
}

.rvnc-session-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-radius: 9999px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
    font-size: 13px;
}

.rvnc-session-label {
    color: var(--text-light-secondary);
    font-weight: 500;
}

.rvnc-session-id {
    color: var(--text-light);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.rvnc-link-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    border-radius: 9999px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    font-size: 13px;
    font-weight: 600;
    color: var(--text-light-secondary);
}

.rvnc-link-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(153, 178, 164, 0.45);
    flex-shrink: 0;
}

.rvnc-link-pill.is-busy .rvnc-link-dot {
    width: 12px;
    height: 12px;
    background: transparent;
    border: 2px solid var(--accent-green);
    border-top-color: transparent;
    animation: rvnc-spin 0.75s linear infinite;
}

.rvnc-link-pill.is-live {
    color: var(--rvnc-ok);
    border-color: rgba(42, 211, 135, 0.24);
    background: rgba(42, 211, 135, 0.08);
}

.rvnc-link-pill.is-live .rvnc-link-dot {
    background: var(--rvnc-ok);
    box-shadow: 0 0 10px rgba(42, 211, 135, 0.45);
}

.rvnc-link-pill.is-fault {
    color: var(--rvnc-danger);
    border-color: rgba(239, 68, 68, 0.24);
    background: rgba(239, 68, 68, 0.08);
}

.rvnc-link-pill.is-fault .rvnc-link-dot {
    background: var(--rvnc-danger);
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.4);
}

.rvnc-tool {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 36px;
    padding: 0 14px;
    border-radius: 9999px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-light);
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s, transform 0.12s;
    white-space: nowrap;
}

.rvnc-tool:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.16);
}

.rvnc-tool:active {
    transform: scale(0.98);
}

.rvnc-tool--ghost {
    color: var(--text-light-secondary);
}

.rvnc-tool--accent {
    background: var(--accent-green);
    border-color: transparent;
    color: #071410;
}

.rvnc-tool--accent:hover {
    background: var(--accent-mint);
}

.rvnc-tool--danger {
    color: #fecaca;
    border-color: rgba(239, 68, 68, 0.28);
    background: rgba(239, 68, 68, 0.1);
}

.rvnc-tool--danger:hover {
    background: rgba(239, 68, 68, 0.16);
    border-color: rgba(239, 68, 68, 0.4);
}

/* ── Shell: viewport + side log panel ── */

.rvnc-shell {
    flex: 1;
    display: flex;
    min-height: 0;
    position: relative;
}

.rvnc-stage {
    flex: 1;
    position: relative;
    min-width: 0;
    background: var(--rvnc-canvas);
    overflow: hidden;
}

#rfb-screen {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

#rfb-screen canvas {
    max-width: 100%;
    max-height: 100%;
}

/* ── State overlays ── */

.rvnc-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(7, 20, 16, 0.82);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.24s ease, visibility 0.24s;
    z-index: 10;
    pointer-events: none;
}

.rvnc-overlay.is-visible {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.rvnc-overlay-card {
    width: min(420px, 100%);
    padding: 32px 28px;
    border-radius: 20px;
    background: rgba(15, 42, 29, 0.96);
    border: 1px solid rgba(42, 211, 135, 0.16);
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.45);
    text-align: center;
    animation: rvnc-rise 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.rvnc-overlay-card--fault {
    border-color: rgba(239, 68, 68, 0.28);
}

.rvnc-overlay-card--idle {
    border-color: rgba(255, 255, 255, 0.12);
}

.rvnc-overlay-spinner {
    width: 44px;
    height: 44px;
    margin: 0 auto 20px;
    border: 3px solid rgba(42, 211, 135, 0.18);
    border-top-color: var(--accent-green);
    border-radius: 50%;
    animation: rvnc-spin 0.8s linear infinite;
}

.rvnc-overlay-icon {
    width: 52px;
    height: 52px;
    margin: 0 auto 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.rvnc-overlay-icon--fault {
    background: rgba(239, 68, 68, 0.12);
    color: var(--rvnc-danger);
}

.rvnc-overlay-icon--idle {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-light-secondary);
}

.rvnc-overlay-title {
    font-size: 18px;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--text-light);
    margin-bottom: 10px;
}

.rvnc-overlay-desc {
    font-size: 15px;
    line-height: 1.65;
    color: var(--text-light-secondary);
    margin-bottom: 22px;
}

.rvnc-overlay-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 42px;
    padding: 0 22px;
    border: none;
    border-radius: 9999px;
    background: var(--accent-green);
    color: #071410;
    font-size: 14px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.2s, transform 0.12s;
}

.rvnc-overlay-action:hover {
    background: var(--accent-mint);
}

.rvnc-overlay-action:active {
    transform: scale(0.98);
}

/* ── Right-side diagnostics panel ── */

#diag-drawer {
    flex-shrink: 0;
    width: 0;
    display: flex;
    flex-direction: column;
    background: rgba(7, 20, 16, 0.98);
    border-left: 1px solid rgba(42, 211, 135, 0.12);
    overflow: hidden;
    transition: width 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 20;
}

#diag-drawer.is-expanded {
    width: var(--rvnc-log-w);
}

.rvnc-log-head {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-light-secondary);
}

.rvnc-log-head svg {
    color: var(--accent-green);
}

#diag-log {
    flex: 1;
    margin: 0;
    padding: 14px 16px;
    overflow: auto;
    font-family: 'SF Mono', 'Monaco', 'Menlo', 'Consolas', monospace;
    font-size: 12px;
    line-height: 1.55;
    color: var(--text-light-secondary);
    background: var(--rvnc-canvas);
    white-space: pre-wrap;
    word-break: break-all;
}

/* ── Animations ── */

@keyframes rvnc-spin {
    to { transform: rotate(360deg); }
}

@keyframes rvnc-rise {
    from { opacity: 0; transform: translateY(14px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ── Responsive ── */

@media (max-width: 900px) {
    body.page-vnc {
        --rvnc-log-w: min(280px, 88vw);
    }

    .rvnc-header {
        flex-wrap: wrap;
        height: auto;
        min-height: var(--rvnc-header-h);
        padding: 10px 14px;
    }

    .rvnc-header-start {
        order: 1;
        flex: 0 1 auto;
        min-width: 0;
    }

    .rvnc-header-center {
        order: 2;
        flex: 1 1 auto;
        justify-content: flex-end;
        padding-top: 0;
        min-width: 0;
    }

    .rvnc-header-end {
        order: 3;
        flex-basis: 100%;
        display: flex;
        gap: 8px;
        padding-top: 8px;
        min-width: 0;
    }

    .rvnc-tool {
        flex: 1;
        min-width: 0;
        padding: 0 12px;
        font-size: 12px;
        gap: 5px;
        width: auto;
        box-sizing: border-box;
        overflow: hidden;
    }

    .rvnc-tool-label,
    #diag-toggle-label {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        min-width: 0;
    }

    .rvnc-tool svg {
        flex-shrink: 0;
    }

    .rvnc-link-pill {
        max-width: 100%;
    }

    .rvnc-status-text {
        max-width: 8em;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
}

@media (max-width: 640px) {
    .rvnc-brand-text,
    .rvnc-session-label {
        display: none;
    }

    .rvnc-tool {
        padding: 0 10px;
    }

    #diag-drawer.is-expanded {
        position: absolute;
        top: 0;
        right: 0;
        bottom: 0;
        width: min(100%, 320px);
        box-shadow: -12px 0 40px rgba(0, 0, 0, 0.45);
    }

    .rvnc-status-text {
        max-width: 6em;
    }
}
