/* ─── ZeroReach Dark Theme ─────────────────────────────────────────────── */

:root {
    --bg-primary:    #111318;
    --bg-secondary:  #1a1d24;
    --bg-card:       #1e2128;
    --bg-hover:      #262b35;
    --sidebar-bg:    #13161c;
    --sidebar-w:     210px;
    --accent:        #2d6be4;
    --accent-bright: #3d7cf5;
    --accent-light:  #6fa3f8;
    --border:        #2a2f3a;
    --text-primary:  #e8ecf4;
    --text-muted:    #7a8499;
    --text-dim:      #454d60;
    --green:         #3fb950;
    --yellow:        #e3b341;
    --red:           #f85149;
    --blue:          #58a6ff;
    --font-mono:     "Cascadia Code", "Fira Code", "Consolas", monospace;
    --radius:        6px;
    --radius-lg:     10px;
    --shadow:        0 2px 12px rgba(0,0,0,0.5);
}

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

html, body {
    height: 100%;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: "Segoe UI", "Inter", system-ui, sans-serif;
    font-size: 14px;
    line-height: 1.5;
}

a { color: var(--accent-light); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ─── App Layout ─────────────────────────────────────────────────────────── */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* ─── Sidebar ────────────────────────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-w);
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border);
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    z-index: 100;
    overflow: hidden;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 18px 16px 16px;
    border-bottom: 1px solid var(--border);
}

.sidebar-icon {
    font-size: 20px;
    color: var(--accent);
    flex-shrink: 0;
}

.sidebar-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: 0.04em;
}

.sidebar-sub {
    font-size: 10px;
    color: var(--text-dim);
    margin-top: 1px;
}

.sidebar-nav {
    flex: 1;
    padding: 12px 8px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow-y: auto;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 9px 12px;
    border-radius: var(--radius);
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
    transition: background 0.15s, color 0.15s;
    text-decoration: none;
    cursor: pointer;
}

.sidebar-link:hover { background: var(--bg-hover); color: var(--text-primary); text-decoration: none; }
.sidebar-link.active { background: rgba(45,107,228,0.18); color: var(--accent-light); }

.sl-icon {
    width: 18px;
    text-align: center;
    flex-shrink: 0;
    font-size: 14px;
}

.sidebar-footer {
    padding: 8px 8px 4px;
    border-top: 1px solid var(--border);
}

.relay-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-muted);
    padding: 8px 12px 4px;
}

.sidebar-link-logout { color: var(--text-dim); margin-top: 2px; }
.sidebar-link-logout:hover { color: var(--red); background: rgba(248,81,73,0.08); }

/* ─── Main Content ────────────────────────────────────────────────────────── */
.main-content {
    margin-left: var(--sidebar-w);
    flex: 1;
    min-width: 0;
    padding: 24px 28px 60px;
    max-width: 100%;
}

/* ─── Status Dots ─────────────────────────────────────────────────────────── */
.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.status-dot.green { background: var(--green); box-shadow: 0 0 5px var(--green); }
.status-dot.red   { background: var(--red);   box-shadow: 0 0 5px var(--red); }
.status-dot.gray  { background: var(--text-dim); }

/* ─── Page Header ─────────────────────────────────────────────────────────── */
.page-header { margin-bottom: 22px; }

.page-header h1 {
    font-size: 22px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.header-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 5px;
}

.refresh-hint { font-size: 11px; color: var(--text-dim); }

.breadcrumb { font-size: 12px; color: var(--text-muted); margin-bottom: 6px; }
.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--accent-light); }

.agent-meta { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }

/* ─── Badges ──────────────────────────────────────────────────────────────── */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    background: var(--bg-card);
    color: var(--text-muted);
    border: 1px solid var(--border);
}
.badge-ok   { background: rgba(63,185,80,0.12); color: var(--green); border-color: rgba(63,185,80,0.25); }
.badge-warn { background: rgba(248,81,73,0.12); color: var(--red);   border-color: rgba(248,81,73,0.25); }
.badge-os   { background: rgba(45,107,228,0.15); color: var(--accent-light); border-color: var(--accent); }
.badge-ip   { background: var(--bg-secondary); color: var(--text-muted); }

