/* ============================================================
   RBP Panel — Main Stylesheet
   Pure CSS, no framework. Uses CSS custom properties for theming.
   ============================================================ */

:root {
  --bg-base:        #0d1117;
  --bg-surface:     #161b22;
  --bg-elevated:    #1c2128;
  --bg-overlay:     #252b34;
  --border:         #30363d;
  --border-muted:   #21262d;

  --text-primary:   #e6edf3;
  --text-secondary: #8b949e;
  --text-muted:     #6e7681;

  --accent:         #58a6ff;
  --accent-dim:     #1f6feb;
  --success:        #3fb950;
  --warning:        #d29922;
  --danger:         #f85149;
  --info:           #79c0ff;

  --font-sans:      -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --font-mono:      "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  --radius:         6px;
  --radius-lg:      12px;
  --shadow:         0 1px 3px rgba(0,0,0,.4);
  --shadow-lg:      0 8px 24px rgba(0,0,0,.5);

  --nav-width:      240px;
  --header-height:  56px;
}

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

html { font-size: 15px; scroll-behavior: smooth; }

body {
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-sans);
  line-height: 1.6;
  min-height: 100vh;
}

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

/* ---- Layout ---- */

.layout {
  display: grid;
  grid-template-columns: var(--nav-width) 1fr;
  grid-template-rows: var(--header-height) 1fr;
  min-height: 100vh;
}

/* ---- Header ---- */

header.site-header {
  grid-column: 1 / -1;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 100;
}

.site-header .brand {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -.3px;
  display: flex;
  align-items: center;
  gap: .5rem;
}

.site-header .brand .dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent);
  display: inline-block;
}

.header-spacer { flex: 1; }

.header-user {
  display: flex;
  align-items: center;
  gap: .75rem;
  font-size: .875rem;
  color: var(--text-secondary);
}

.avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--accent-dim);
  color: var(--text-primary);
  font-weight: 600;
  display: grid;
  place-items: center;
  font-size: .8rem;
  text-transform: uppercase;
}

/* ---- Sidebar Nav ---- */

nav.sidebar {
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  padding: 1rem 0;
  overflow-y: auto;
  position: sticky;
  top: var(--header-height);
  height: calc(100vh - var(--header-height));
}

.nav-section {
  padding: .25rem 0;
}

.nav-section-label {
  font-size: .7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-muted);
  padding: .5rem 1.25rem .25rem;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .5rem 1.25rem;
  color: var(--text-secondary);
  font-size: .875rem;
  transition: background .12s, color .12s;
  border-radius: 0;
}

.nav-link:hover,
.nav-link.active {
  background: var(--bg-elevated);
  color: var(--text-primary);
  text-decoration: none;
}

.nav-link.active {
  border-left: 2px solid var(--accent);
}

.nav-icon {
  width: 16px;
  text-align: center;
  opacity: .7;
  flex-shrink: 0;
}

/* ---- Main Content ---- */

main.content {
  padding: 2rem;
  overflow-y: auto;
  min-height: calc(100vh - var(--header-height));
}

/* Login page (no sidebar) */
.page-login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: var(--bg-base);
}

/* ---- Page Header ---- */

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  gap: 1rem;
  flex-wrap: wrap;
}

.page-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-primary);
}

.page-subtitle {
  font-size: .875rem;
  color: var(--text-secondary);
  margin-top: .15rem;
}

/* ---- Cards ---- */

.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.card-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
}

.card-title {
  font-size: .9rem;
  font-weight: 600;
}

.card-body {
  padding: 1.25rem;
}

.card-footer {
  padding: .75rem 1.25rem;
  border-top: 1px solid var(--border);
  background: var(--bg-elevated);
}

/* ---- Stats Grid ---- */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
}

.stat-label {
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  margin-bottom: .4rem;
}

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
}

.stat-meta {
  font-size: .8rem;
  color: var(--text-secondary);
  margin-top: .3rem;
}

/* ---- Tables ---- */

.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}

thead {
  background: var(--bg-elevated);
}

