/* ========================================
   xDesk Web Console - Dark Theme
   ======================================== */

:root {
    --bg-primary: #0D0D1A;
    --bg-secondary: #12122A;
    --bg-tertiary: #1A1A35;
    --card-bg: rgba(255, 255, 255, 0.04);
    --card-bg-hover: rgba(255, 255, 255, 0.07);
    --card-border: rgba(255, 255, 255, 0.08);
    --primary: #6C63FF;
    --primary-hover: #5A52E0;
    --primary-glow: rgba(108, 99, 255, 0.25);
    --success: #34D399;
    --warning: #FBBF24;
    --danger: #F87171;
    --info: #60A5FA;
    --text-primary: #E8E8F0;
    --text-secondary: #A0A0B8;
    --text-muted: #6B6B80;
    --border: rgba(255, 255, 255, 0.08);
    --sidebar-width: 260px;
    --header-height: 64px;
    --radius: 12px;
    --radius-sm: 8px;
    --transition: 0.2s ease;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, textarea, select { font-family: inherit; font-size: inherit; }
table { border-collapse: collapse; width: 100%; }

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }

/* ========================================
   Login Screen
   ======================================== */
.login-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg-primary);
    background-image:
        radial-gradient(ellipse 600px 400px at 50% 30%, rgba(108, 99, 255, 0.08) 0%, transparent 70%);
}
.login-card {
    width: 100%;
    max-width: 400px;
    padding: 40px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 20px;
    backdrop-filter: blur(20px);
}
.login-logo {
    text-align: center;
    margin-bottom: 32px;
}
.login-logo svg {
    margin-bottom: 16px;
}
.login-logo h1 {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.5px;
}
.login-subtitle {
    color: var(--text-muted);
    font-size: 14px;
    margin-top: 4px;
}

/* ---- Forms ---- */
.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,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}
.form-group input::placeholder {
    color: var(--text-muted);
}
.form-error {
    background: rgba(248, 113, 113, 0.1);
    border: 1px solid rgba(248, 113, 113, 0.3);
    border-radius: var(--radius-sm);
    color: var(--danger);
    padding: 10px 14px;
    font-size: 13px;
    margin-bottom: 16px;
}

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-weight: 500;
    font-size: 14px;
    transition: all var(--transition);
    white-space: nowrap;
}
.btn-primary {
    background: var(--primary);
    color: #fff;
}
.btn-primary:hover {
    background: var(--primary-hover);
    box-shadow: 0 4px 16px var(--primary-glow);
}
.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
.btn-ghost {
    color: var(--text-secondary);
    background: transparent;
}
.btn-ghost:hover {
    color: var(--text-primary);
    background: rgba(255,255,255,0.05);
}
.btn-danger {
    background: rgba(248, 113, 113, 0.15);
    color: var(--danger);
}
.btn-danger:hover {
    background: rgba(248, 113, 113, 0.25);
}
.btn-block { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-loader {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ========================================
   App Shell Layout
   ======================================== */
.app-shell {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* ---- Sidebar ---- */
.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 0;
    overflow-y: auto;
}
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}
.sidebar-brand svg {
    width: 32px;
    height: 32px;
}
.brand-text {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.3px;
}
.sidebar-nav {
    flex: 1;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-weight: 450;
    font-size: 14px;
    transition: all var(--transition);
}
.nav-item:hover {
    color: var(--text-primary);
    background: rgba(255,255,255,0.05);
}
.nav-item.active {
    color: #fff;
    background: var(--primary);
}
.nav-item.active svg {
    opacity: 1;
}
.nav-item svg {
    opacity: 0.6;
    flex-shrink: 0;
}
.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}
.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    flex-shrink: 0;
}
.user-details {
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.user-name {
    font-weight: 500;
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.user-role {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ---- Main Content ---- */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}
.content-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    height: var(--header-height);
    min-height: var(--header-height);
    border-bottom: 1px solid var(--border);
}
.content-header h2 {
    font-size: 20px;
    font-weight: 600;
}
.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}
.connection-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-muted);
}
.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}
.status-dot-online {
    background: var(--success);
    box-shadow: 0 0 6px rgba(52, 211, 153, 0.5);
}
.status-dot-offline {
    background: var(--text-muted);
}
.content-body {
    flex: 1;
    overflow-y: auto;
    padding: 24px 32px;
}

/* ========================================
   Dashboard Section
   ======================================== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}
.stat-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius);
    padding: 24px;
    transition: all var(--transition);
}
.stat-card:hover {
    background: var(--card-bg-hover);
    border-color: rgba(255, 255, 255, 0.12);
}
.stat-label {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}
.stat-value {
    font-size: 36px;
    font-weight: 700;
    letter-spacing: -1px;
    line-height: 1;
}
.stat-value.text-success { color: var(--success); }
.stat-value.text-primary { color: var(--primary); }
.stat-value.text-warning { color: var(--warning); }
.stat-value.text-info { color: var(--info); }
.stat-sub {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 8px;
}

/* ---- Plan Info Card ---- */
.plan-card {
    background: linear-gradient(135deg, rgba(108, 99, 255, 0.12) 0%, rgba(108, 99, 255, 0.04) 100%);
    border: 1px solid rgba(108, 99, 255, 0.2);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 32px;
}
.plan-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}
.plan-name {
    font-size: 18px;
    font-weight: 600;
    text-transform: capitalize;
}
.plan-badge {
    background: var(--primary);
    color: #fff;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}
.plan-features {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 8px;
}
.plan-feature {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-secondary);
}
.plan-feature .check {
    color: var(--success);
    font-weight: 700;
}
.plan-feature .cross {
    color: var(--text-muted);
}

