:root {
    --bg-darkest: #0b0f14;
    --bg-sidebar: #10141b;
    --bg-card: #161b22;
    --bg-card-hover: #1e242d;
    --bg-input: #0d1117;
    --border-color: #262c36;
    --border-focus: #3b82f6;
    --text-primary: #f0f6fc;
    --text-secondary: #8b949e;
    --text-muted: #586069;
    --accent-blue: #00d2ff;
    --accent-cyan: #06b6d4;
    --accent-green: #10b981;
    --accent-yellow: #f59e0b;
    --accent-red: #ef4444;
    --accent-purple: #8b5cf6;
    --gradient-btn: linear-gradient(135deg, #0284c7 0%, #06b6d4 100%);
    --gradient-connect: linear-gradient(135deg, #4f46e5 0%, #7c3aed 50%, #06b6d4 100%);
    --shadow-glow: 0 0 20px rgba(6, 182, 212, 0.35);
    --font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
}

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

body {
    background-color: var(--bg-darkest);
    color: var(--text-primary);
    font-family: var(--font-family);
    height: 100vh;
    overflow: hidden;
    user-select: none;
}

/* App Grid Layout: 4 columns */
.app-container {
    display: grid;
    grid-template-columns: 260px 300px 1fr 340px;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
    background-color: var(--bg-darkest);
}

/* Scrollbar styles */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: #30363d;
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: #484f58;
}

/* ========================================================
   COLUMN 1: MAIN NAVIGATION SIDEBAR
======================================================== */
.sidebar {
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 100%;
    padding: 16px 14px;
}

.brand-section {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 16px;
}

.brand-info {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

.brand-logo {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: linear-gradient(135deg, #0ea5e9, #3b82f6);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 14px;
    color: #fff;
    box-shadow: 0 4px 12px rgba(14, 165, 233, 0.3);
}

.brand-titles h2 {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 6px;
}

.brand-titles p {
    font-size: 11px;
    color: var(--text-secondary);
}

.brand-actions {
    display: flex;
    gap: 6px;
}

.icon-btn-ghost {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 6px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

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

.sidebar-action-btn {
    width: 100%;
    padding: 9px 12px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s;
    margin-bottom: 10px;
}

.upgrade-btn {
    background: #232936;
    color: #f1f5f9;
    border: 1px solid #3b4252;
}

.upgrade-btn:hover {
    background: #2d3444;
    border-color: #eab308;
}

.upgrade-btn .icon {
    color: #eab308;
}

.add-client-btn {
    background: rgba(6, 182, 212, 0.1);
    color: var(--accent-cyan);
    border: 1px solid rgba(6, 182, 212, 0.3);
}

.add-client-btn:hover {
    background: rgba(6, 182, 212, 0.2);
    box-shadow: 0 0 12px rgba(6, 182, 212, 0.25);
}

.nav-menu {
    list-style: none;
    margin-top: 10px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 4px;
}

.nav-item:hover {
    background-color: var(--bg-card);
    color: var(--text-primary);
}

.nav-item.active {
    background-color: rgba(6, 182, 212, 0.15);
    color: var(--accent-cyan);
    font-weight: 600;
}

.groups-section {
    margin-top: 20px;
}

.groups-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 600;
    padding: 4px 8px;
}

/* Sidebar Footer / User Profile */
.sidebar-footer {
    border-top: 1px solid var(--border-color);
    padding-top: 14px;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border-radius: 8px;
    background-color: rgba(255, 255, 255, 0.03);
    margin-bottom: 12px;
}

.avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 13px;
    color: #fff;
    border: 2px solid #0ea5e9;
}

.user-details h4 {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.user-details p {
    font-size: 11px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 130px;
}

.role-badge {
    display: inline-block;
    font-size: 10px;
    background: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
    padding: 1px 6px;
    border-radius: 4px;
    margin-top: 2px;
}

.footer-nav {
    list-style: none;
    margin-bottom: 10px;
}

.footer-nav li {
    font-size: 12px;
    color: var(--text-secondary);
    padding: 7px 10px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
}

.footer-nav li:hover {
    background-color: var(--bg-card);
    color: var(--text-primary);
}

.footer-links {
    display: flex;
    gap: 12px;
    font-size: 11px;
    color: var(--text-muted);
    padding: 4px 8px;
}

.footer-links a {
    color: var(--text-muted);
    text-decoration: none;
}

.footer-links a:hover {
    color: var(--accent-cyan);
    text-decoration: underline;
}

/* ========================================================
   COLUMN 2: CLIENT LIST COLUMN
======================================================== */
.clients-column {
    background-color: var(--bg-darkest);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    height: 100%;
}

.column-header {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
}

.column-header-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.column-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
}

.filter-select {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 12px;
    cursor: pointer;
    outline: none;
}

.search-box {
    position: relative;
    width: 100%;
}

.search-box input {
    width: 100%;
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    padding: 8px 12px 8px 34px;
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 12px;
    outline: none;
    transition: border 0.2s;
}

.search-box input:focus {
    border-color: var(--accent-cyan);
}

.search-box .search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 13px;
}

.clients-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

.client-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 12px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.client-card:hover {
    background-color: var(--bg-card-hover);
    border-color: #3b4252;
    transform: translateY(-1px);
}

.client-card.active {
    background-color: #1a2230;
    border-color: var(--accent-cyan);
    box-shadow: 0 0 10px rgba(6, 182, 212, 0.2);
}

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

.client-title-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.status-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background-color: var(--text-muted);
    display: inline-block;
}

