/* ============================================================
   RustDesk Admin Panel — app.css
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg:           #0b0d14;
    --surface:      #13151f;
    --surface2:     #1c1f2e;
    --surface3:     #252840;
    --border:       #2a2d45;
    --accent:       #6366f1;
    --accent-hover: #818cf8;
    --accent-glow:  rgba(99,102,241,.18);
    --success:      #34d399;
    --warning:      #fbbf24;
    --danger:       #f87171;
    --text:         #e2e8f0;
    --text-muted:   #7c85a2;
    --sidebar-w:    248px;
    --radius:       10px;
    --radius-sm:    6px;
    --shadow:       0 4px 24px rgba(0,0,0,.55);
    --shadow-sm:    0 2px 8px rgba(0,0,0,.35);
}

body {
    font-family: 'Segoe UI', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
}

/* ---- Layout ---- */
.sidebar {
    position: fixed;
    top: 0; left: 0;
    width: var(--sidebar-w);
    height: 100vh;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 100;
    overflow: hidden;
}

/* subtle gradient overlay */
.sidebar::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 160px;
    background: radial-gradient(ellipse at 20% 0%, rgba(99,102,241,.12) 0%, transparent 70%);
    pointer-events: none;
}

/* ---- Brand ---- */
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 22px 18px 20px;
    border-bottom: 1px solid var(--border);
    position: relative;
    z-index: 1;
    overflow: hidden;
}

.sidebar-brand-icon {
    width: 36px; height: 36px;
    background: var(--accent-glow);
    border: 1px solid rgba(99,102,241,.35);
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    color: var(--accent);
    flex-shrink: 0;
}

.sidebar-brand-icon svg { width: 18px; height: 18px; }

.sidebar-brand-name {
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
    line-height: 1.1;
    letter-spacing: -.2px;
}

.sidebar-brand-logo {
    max-height: 40px;
    max-width: 100%;
    width: auto;
    display: block;
    object-fit: contain;
}

.sidebar-brand-sub {
    display: block;
    font-size: 10px;
    color: var(--text-muted);
    letter-spacing: .4px;
    text-transform: uppercase;
    line-height: 1;
}

/* ---- Nav list ---- */
.sidebar-nav {
    list-style: none;
    flex: 1;
    padding: 10px 10px 0;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

.nav-separator {
    padding: 16px 10px 5px;
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1.2px;
    user-select: none;
}

/* ---- Nav item ---- */
.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    margin: 1px 0;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 500;
    position: relative;
    transition: background .14s, color .14s;
    cursor: pointer;
}

.nav-item:hover {
    background: var(--surface2);
    color: var(--text);
}

.nav-item.active {
    background: var(--accent-glow);
    color: var(--text);
}

.nav-icon {
    width: 20px; height: 20px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    opacity: .65;
    transition: opacity .14s;
}

.nav-item.active .nav-icon,
.nav-item:hover .nav-icon { opacity: 1; }

.nav-item.active .nav-icon { color: var(--accent); }

.nav-icon svg { width: 16px; height: 16px; }

.nav-label { flex: 1; line-height: 1; }

/* Active pill indicator */
.nav-pill {
    width: 4px; height: 20px;
    background: var(--accent);
    border-radius: 2px;
    position: absolute;
    right: -10px;
    box-shadow: 0 0 8px rgba(99,102,241,.6);
}

/* ---- Footer / user ---- */
.sidebar-footer {
    padding: 14px 16px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-avatar {
    width: 32px; height: 32px;
    background: linear-gradient(135deg, var(--accent), #a855f7);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 13px;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
}

.sidebar-footer-info {
    flex: 1;
    overflow: hidden;
}

.sidebar-user {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-role {
    display: block;
    font-size: 10px;
    color: var(--text-muted);
    text-transform: capitalize;
    letter-spacing: .3px;
}

.sidebar-logout {
    width: 30px; height: 30px;
    border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    color: var(--text-muted);
    background: transparent;
    transition: background .14s, color .14s;
    flex-shrink: 0;
}

.sidebar-logout:hover {
    background: rgba(248,113,113,.12);
    color: var(--danger);
}

.sidebar-logout svg { width: 16px; height: 16px; }

/* ---- Main content ---- */
.main-content {
    margin-left: var(--sidebar-w);
    padding: 28px 32px;
    min-height: 100vh;
}

/* ---- Login ---- */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg);
}

.login-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 40px 36px;
    width: 100%;
    max-width: 380px;
    box-shadow: var(--shadow);
}

.login-logo {
    text-align: center;
    margin-bottom: 28px;
}

.login-logo-img {
    max-width: 180px;
    max-height: 60px;
    width: auto;
    height: auto;
    object-fit: contain;
    display: inline-block;
}

/* ---- Page header ---- */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.page-header h1 { font-size: 1.5rem; font-weight: 700; }
.page-header small { color: var(--text-muted); font-size: 13px; }