/* ─── Cards ───────────────────────────────────────────────────────────────── */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow: hidden;
}

/* ─── Metrics Row ─────────────────────────────────────────────────────────── */
.metrics-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 14px;
    margin-bottom: 22px;
}

.metric-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 15px;
}

.metric-title {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.metric-value { font-size: 22px; font-weight: 700; margin-bottom: 10px; }
.metric-time  { font-size: 12px; font-weight: 400; color: var(--text-muted); }

.metric-bar-large {
    height: 5px;
    background: var(--bg-hover);
    border-radius: 3px;
    overflow: hidden;
}

/* ─── Metric Bars ─────────────────────────────────────────────────────────── */
.metric-bar {
    display: flex;
    align-items: center;
    gap: 7px;
    min-width: 75px;
}

.metric-bar > div:first-child {
    flex: 1;
    height: 5px;
    background: var(--bg-hover);
    border-radius: 3px;
    overflow: hidden;
}

.metric-fill { height: 100%; border-radius: 3px; transition: width 0.5s ease; min-width: 2px; }
.cpu-fill    { background: linear-gradient(90deg, #2d6be4, #64b5f6); }
.ram-fill    { background: linear-gradient(90deg, #8b5cf6, #c4b5fd); }
.disk-fill   { background: linear-gradient(90deg, #f59e0b, #fcd34d); }

.metric-label { font-size: 11px; color: var(--text-muted); white-space: nowrap; min-width: 28px; text-align: right; }

/* ─── Agent Table ─────────────────────────────────────────────────────────── */
.card-scroll { overflow-x: auto; }

.agent-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12.5px;
    min-width: 900px;
}

.agent-table th {
    text-align: left;
    padding: 10px 12px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    background: var(--bg-secondary);
}

.agent-table td {
    padding: 11px 12px;
    border-bottom: 1px solid rgba(255,255,255,0.035);
    vertical-align: middle;
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.agent-table td.wrap { white-space: normal; }

.agent-row:hover td { background: var(--bg-hover); }
.agent-row:last-child td { border-bottom: none; }

.hostname-cell { font-weight: 600; color: var(--text-primary); max-width: 130px; }
.os-cell       { color: var(--text-muted); font-size: 11px; max-width: 100px; }
.ip-cell       { color: var(--text-muted); font-size: 11px; }
.time-cell     { font-size: 10px; color: var(--text-dim); font-family: var(--font-mono); }
.actions-cell  { white-space: nowrap; max-width: 260px; }
.actions-cell .btn { margin-right: 3px; margin-bottom: 2px; }

.empty-state   { text-align: center; padding: 60px 20px !important; color: var(--text-muted); }
.empty-icon    { font-size: 44px; margin-bottom: 16px; }
.empty-hint    { font-size: 12px; color: var(--text-dim); margin-top: 8px; }

/* ─── Panels Grid ─────────────────────────────────────────────────────────── */
.panels-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 18px;
}

.panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    min-height: 260px;
}

.panel-wide { grid-column: span 2; }

.panel-header {
    padding: 13px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.panel-header h2 { font-size: 13px; font-weight: 600; }

.panel-body {
    padding: 14px 16px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* ─── Shell ───────────────────────────────────────────────────────────────── */
.shell-input-row { display: flex; gap: 8px; }

.shell-input {
    flex: 1;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    padding: 7px 11px;
    font-family: var(--font-mono);
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s;
}
.shell-input:focus { border-color: var(--accent-light); }

.shell-output {
    flex: 1;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 11px;
    font-family: var(--font-mono);
    font-size: 12px;
    color: #d4d8e2;
    min-height: 150px;
    max-height: 380px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-all;
}

.history-row { display: flex; gap: 5px; flex-wrap: wrap; min-height: 0; }

/* ─── Screenshot ──────────────────────────────────────────────────────────── */
.screenshot-panel { align-items: center; }

.screenshot-placeholder {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-dim);
    font-size: 13px;
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    min-height: 140px;
}

.screenshot-img { max-width: 100%; border-radius: var(--radius); border: 1px solid var(--border); cursor: zoom-in; }
.screenshot-meta { font-size: 11px; color: var(--text-dim); text-align: center; }
.loading-text { color: var(--text-muted); font-size: 13px; text-align: center; padding: 20px; }

/* ─── File Browser ────────────────────────────────────────────────────────── */
.file-path-input {
    flex: 1;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    padding: 7px 11px;
    font-family: var(--font-mono);
    font-size: 13px;
    outline: none;
}
.file-path-input:focus { border-color: var(--accent-light); }

.file-listing {
    flex: 1;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    min-height: 150px;
    max-height: 300px;
    overflow-y: auto;
}

/* ─── RDP Panel ───────────────────────────────────────────────────────────── */
.rdp-panel { align-items: center; justify-content: center; text-align: center; }
.rdp-desc  { color: var(--text-muted); font-size: 13px; max-width: 280px; }

.rdp-result {
    margin-top: 12px;
    font-size: 12px;
    padding: 11px;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    max-width: 300px;
    text-align: left;
}
.rdp-result code { font-family: var(--font-mono); font-size: 11px; color: var(--accent-light); }

/* ─── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 7px 14px;
    border: none;
    border-radius: var(--radius);
    font-size: 12.5px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.12s, opacity 0.12s;
    text-decoration: none;
    white-space: nowrap;
    line-height: 1.3;
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn:hover:not(:disabled) { opacity: 0.83; }

.btn-primary   { background: var(--accent);      color: #fff; }
.btn-secondary { background: var(--bg-hover);    color: var(--text-primary); border: 1px solid var(--border); }
.btn-warning   { background: #6b3800;            color: #fbbf24; border: 1px solid #92400e; }
.btn-danger    { background: #5c1a1a;            color: #fca5a5; border: 1px solid #7f1d1d; }
.btn-ghost     { background: transparent;        color: var(--text-muted); border: 1px solid transparent; }

.btn-sm    { padding: 4px 9px;  font-size: 11.5px; }
.btn-xs    { padding: 2px 6px;  font-size: 11px; }
.btn-large { padding: 11px 26px; font-size: 14px; }

.btn-ghost:hover { border-color: var(--border); color: var(--text-primary); }
.ok-text    { color: var(--green); font-weight: 600; }
.error-text { color: var(--red); }

/* ─── Alerts ──────────────────────────────────────────────────────────────── */
.alert {
    padding: 11px 15px;
    border-radius: var(--radius);
    margin-bottom: 18px;
    font-size: 13px;
}
.alert-error { background: rgba(248,81,73,0.1); border: 1px solid rgba(248,81,73,0.25); color: #fca5a5; }

/* ─── Modals ──────────────────────────────────────────────────────────────── */
.modal { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.72); z-index: 999; align-items: center; justify-content: center; padding: 20px; }
.modal.visible { display: flex; }

.modal-box {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: 0 8px 40px rgba(0,0,0,0.7);
    width: 100%;
    max-width: 680px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.modal-wide     { max-width: 980px; }
.modal-fullscreen { max-width: 95vw; max-height: 95vh; position: relative; }

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
}
.modal-header h2 { font-size: 15px; font-weight: 600; }
.modal-close { background: none; border: none; color: var(--text-muted); font-size: 20px; cursor: pointer; line-height: 1; padding: 0; }
.modal-close:hover { color: var(--text-primary); }

.modal-body { padding: 14px 18px; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 11px; }

/* ─── Scrollbar ───────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-hover); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

/* ─── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
    .panels-grid { grid-template-columns: 1fr; }
    .panel-wide  { grid-column: span 1; }
    .metrics-row { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 700px) {
    .sidebar { width: 52px; }
    .sidebar-title, .sidebar-sub, .sidebar-sub, .sl-icon + *, .relay-status span:last-child, .sidebar-footer div { display: none; }
    .sidebar-link { justify-content: center; padding: 10px; }
    .main-content { margin-left: 52px; padding: 14px 14px 60px; }
}