.status-dot.online {
    background-color: var(--accent-green);
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.8);
}

.client-card-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.client-icons {
    display: flex;
    gap: 6px;
    color: var(--accent-cyan);
    font-size: 12px;
}

.client-card-subtitle {
    font-size: 11px;
    color: var(--text-secondary);
    margin-bottom: 8px;
    line-height: 1.3;
}

.client-card-addedby {
    font-size: 11px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
}

.small-avatar {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #0284c7;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    color: #fff;
}

.clients-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--border-color);
    background-color: var(--bg-sidebar);
}

.unattended-toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}

.unattended-label {
    font-size: 12px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 4px;
}

.switch {
    position: relative;
    display: inline-block;
    width: 36px;
    height: 20px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #334155;
    transition: .3s;
    border-radius: 20px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 14px;
    width: 14px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .3s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: var(--accent-cyan);
}

input:checked + .slider:before {
    transform: translateX(16px);
}

.unattended-subtext {
    font-size: 11px;
    color: var(--text-muted);
}

/* ========================================================
   COLUMN 3: CLIENT DETAILS & REMOTE SCREEN PREVIEW
======================================================== */
.details-column {
    background-color: var(--bg-card);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow-y: auto;
}

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

.details-header-left h1 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
}

.details-status-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--accent-cyan);
    margin-top: 4px;
}

.details-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.round-action-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: var(--bg-card-hover);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.round-action-btn:hover {
    background-color: rgba(6, 182, 212, 0.2);
    color: var(--accent-cyan);
    border-color: var(--accent-cyan);
}

.details-content {
    padding: 20px 24px;
    flex: 1;
}

/* App Link Card */
.app-link-card {
    background-color: var(--bg-darkest);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    gap: 12px;
}

.app-link-info {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    overflow: hidden;
}

.app-link-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
}

.app-link-url {
    font-size: 12px;
    color: var(--accent-cyan);
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
    text-decoration: none;
}

.link-buttons-group {
    display: flex;
    gap: 8px;
}

.action-pill-btn {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
}

.action-pill-btn:hover {
    background-color: rgba(6, 182, 212, 0.15);
    border-color: var(--accent-cyan);
    color: var(--accent-cyan);
}

.download-pill-btn {
    background: var(--gradient-btn);
    border: none;
    color: #fff;
    font-weight: 600;
}

.download-pill-btn:hover {
    box-shadow: 0 0 12px rgba(6, 182, 212, 0.4);
}

/* Tabs */
.tabs-header {
    display: flex;
    gap: 20px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 16px;
}

.tab-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 600;
    padding: 8px 4px;
    cursor: pointer;
    position: relative;
    display: flex;
    align-items: center;
    gap: 6px;
}

.tab-btn.active {
    color: var(--text-primary);
}

.tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 2px;
    background-color: var(--accent-cyan);
}

/* Machine Info Grid */
.system-specs-bar {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 16px;
    background-color: var(--bg-sidebar);
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 20px;
    border: 1px solid var(--border-color);
}

.spec-item .label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    font-weight: 600;
    margin-bottom: 4px;
}

.spec-item .value {
    font-size: 13px;
    color: var(--text-primary);
    font-weight: 500;
}

/* Remote Screen Container */
.remote-screen-section h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

.screen-preview-card {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--border-color);
    background-color: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

.preview-wallpaper {
    width: 100%;
    height: 100%;
    object-fit: cover;
    filter: brightness(0.75);
    transition: filter 0.3s;
}

