/* ═══════════════════════════════════════════════════════════════════════════
   Remote Desktop Console — Styles
   ═══════════════════════════════════════════════════════════════════════════ */

:root {
    --bg-primary: #0f1117;
    --bg-secondary: #1a1d27;
    --bg-tertiary: #242836;
    --bg-hover: #2d3245;
    --bg-active: #363b50;
    --border: #2d3245;
    --border-light: #3d4460;
    --text-primary: #e4e6ef;
    --text-secondary: #9ba1b8;
    --text-muted: #6b7194;
    --accent: #6366f1;
    --accent-hover: #818cf8;
    --accent-dim: rgba(99, 102, 241, 0.15);
    --green: #22c55e;
    --green-dim: rgba(34, 197, 94, 0.15);
    --red: #ef4444;
    --red-dim: rgba(239, 68, 68, 0.15);
    --blue: #3b82f6;
    --blue-dim: rgba(59, 130, 246, 0.15);
    --yellow: #fbbf24;
    --yellow-dim: rgba(251, 191, 36, 0.15);
    --radius: 8px;
    --radius-sm: 4px;
    --radius-lg: 12px;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.5);
    --transition: 0.2s ease;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --sidebar-width: 280px;
    --topbar-height: 52px;
    --toolbar-height: 44px;
}

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

body {
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    overflow: hidden;
    height: 100vh;
    width: 100vw;
}

/* ─── Utility ──────────────────────────────────────────────────────────────── */

.text-green { color: var(--green); }
.text-blue { color: var(--blue); }
.text-red { color: var(--red); }
.text-yellow { color: var(--yellow); }
.text-muted { color: var(--text-muted); }

/* ─── Buttons ──────────────────────────────────────────────────────────────── */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius);
    font-family: var(--font);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    outline: none;
}

.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-primary {
    background: var(--accent);
    color: white;
}
.btn-primary:hover { background: var(--accent-hover); }

.btn-danger {
    background: var(--red);
    color: white;
}
.btn-danger:hover { background: #dc2626; }

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    padding: 8px 12px;
}
.btn-ghost:hover { background: var(--bg-hover); color: var(--text-primary); }

.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-xs { padding: 4px 8px; font-size: 12px; }
.btn-block { width: 100%; justify-content: center; }

/* ─── Screens ──────────────────────────────────────────────────────────────── */

.screen {
    display: none;
    width: 100vw;
    height: 100vh;
}
.screen.active { display: flex; }

/* ─── Login Screen ─────────────────────────────────────────────────────────── */

#login-screen {
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
    background-image:
        radial-gradient(ellipse at 20% 50%, rgba(99, 102, 241, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(59, 130, 246, 0.06) 0%, transparent 50%);
}

.login-container {
    width: 400px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 40px;
    box-shadow: var(--shadow-lg);
}

.login-logo {
    text-align: center;
    margin-bottom: 32px;
}

.login-logo i {
    font-size: 48px;
    color: var(--accent);
    margin-bottom: 16px;
}

.login-logo h1 {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
}

.login-logo p {
    color: var(--text-muted);
    font-size: 14px;
    margin-top: 4px;
}

.form-group {
    margin-bottom: 20px;
}

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

.form-group input[type="text"],
.form-group input[type="password"],
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 14px;
    outline: none;
    transition: border-color var(--transition);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--accent);
}

.form-group textarea {
    resize: vertical;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 13px;
}

.error-msg {
    color: var(--red);
    font-size: 13px;
    margin-top: 12px;
    text-align: center;
    min-height: 20px;
}

/* ─── Dashboard Layout ─────────────────────────────────────────────────────── */

#dashboard-screen {
    flex-direction: column;
}

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

.topbar-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.brand-icon {
    font-size: 20px;
    color: var(--accent);
}

.brand-name {
    font-size: 16px;
    font-weight: 600;
}

.topbar-center {
    display: flex;
    align-items: center;
}

.status-bar {
    display: flex;
    gap: 20px;
}

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

.status-item i { font-size: 8px; }

.topbar-right {
    display: flex;
    align-items: center;
    gap: 4px;
}

.main-layout {
    display: flex;
    flex: 1;
    overflow: hidden;
    position: relative;
}

/* ─── Sidebar ──────────────────────────────────────────────────────────────── */

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

.sidebar.collapsed {
    width: 0;
    border-right: none;
}

.sidebar-toggle-btn {
    position: absolute;
    left: var(--sidebar-width);
    top: 50%;
    transform: translateY(-50%);
    z-index: 150;
    width: 24px;
    height: 48px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-left: none;
    border-radius: 0 var(--radius) var(--radius) 0;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: left var(--transition), background var(--transition);
    padding: 0;
    font-size: 12px;
}

.sidebar-toggle-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.sidebar.collapsed ~ .sidebar-toggle-btn {
    left: 0;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    border-bottom: 1px solid var(--border);
}

.sidebar-header h3 {
    font-size: 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.sidebar-header h3 i {
    color: var(--accent);
}

.agent-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.agent-list::-webkit-scrollbar { width: 4px; }
.agent-list::-webkit-scrollbar-track { background: transparent; }
.agent-list::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 2px; }

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}

