/* =============================================================
   VHMC2 Controller Dashboard — Stylesheet
   ============================================================= */

/* ── Custom Properties ── */
:root {
    --bg:         #0d1117;
    --bg2:        #161b22;
    --bg3:        #1c2128;
    --bg4:        #21262d;
    --border:     #30363d;
    --border2:    #3d444d;
    --text:       #e6edf3;
    --text2:      #8b949e;
    --text3:      #6e7681;
    --accent:     #2f81f7;
    --accent2:    #58a6ff;
    --green:      #3fb950;
    --yellow:     #d29922;
    --red:        #f85149;
    --purple:     #a371f7;
    --cyan:       #39c5cf;
    --sidebar-w:  230px;
    --topbar-h:   56px;
    --radius:     6px;
    --radius-lg:  10px;
    --shadow:     0 1px 3px rgba(0,0,0,.4);
    --shadow-lg:  0 8px 32px rgba(0,0,0,.6);
    --font:       -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --mono:       'JetBrains Mono', 'Fira Code', 'Courier New', monospace;
    --transition: 150ms ease;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; font-family: var(--font); background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5; }
a { color: var(--accent2); text-decoration: none; }
a:hover { text-decoration: underline; }
ul { list-style: none; }
button { cursor: pointer; font-family: inherit; font-size: inherit; }
input, select, textarea { font-family: inherit; font-size: inherit; color: var(--text); }
#app { height: 100%; }

/* ── Utility ── */
.hidden { display: none !important; }
.flex   { display: flex; }
.gap-2  { gap: 8px; }
.gap-4  { gap: 16px; }
.mt-2   { margin-top: 8px; }
.mt-4   { margin-top: 16px; }
.mb-4   { margin-bottom: 16px; }
.w-full { width: 100%; }
.text-right { text-align: right; }
.text-muted { color: var(--text2); }
.mono   { font-family: var(--mono); font-size: 12px; }

/* ── Login Screen ── */
#login-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: radial-gradient(ellipse at 50% 0%, #1c2744 0%, var(--bg) 70%);
}
.login-card {
    width: 360px;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 40px 36px;
    box-shadow: var(--shadow-lg);
}
.login-logo {
    font-size: 28px;
    font-weight: 700;
    color: var(--accent2);
    text-align: center;
    letter-spacing: 4px;
    margin-bottom: 4px;
}
.login-subtitle {
    text-align: center;
    color: var(--text2);
    margin-bottom: 28px;
    font-size: 13px;
}

/* ── Forms ── */
.form-group {
    margin-bottom: 16px;
}
.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text2);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: .5px;
}
.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 8px 12px;
    color: var(--text);
    transition: border-color var(--transition);
    outline: none;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(47,129,247,.15);
}
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border-radius: var(--radius);
    border: 1px solid transparent;
    font-weight: 500;
    transition: background var(--transition), border-color var(--transition), opacity var(--transition);
    white-space: nowrap;
}
.btn:disabled { opacity: .5; pointer-events: none; }
.btn-primary {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}
.btn-primary:hover { background: #388bfd; border-color: #388bfd; }
.btn-secondary {
    background: var(--bg4);
    color: var(--text);
    border-color: var(--border);
}
.btn-secondary:hover { background: var(--border); }
.btn-danger {
    background: transparent;
    color: var(--red);
    border-color: var(--red);
}
.btn-danger:hover { background: rgba(248,81,73,.12); }
.btn-success {
    background: transparent;
    color: var(--green);
    border-color: var(--green);
}
.btn-success:hover { background: rgba(63,185,80,.12); }
.btn-ghost {
    background: transparent;
    color: var(--text2);
    border-color: transparent;
}
.btn-ghost:hover { background: var(--bg4); color: var(--text); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-block { width: 100%; justify-content: center; }
.btn-group { display: flex; gap: 6px; flex-wrap: wrap; }

/* ── Alerts ── */
.alert {
    padding: 10px 14px;
    border-radius: var(--radius);
    font-size: 13px;
    margin-top: 12px;
}
.alert-error   { background: rgba(248,81,73,.12); border: 1px solid rgba(248,81,73,.4); color: var(--red); }
.alert-success { background: rgba(63,185,80,.12);  border: 1px solid rgba(63,185,80,.4);  color: var(--green); }
.alert-warn    { background: rgba(210,153,34,.12); border: 1px solid rgba(210,153,34,.4); color: var(--yellow); }
.alert-info    { background: rgba(47,129,247,.12); border: 1px solid rgba(47,129,247,.4); color: var(--accent2); }

/* ── Main Layout ── */
#main-app {
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr;
    height: 100vh;
    overflow: hidden;
}

/* ── Sidebar ── */
#sidebar {
    background: var(--bg2);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}
.sidebar-header {
    padding: 20px 16px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    flex-direction: column;
}
.logo-text {
    font-size: 20px;
    font-weight: 700;
    color: var(--accent2);
    letter-spacing: 3px;
}
.logo-sub {
    font-size: 10px;
    color: var(--text3);
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-top: 2px;
}
.nav-links {
    padding: 8px 0;
    flex: 1;
}
.nav-links li a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 16px;
    color: var(--text2);
    font-size: 13px;
    border-radius: 0;
    transition: background var(--transition), color var(--transition);
    border-left: 3px solid transparent;
}
.nav-links li a:hover { background: var(--bg3); color: var(--text); text-decoration: none; }
.nav-links li a.active { background: var(--bg3); color: var(--accent2); border-left-color: var(--accent2); }
.nav-icon { font-size: 13px; width: 16px; text-align: center; }
.sidebar-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--border);
}
.auth-status {
    font-size: 11px;
    color: var(--text3);
    margin-bottom: 8px;
    word-break: break-all;
}