/* ========================================
   Data Tables
   ======================================== */
.card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius);
    overflow: hidden;
}
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}
.card-title {
    font-size: 16px;
    font-weight: 600;
}
.card-body {
    padding: 0;
}
.table-wrap {
    overflow-x: auto;
}
table {
    width: 100%;
    font-size: 13px;
}
thead th {
    text-align: left;
    padding: 12px 16px;
    font-weight: 500;
    color: var(--text-muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    background: rgba(255, 255, 255, 0.02);
}
tbody tr {
    border-bottom: 1px solid var(--border);
    transition: background var(--transition);
}
tbody tr:last-child {
    border-bottom: none;
}
tbody tr:hover {
    background: rgba(255, 255, 255, 0.03);
}
tbody td {
    padding: 12px 16px;
    color: var(--text-secondary);
    white-space: nowrap;
}
.table-empty {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-muted);
}
.table-empty svg {
    opacity: 0.3;
    margin-bottom: 12px;
}

/* ---- Badges / Pills ---- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}
.badge-online {
    background: rgba(52, 211, 153, 0.12);
    color: var(--success);
}
.badge-offline {
    background: rgba(107, 107, 128, 0.12);
    color: var(--text-muted);
}
.badge-active {
    background: rgba(52, 211, 153, 0.12);
    color: var(--success);
}
.badge-connecting {
    background: rgba(251, 191, 36, 0.12);
    color: var(--warning);
}
.badge-ended {
    background: rgba(107, 107, 128, 0.12);
    color: var(--text-muted);
}
.badge-owner {
    background: rgba(108, 99, 255, 0.15);
    color: var(--primary);
}
.badge-admin {
    background: rgba(96, 165, 250, 0.15);
    color: var(--info);
}
.badge-operator {
    background: rgba(107, 107, 128, 0.15);
    color: var(--text-secondary);
}
.badge-inactive {
    background: rgba(248, 113, 113, 0.12);
    color: var(--danger);
}
.badge-mfa-on {
    background: rgba(52, 211, 153, 0.12);
    color: var(--success);
}
.badge-mfa-off {
    background: rgba(107, 107, 128, 0.12);
    color: var(--text-muted);
}

/* ---- OS Icons ---- */
.os-icon {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

/* ---- Filters Bar ---- */
.filters-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}
.filter-input {
    padding: 8px 14px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 13px;
    outline: none;
    min-width: 200px;
    transition: border-color var(--transition);
}
.filter-input:focus {
    border-color: var(--primary);
}
.filter-input::placeholder {
    color: var(--text-muted);
}
.filter-select {
    padding: 8px 14px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 13px;
    outline: none;
    cursor: pointer;
}
.filter-select option {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

/* ========================================
   Settings Section
   ======================================== */
.settings-form {
    max-width: 640px;
}
.settings-group {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 20px;
}
.settings-group-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}
.setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}
.setting-row:last-child {
    border-bottom: none;
    padding-bottom: 0;
}
.setting-label {
    font-size: 14px;
    color: var(--text-secondary);
}
.setting-desc {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}
.settings-json {
    width: 100%;
    min-height: 300px;
    padding: 16px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 13px;
    line-height: 1.6;
    resize: vertical;
    outline: none;
    tab-size: 2;
}
.settings-json:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}
.settings-actions {
    display: flex;
    gap: 12px;
    margin-top: 16px;
}

/* ========================================
   Toast Notifications
   ======================================== */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.toast {
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    min-width: 280px;
    max-width: 420px;
    animation: toast-in 0.3s ease;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    gap: 10px;
}
.toast-success {
    background: rgba(52, 211, 153, 0.15);
    border: 1px solid rgba(52, 211, 153, 0.3);
    color: var(--success);
}
.toast-error {
    background: rgba(248, 113, 113, 0.15);
    border: 1px solid rgba(248, 113, 113, 0.3);
    color: var(--danger);
}
.toast-info {
    background: rgba(96, 165, 250, 0.15);
    border: 1px solid rgba(96, 165, 250, 0.3);
    color: var(--info);
}
@keyframes toast-in {
    from { opacity: 0; transform: translateX(40px); }
    to { opacity: 1; transform: translateX(0); }
}

/* ========================================
   Loading States
   ======================================== */
.loading-spinner {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 64px 20px;
}
.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid rgba(108, 99, 255, 0.2);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* ---- Skeleton ---- */
.skeleton {
    background: linear-gradient(90deg, rgba(255,255,255,0.04) 25%, rgba(255,255,255,0.08) 50%, rgba(255,255,255,0.04) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 6px;
}
@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ========================================
   Pagination
   ======================================== */
.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-top: 1px solid var(--border);
}
.pagination-info {
    font-size: 13px;
    color: var(--text-muted);
}
.pagination-buttons {
    display: flex;
    gap: 8px;
}

/* ========================================
   Responsive
   ======================================== */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: -280px;
        top: 0;
        height: 100vh;
        z-index: 1000;
        transition: left 0.3s ease;
    }
    .sidebar.open {
        left: 0;
    }
    .content-body {
        padding: 16px;
    }
    .stats-grid {
        grid-template-columns: 1fr;
    }
}