.screen-preview-card:hover .preview-wallpaper {
    filter: brightness(0.6);
}

/* Overlay Connect Button */
.preview-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    z-index: 5;
}

.connect-btn-main {
    padding: 14px 44px;
    font-size: 15px;
    font-weight: 700;
    color: #ffffff;
    background: var(--gradient-connect);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 30px;
    cursor: pointer;
    box-shadow: 0 0 25px rgba(124, 58, 237, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.3);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    gap: 10px;
}

.connect-btn-main:hover {
    transform: scale(1.05);
    box-shadow: 0 0 35px rgba(6, 182, 212, 0.8), inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

.preview-bottom-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(16, 20, 27, 0.85);
    backdrop-filter: blur(8px);
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.permission-pill {
    font-size: 11px;
    font-weight: 600;
    color: var(--accent-green);
    display: flex;
    align-items: center;
    gap: 6px;
}

.admin-shield-banner {
    margin-top: 14px;
    background: rgba(6, 182, 212, 0.08);
    border: 1px solid rgba(6, 182, 212, 0.25);
    border-radius: 8px;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--accent-cyan);
    font-size: 13px;
    font-weight: 500;
}

.admin-shield-banner .shield-icon {
    font-size: 18px;
}

/* Notes area */
.notes-container {
    margin-top: 20px;
}

.notes-container textarea {
    width: 100%;
    background-color: var(--bg-sidebar);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 12px;
    outline: none;
    resize: vertical;
    min-height: 70px;
}

.notes-container textarea:focus {
    border-color: var(--accent-cyan);
}

/* ========================================================
   COLUMN 4: TIMELINE & CHAT DRAWER
======================================================== */
.timeline-column {
    background-color: var(--bg-darkest);
    display: flex;
    flex-direction: column;
    height: 100%;
}

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

.timeline-header-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
}

.timeline-header-actions {
    display: flex;
    gap: 6px;
    color: var(--text-secondary);
}

.timeline-stream {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.timeline-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px 14px;
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.4;
    transition: all 0.2s;
}

.timeline-card strong {
    color: var(--text-primary);
}

.timeline-card.badge-connected {
    background-color: rgba(16, 185, 129, 0.15);
    border-color: rgba(16, 185, 129, 0.4);
    color: #34d399;
    font-weight: 600;
    text-align: center;
}

.timeline-card.badge-disconnected {
    background-color: #21262d;
    border-color: #30363d;
    color: var(--text-muted);
    font-weight: 500;
    text-align: center;
}

.timeline-time {
    font-size: 10px;
    color: var(--text-muted);
    margin-top: 4px;
    display: block;
    text-align: right;
}

/* Chat bubble styles within timeline */
.chat-bubble {
    border-radius: 12px;
    padding: 10px 14px;
    font-size: 12px;
    max-width: 85%;
    line-height: 1.4;
}

.chat-bubble.operator {
    align-self: flex-end;
    background: linear-gradient(135deg, #0284c7, #0ea5e9);
    color: #ffffff;
    border-bottom-right-radius: 2px;
}

.chat-bubble.client {
    align-self: flex-start;
    background: #21262d;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-bottom-left-radius: 2px;
}

.chat-bubble .meta {
    font-size: 9px;
    opacity: 0.8;
    margin-top: 4px;
    display: block;
    text-align: right;
}

.timeline-footer {
    padding: 14px 16px;
    border-top: 1px solid var(--border-color);
    background-color: var(--bg-sidebar);
}

.chat-input-wrapper {
    display: flex;
    align-items: center;
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    padding: 4px 6px 4px 14px;
    transition: border 0.2s;
}

.chat-input-wrapper:focus-within {
    border-color: var(--accent-cyan);
}

.chat-input-wrapper input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 12px;
    outline: none;
}

.chat-send-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-color: var(--accent-cyan);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
}

.chat-send-btn:hover {
    transform: scale(1.08);
}

/* Modal styles for adding new client or viewing apps */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.modal-backdrop.open {
    opacity: 1;
    pointer-events: auto;
}

.modal-box {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    width: 520px;
    max-width: 95vw;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
    overflow: hidden;
}

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

.modal-header h3 {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
}

.modal-body {
    padding: 20px 24px;
}

.modal-body p {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 16px;
}

.modal-download-card {
    background: var(--bg-sidebar);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 16px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-footer {
    padding: 14px 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    background-color: var(--bg-sidebar);
}