/* ── Content Wrapper ── */
#content-wrapper {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
#top-bar {
    height: var(--topbar-h);
    background: var(--bg2);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    flex-shrink: 0;
}
#top-bar h2 { font-size: 16px; font-weight: 600; }
.top-bar-actions { display: flex; align-items: center; gap: 12px; }
.health-dot {
    width: 10px; height: 10px;
    border-radius: 50%;
    background: var(--text3);
    display: inline-block;
    transition: background var(--transition);
}
.health-dot.ok      { background: var(--green); box-shadow: 0 0 6px var(--green); }
.health-dot.warn    { background: var(--yellow); box-shadow: 0 0 6px var(--yellow); }
.health-dot.error   { background: var(--red);   box-shadow: 0 0 6px var(--red); }
#content {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

/* ── Cards ── */
.card {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow);
}
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}
.card-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}
.card-subtitle { font-size: 12px; color: var(--text2); margin-top: 2px; }

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.stat-card {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 18px;
}
.stat-label {
    font-size: 11px;
    color: var(--text2);
    text-transform: uppercase;
    letter-spacing: .6px;
    margin-bottom: 6px;
}
.stat-value {
    font-size: 26px;
    font-weight: 700;
    color: var(--accent2);
    line-height: 1;
}
.stat-sub {
    font-size: 11px;
    color: var(--text3);
    margin-top: 4px;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}
.section-title { font-size: 16px; font-weight: 600; }

/* ── Tables ── */
.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
}
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
thead { background: var(--bg3); }
th {
    padding: 10px 14px;
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    color: var(--text2);
    text-transform: uppercase;
    letter-spacing: .5px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--bg3); }
.actions-cell { display: flex; gap: 6px; flex-wrap: wrap; }

/* ── Badges / Status ── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .4px;
}
.badge-green   { background: rgba(63,185,80,.15);  color: var(--green); }
.badge-red     { background: rgba(248,81,73,.15);  color: var(--red); }
.badge-yellow  { background: rgba(210,153,34,.15); color: var(--yellow); }
.badge-blue    { background: rgba(47,129,247,.15); color: var(--accent2); }
.badge-purple  { background: rgba(163,113,247,.15);color: var(--purple); }
.badge-gray    { background: rgba(139,148,158,.15);color: var(--text2); }
.badge-cyan    { background: rgba(57,197,207,.15); color: var(--cyan); }

/* ── Pre / Code blocks ── */
.code-block {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    font-family: var(--mono);
    font-size: 12px;
    line-height: 1.6;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 480px;
    overflow-y: auto;
    color: var(--text2);
}

/* ── Tabs ── */
.tab-bar {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 20px;
}
.tab-btn {
    padding: 8px 16px;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text2);
    font-size: 13px;
    cursor: pointer;
    margin-bottom: -1px;
    transition: color var(--transition), border-color var(--transition);
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--accent2); border-bottom-color: var(--accent2); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ── Modal ── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.65);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.modal {
    background: var(--bg2);
    border: 1px solid var(--border2);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    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);
    flex-shrink: 0;
}
.modal-header h3 { font-size: 15px; font-weight: 600; }
.modal-close {
    background: none;
    border: none;
    color: var(--text2);
    font-size: 16px;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: var(--radius);
}
.modal-close:hover { background: var(--bg4); color: var(--text); }
.modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}
.modal-footer {
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    flex-shrink: 0;
}

/* ── Toasts ── */
#toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}
.toast {
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 16px;
    font-size: 13px;
    box-shadow: var(--shadow-lg);
    opacity: 1;
    transition: opacity .4s ease, transform .4s ease;
    max-width: 340px;
    pointer-events: auto;
}
.toast.toast-success { border-left: 3px solid var(--green); }
.toast.toast-error   { border-left: 3px solid var(--red); }
.toast.toast-info    { border-left: 3px solid var(--accent2); }
.toast.toast-warn    { border-left: 3px solid var(--yellow); }
.toast.fade-out { opacity: 0; transform: translateX(20px); }

/* ── Loading ── */
.loading-spinner {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 60px;
    color: var(--text2);
    font-size: 13px;
}
.loading-spinner::before {
    content: '';
    width: 18px; height: 18px;
    border: 2px solid var(--border);
    border-top-color: var(--accent2);
    border-radius: 50%;
    margin-right: 10px;
    animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text2);
}
.empty-state h3 { margin-bottom: 6px; color: var(--text); }

/* ── JSON / Config display ── */
.json-key    { color: var(--accent2); }
.json-str    { color: var(--green); }
.json-num    { color: var(--purple); }
.json-bool   { color: var(--yellow); }
.json-null   { color: var(--text3); }

/* ── Misc ── */
.pill {
    display: inline-block;
    background: var(--bg4);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 2px 10px;
    font-size: 11px;
    color: var(--text2);
}
.divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 20px 0;
}
.health-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}
.health-item {
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.health-item-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.health-item-dot.ok    { background: var(--green); }
.health-item-dot.error { background: var(--red); }
.health-item-label { font-size: 12px; color: var(--text2); }
.health-item-value { font-size: 13px; font-weight: 600; color: var(--text); }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text3); }