th {
  padding: .75rem 1rem;
  text-align: left;
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

td {
  padding: .875rem 1rem;
  border-bottom: 1px solid var(--border-muted);
  vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }

tbody tr:hover { background: var(--bg-elevated); }

/* ---- Badges / Status ---- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  font-size: .7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: .2rem .55rem;
  border-radius: 100px;
}

.badge-success  { background: rgba(63,185,80,.15); color: var(--success); }
.badge-danger   { background: rgba(248,81,73,.15);  color: var(--danger); }
.badge-warning  { background: rgba(210,153,34,.15); color: var(--warning); }
.badge-info     { background: rgba(121,192,255,.12);color: var(--info); }
.badge-muted    { background: var(--bg-elevated);   color: var(--text-muted); }
.badge-accent   { background: rgba(88,166,255,.15); color: var(--accent); }

.status-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}
.status-dot.online   { background: var(--success); box-shadow: 0 0 0 3px rgba(63,185,80,.2); }
.status-dot.offline  { background: var(--text-muted); }
.status-dot.warning  { background: var(--warning); }
.status-dot.error    { background: var(--danger); }

/* ---- Buttons ---- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .45rem 1rem;
  font-size: .875rem;
  font-weight: 500;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  transition: opacity .12s, background .12s, border-color .12s;
  text-decoration: none;
  white-space: nowrap;
  font-family: inherit;
}

.btn:hover { opacity: .88; text-decoration: none; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.btn-primary  { background: var(--accent-dim); color: #fff; border-color: var(--accent-dim); }
.btn-success  { background: #1a6c25; color: #fff; border-color: #1a6c25; }
.btn-danger   { background: #6e1c1a; color: var(--danger); border-color: #6e1c1a; }
.btn-warning  { background: #6c4a00; color: var(--warning); border-color: #6c4a00; }
.btn-ghost    { background: transparent; color: var(--text-secondary); border-color: var(--border); }
.btn-ghost:hover { background: var(--bg-elevated); color: var(--text-primary); }
.btn-sm { padding: .3rem .7rem; font-size: .8rem; }
.btn-icon { padding: .4rem; border-radius: var(--radius); }

/* Power action buttons */
.power-btn-group {
  display: flex;
  gap: .4rem;
}

/* ---- Forms ---- */

.form-group {
  margin-bottom: 1.25rem;
}

label {
  display: block;
  font-size: .8rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: .4rem;
  text-transform: uppercase;
  letter-spacing: .04em;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="url"],
select,
textarea {
  width: 100%;
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  padding: .5rem .75rem;
  font-size: .9rem;
  font-family: inherit;
  transition: border-color .12s, box-shadow .12s;
  outline: none;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(88,166,255,.15);
}

textarea { resize: vertical; min-height: 120px; }
textarea.mono { font-family: var(--font-mono); font-size: .85rem; }

.form-hint {
  font-size: .78rem;
  color: var(--text-muted);
  margin-top: .3rem;
}

.form-error {
  font-size: .78rem;
  color: var(--danger);
  margin-top: .3rem;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

/* ---- Flash Messages ---- */

.flash-container {
  position: fixed;
  top: calc(var(--header-height) + 1rem);
  right: 1rem;
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  max-width: 380px;
}

.flash {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .75rem 1rem;
  font-size: .875rem;
  display: flex;
  align-items: flex-start;
  gap: .6rem;
  box-shadow: var(--shadow-lg);
  animation: slideIn .2s ease;
}

.flash-error   { border-left: 3px solid var(--danger); }
.flash-success { border-left: 3px solid var(--success); }
.flash-warning { border-left: 3px solid var(--warning); }
.flash-info    { border-left: 3px solid var(--info); }

@keyframes slideIn {
  from { transform: translateX(20px); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

.flash-close {
  margin-left: auto;
  cursor: pointer;
  color: var(--text-muted);
  background: none;
  border: none;
  font-size: 1rem;
  line-height: 1;
  flex-shrink: 0;
}

/* ---- Console ---- */

.console-wrap {
  background: #010409;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  height: 60vh;
}

.console-output {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  font-family: var(--font-mono);
  font-size: .83rem;
  line-height: 1.55;
  color: #c9d1d9;
  white-space: pre-wrap;
  word-break: break-all;
}

.console-output .line-err  { color: var(--danger); }
.console-output .line-warn { color: var(--warning); }
.console-output .line-info { color: var(--info); }

.console-input-row {
  display: flex;
  align-items: center;
  border-top: 1px solid var(--border);
  background: #010409;
  padding: .4rem .75rem;
  gap: .5rem;
}

.console-input-row .prompt {
  color: var(--success);
  font-family: var(--font-mono);
  font-size: .85rem;
  user-select: none;
}

.console-input-row input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: .85rem;
  outline: none;
}

/* ---- Resource Bars ---- */

.resource-bar-wrap { margin-bottom: .75rem; }

.resource-bar-label {
  display: flex;
  justify-content: space-between;
  font-size: .78rem;
  color: var(--text-secondary);
  margin-bottom: .3rem;
}

.resource-bar {
  height: 6px;
  background: var(--bg-elevated);
  border-radius: 100px;
  overflow: hidden;
}

.resource-bar-fill {
  height: 100%;
  border-radius: 100px;
  background: var(--accent);
  transition: width .5s ease;
}

.resource-bar-fill.high   { background: var(--danger); }
.resource-bar-fill.medium { background: var(--warning); }

/* ---- Pagination ---- */

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .3rem;
  margin-top: 1.5rem;
  flex-wrap: wrap;
}

.page-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 34px;
  padding: 0 .6rem;
  border-radius: var(--radius);
  font-size: .85rem;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  transition: background .12s, color .12s;
}

.page-link:hover { background: var(--bg-elevated); color: var(--text-primary); text-decoration: none; }
.page-link.active { background: var(--accent-dim); color: #fff; border-color: transparent; }
.page-link.disabled { opacity: .4; pointer-events: none; }

/* ---- Code blocks ---- */

code {
  font-family: var(--font-mono);
  font-size: .85em;
  background: var(--bg-elevated);
  padding: .1em .35em;
  border-radius: 3px;
  color: var(--info);
}

pre {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: .85rem;
}

/* ---- Modal ---- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  z-index: 200;
  display: grid;
  place-items: center;
  backdrop-filter: blur(4px);
}

.modal {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  max-width: 480px;
  width: 90%;
  box-shadow: var(--shadow-lg);
  animation: modalIn .18s ease;
}

@keyframes modalIn {
  from { transform: scale(.96); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}

.modal-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

.modal-actions {
  display: flex;
  gap: .5rem;
  justify-content: flex-end;
  margin-top: 1.25rem;
}

/* ---- Utility ---- */

.flex        { display: flex; }
.flex-wrap   { flex-wrap: wrap; }
.items-center{ align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: .5rem; }
.gap-2 { gap: 1rem; }
.mt-1  { margin-top: .5rem; }
.mt-2  { margin-top: 1rem; }
.mb-2  { margin-bottom: 1rem; }
.text-muted   { color: var(--text-muted); }
.text-danger  { color: var(--danger); }
.text-success { color: var(--success); }
.text-sm { font-size: .85rem; }
.font-mono { font-family: var(--font-mono); }
.w-full { width: 100%; }
.hidden { display: none !important; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3,1fr); gap: 1rem; }