/* ---- Cards ---- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.card-header {
    padding: 14px 18px;
    font-weight: 600;
    border-bottom: 1px solid var(--border);
    background: var(--surface2);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-body { padding: 18px; }
.p-0 { padding: 0 !important; }
.mt-2 { margin-top: 10px; }
.mt-3 { margin-top: 20px; }

/* ---- Stats grid ---- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--shadow);
}

.stat-icon { font-size: 2rem; }
.stat-value { font-size: 1.8rem; font-weight: 700; line-height: 1; }
.stat-label { color: var(--text-muted); font-size: 12px; margin-top: 4px; }

.row-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
    margin-bottom: 16px;
}

/* ---- Service status ---- */
.service-status {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}

.service-status:last-of-type { border-bottom: none; }
.service-name { font-weight: 500; }

.service-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }

/* ---- Resources ---- */
.resource-item {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.resource-item > span:first-child { width: 40px; color: var(--text-muted); font-size: 12px; }

.progress-bar-wrap {
    flex: 1;
    height: 8px;
    background: var(--surface2);
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: var(--accent);
    border-radius: 4px;
    transition: width .4s;
}

.uptime-val { color: var(--success); font-weight: 600; }

/* ---- Table ---- */
.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: 10px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}

.table th {
    background: var(--surface2);
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: .5px;
}

.table-hover tbody tr:hover { background: var(--surface2); }

.table tbody tr:last-child td { border-bottom: none; }

.text-center { text-align: center; }
.text-muted   { color: var(--text-muted); }
.float-right  { float: right; }

/* ---- Badges ---- */
.badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
}

.badge-success   { background: rgba(52,211,153,.15); color: var(--success); }
.badge-danger    { background: rgba(248,113,113,.15); color: var(--danger);  }
.badge-warning   { background: rgba(251,191,36,.15);  color: var(--warning); }
.badge-secondary { background: var(--surface2);        color: var(--text-muted); }
.badge-primary   { background: rgba(79,142,247,.15);  color: var(--accent); }

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 7px 14px;
    border-radius: var(--radius);
    border: none;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    transition: background .15s, opacity .15s;
}

.btn-block { width: 100%; justify-content: center; }
.btn-sm    { padding: 5px 10px; font-size: 12px; }
.btn-xs    { padding: 3px 8px; font-size: 11px; }

.btn-primary   { background: var(--accent);   color: #fff; }
.btn-primary:hover   { background: var(--accent-hover); }
.btn-success   { background: var(--success);  color: #000; }
.btn-warning   { background: var(--warning);  color: #000; }
.btn-danger    { background: var(--danger);   color: #fff; }
.btn-secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }

/* ---- Forms ---- */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; margin-bottom: 5px; font-size: 12px; color: var(--text-muted); font-weight: 600; }

input[type="text"],
input[type="email"],
input[type="password"],
select,
textarea {
    width: 100%;
    padding: 9px 12px;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 14px;
    transition: border-color .15s;
    outline: none;
}

input:focus, select:focus, textarea:focus { border-color: var(--accent); }

/* ---- Alerts ---- */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-size: 13px;
}

.alert-success { background: rgba(52,211,153,.12); border: 1px solid rgba(52,211,153,.3); color: var(--success); }
.alert-error   { background: rgba(248,113,113,.12); border: 1px solid rgba(248,113,113,.3); color: var(--danger); }

/* ---- Filter bar ---- */
.filter-bar {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.filter-bar input[type="text"] { width: auto; flex: 1; min-width: 180px; }
.filter-bar select { width: auto; }

/* ---- Pagination ---- */
.pagination { display: flex; gap: 6px; margin-top: 14px; flex-wrap: wrap; }

.page-link {
    padding: 5px 10px;
    border-radius: var(--radius);
    background: var(--surface2);
    border: 1px solid var(--border);
    color: var(--text);
    text-decoration: none;
    font-size: 12px;
}

.page-link.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ---- Helpers ---- */
.fw-600    { font-weight: 600; }
.link-subtle { color: var(--text); text-decoration: none; }
.link-subtle:hover { color: var(--accent); }
.row-inactive { opacity: .5; }

.form-row-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text);
}

.checkbox-label input[type=checkbox] { width: auto; }

.rd-id { color: var(--accent); font-size: 13px; }

/* ---- Peer status dot ---- */
.peer-dot {
    display: inline-block;
    width: 8px; height: 8px;
    border-radius: 50%;
    margin-right: 5px;
    vertical-align: middle;
    flex-shrink: 0;
}
.peer-dot--online  { background: #22c55e; box-shadow: 0 0 4px #22c55e88; }
.peer-dot--offline { background: #ef4444; }
.peer-dot--unknown { background: #94a3b8; }

/* ---- Client name in table ---- */
.client-name    { font-weight: 600; }
.client-company { font-size: 12px; }

/* ---- Server config widget ---- */
.server-config-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
}

.config-item {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.config-item-full { grid-column: 1 / -1; flex-direction: row; align-items: center; gap: 12px; }

.config-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .5px;
}

.config-val {
    font-size: 13px;
    color: var(--accent);
    word-break: break-all;
}

.config-key { flex: 1; }

/* ---- Modal ---- */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.65);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999;
}

.modal-content {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px 28px 20px;
    width: 100%;
    max-width: 460px;
    box-shadow: var(--shadow);
}

.modal-content h3 { margin-bottom: 18px; font-size: 1.1rem; }

.modal-footer {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 18px;
}