.empty-state i {
    font-size: 40px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state p {
    font-size: 14px;
    margin-bottom: 4px;
}

.empty-state small {
    font-size: 12px;
}

/* ─── Agent Card ───────────────────────────────────────────────────────────── */

.agent-card {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all var(--transition);
}

.agent-card:hover {
    border-color: var(--border-light);
    background: var(--bg-hover);
}

.agent-card.active {
    border-color: var(--accent);
    background: var(--accent-dim);
}

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

.agent-card-header .hostname {
    font-size: 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
}

.agent-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--green);
    display: inline-block;
    animation: pulse-green 2s infinite;
}

@keyframes pulse-green {
    0%, 100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.4); }
    50% { box-shadow: 0 0 0 4px rgba(34, 197, 94, 0); }
}

.agent-card-info {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 4px 10px;
    font-size: 12px;
    color: var(--text-muted);
}

.agent-card-info .label {
    color: var(--text-secondary);
}

.agent-card-actions {
    margin-top: 10px;
    display: flex;
    gap: 6px;
}

.agent-card-actions .btn {
    flex: 1;
    justify-content: center;
    padding: 6px 10px;
    font-size: 12px;
}

/* ─── Main Content ─────────────────────────────────────────────────────────── */

.content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg-primary);
}

/* Welcome Panel */
.welcome-panel {
    flex: 1;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    overflow-y: auto;
    padding: 40px 0;
}

.welcome-content {
    text-align: center;
    color: var(--text-muted);
    max-width: 500px;
}

.welcome-content > i {
    font-size: 64px;
    margin-bottom: 24px;
    color: var(--border-light);
}

.welcome-content h2 {
    font-size: 24px;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.welcome-content p {
    font-size: 14px;
    margin-bottom: 32px;
}

.quick-start {
    text-align: left;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 24px;
}

.quick-start h4 {
    font-size: 14px;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.quick-start ol {
    padding-left: 20px;
    font-size: 13px;
    line-height: 1.8;
    color: var(--text-secondary);
}

.quick-start code {
    background: var(--bg-tertiary);
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    color: var(--accent-hover);
}

/* ─── Remote Panel ─────────────────────────────────────────────────────────── */

.remote-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.remote-toolbar {
    height: var(--toolbar-height);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 12px;
    flex-shrink: 0;
}

.toolbar-left, .toolbar-center, .toolbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

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

.connected-to i { color: var(--green); }

.fps-display {
    font-size: 12px;
    color: var(--text-muted);
    background: var(--bg-tertiary);
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    font-family: 'Consolas', monospace;
}

.mode-switcher {
    display: inline-flex;
    gap: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
    margin: 0 8px;
}

.mode-btn {
    padding: 4px 10px;
    background: transparent;
    border: none;
    border-right: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 11px;
    font-family: var(--font);
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}

.mode-btn:last-child { border-right: none; }

.mode-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.mode-btn.active {
    background: var(--accent);
    color: #fff;
}

.mode-btn.active-hvnc {
    background: #7c3aed;
    color: #fff;
}

.mode-btn.active-hrdp {
    background: #e67e22;
    color: #fff;
}

.toolbar-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 10px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 12px;
    font-family: var(--font);
    cursor: pointer;
    transition: all var(--transition);
}

.toolbar-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--border-light);
}

.toolbar-btn.btn-danger { border-color: rgba(239, 68, 68, 0.3); }
.toolbar-btn.btn-danger:hover { background: var(--red-dim); color: var(--red); }

.toolbar-separator {
    width: 1px;
    height: 24px;
    background: var(--border);
    margin: 0 4px;
}

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

.quality-slider {
    width: 80px;
    accent-color: var(--accent);
}

#quality-value {
    font-size: 12px;
    color: var(--text-secondary);
    min-width: 30px;
}

/* ─── Canvas ───────────────────────────────────────────────────────────────── */

.canvas-container {
    flex: 1;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: stretch;
    justify-content: stretch;
    background: #000;
}

#remote-canvas {
    width: 100%;
    height: 100%;
    image-rendering: auto;
}

#remote-canvas.custom-cursor {
    cursor: none;
}

.canvas-overlay {
    position: absolute;
    inset: 0;
    background: rgba(15, 17, 23, 0.85);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    color: var(--text-secondary);
    font-size: 14px;
    z-index: 10;
}

.canvas-overlay.hidden { display: none; }

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ─── Modal ────────────────────────────────────────────────────────────────── */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    width: 440px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    font-size: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.modal-header h3 i { color: var(--accent); }

.modal-body {
    padding: 20px;
}

.modal-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* ─── Scrollbar ────────────────────────────────────────────────────────────── */

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-light); }

/* ─── Responsive ───────────────────────────────────────────────────────────── */

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: var(--topbar-height);
        bottom: 0;
        z-index: 50;
        box-shadow: var(--shadow-lg);
    }
    .sidebar.collapsed {
        transform: translateX(-100%);
    }
    .topbar-center { display: none; }
    .toolbar-center { flex-wrap: wrap; }
    .toolbar-right { flex-wrap: wrap; }
}

/* ─── Animations ───────────────────────────────────────────────────────────── */

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

.agent-card {
    animation: fadeIn 0.3s ease;
}

/* ─── Notification Toast ───────────────────────────────────────────────────── */

.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 16px;
    font-size: 13px;
    color: var(--text-primary);
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 10px;
    animation: slideIn 0.3s ease;
    max-width: 360px;
}

.toast.success { border-left: 3px solid var(--green); }
.toast.error { border-left: 3px solid var(--red); }
.toast.info { border-left: 3px solid var(--blue); }

@keyframes slideIn {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}
