/* Relight Portal - Brand Palette & UI */

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

:root {
  /* Brand */
  --amber:          #f59e0b;
  --amber-light:    #fbbf24;
  --amber-glow:     rgba(245, 158, 11, 0.12);
  --amber-dim:      rgba(245, 158, 11, 0.06);

  /* Backgrounds */
  --bg-deep:        #0a1628;
  --bg-surface:     #0f1d32;
  --bg-elevated:    #15263e;
  --bg-terminal:    #081322;
  --bg-hover:       #1a2d4a;

  /* Text */
  --text-primary:   #e1e7ef;
  --text-secondary: #94a3b8;
  --text-muted:     #475569;

  /* Borders */
  --border:         #1e3048;
  --border-light:   #2a3f5c;

  /* Semantic */
  --green:          #4ade80;
  --green-dim:      rgba(74, 222, 128, 0.15);
  --red:            #ef4444;
  --red-dim:        rgba(239, 68, 68, 0.15);
  --yellow:         #fde68a;
  --sky:            #7dd3fc;
  --purple:         #a855f7;

  /* Layout */
  --sidebar-width:  220px;
  --content-max:    1100px;
  --radius:         8px;
  --radius-sm:      4px;
}

/* === Typography === */
body {
  font-family: 'DM Sans', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--bg-deep);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  font-family: 'Source Serif 4', Georgia, serif;
  font-weight: 600;
  line-height: 1.3;
}

h1 { font-size: 24px; }
h2 { font-size: 18px; }
h3 { font-size: 15px; color: var(--text-secondary); font-weight: 500; }

code, .mono {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
}

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

/* === Ambient Glow === */
body::before {
  content: '';
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 500px;
  background: radial-gradient(
    ellipse 80% 50% at 50% -10%,
    var(--amber-glow) 0%, transparent 60%
  );
  pointer-events: none;
  z-index: 0;
}

/* === Layout: Sidebar + Main === */
.layout {
  display: flex;
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-deep);
  border-right: 1px solid var(--border);
  padding: 20px 0;
  position: fixed;
  top: 0; bottom: 0; left: 0;
  display: flex;
  flex-direction: column;
  z-index: 10;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 20px 24px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}

.sidebar-logo svg { flex-shrink: 0; }

.sidebar-logo span {
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}

.sidebar nav { flex: 1; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 20px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  border-left: 3px solid transparent;
  transition: all 0.15s;
}

.nav-item:hover {
  color: var(--text-secondary);
  background: var(--amber-dim);
}

.nav-item.active {
  color: var(--text-primary);
  border-left-color: var(--amber);
  background: var(--amber-dim);
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  margin-top: auto;
}

.sidebar-user {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-logout {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
  display: inline-block;
}
.sidebar-logout:hover { color: var(--red); }

.main {
  margin-left: var(--sidebar-width);
  flex: 1;
  padding: 32px 40px;
  background: var(--bg-surface);
  min-height: 100vh;
}

.main-inner {
  max-width: var(--content-max);
}

/* === Page Header === */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
}

.page-header h1 { margin: 0; }

.page-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* === Cards === */
.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
}

.card-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 28px;
}

.summary-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
}

.summary-card .value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 28px;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1;
}

.summary-card .label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* === Status Dot === */
.dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.dot-green   { background: var(--green); }
.dot-amber   { background: var(--amber); }
.dot-red     { background: var(--red); }
.dot-muted   { background: var(--text-muted); }
.dot-sky     { background: var(--sky); }
.dot-purple  { background: var(--purple); }

.dot-pulse {
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* === Tables === */
.table-wrap {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

table {
  width: 100%;
  border-collapse: collapse;
}

table th {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  text-align: left;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface);
}

table td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  vertical-align: middle;
}

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

table tr.clickable { cursor: pointer; }
table tr.clickable:hover td { background: var(--bg-hover); }

/* Row with left-border accent */
table tr.row-green td:first-child { box-shadow: inset 3px 0 0 var(--green); }
table tr.row-red td:first-child { box-shadow: inset 3px 0 0 var(--red); }
table tr.row-amber td:first-child { box-shadow: inset 3px 0 0 var(--amber); }
table tr.row-muted td:first-child { box-shadow: inset 3px 0 0 var(--text-muted); }

/* Detail row (expandable) */
.detail-row td { padding: 0; }
.detail-row:empty { display: none; }

.detail-content {
  padding: 16px 20px;
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
}

/* === App List Item (two-line row) === */
.app-row-main {
  display: flex;
  align-items: center;
  gap: 10px;
}

.app-name {
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
}

.app-meta {
  font-size: 12px;
  color: var(--text-muted);
  padding-left: 17px; /* align with name (dot width + gap) */
  display: flex;
  gap: 16px;
}

/* === Tabs === */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}

.tab {
  padding: 10px 20px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all 0.15s;
}

.tab:hover { color: var(--text-secondary); }

.tab.active {
  color: var(--amber);
  border-bottom-color: var(--amber);
}

/* === Key-Value Pairs === */
.kv-grid {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 8px 20px;
  margin-bottom: 24px;
}

.kv-label {
  font-size: 13px;
  color: var(--text-muted);
  padding: 4px 0;
}

.kv-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  color: var(--text-primary);
  padding: 4px 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* === Terminal === */
.terminal {
  background: var(--bg-terminal);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  line-height: 1.7;
  overflow-x: auto;
  color: var(--text-secondary);
}

.terminal .cmd { color: var(--text-primary); }
.terminal .ok  { color: var(--green); }
.terminal .err { color: var(--red); }
.terminal .dim { color: var(--text-muted); }

/* === Buttons === */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.15s;
}

.btn:hover {
  background: var(--bg-hover);
  border-color: var(--border-light);
}

.btn-primary {
  background: var(--amber);
  color: #0a1628;
  border-color: var(--amber);
  font-weight: 600;
}

.btn-primary:hover {
  background: var(--amber-light);
  border-color: var(--amber-light);
}

.btn-sm {
  padding: 4px 10px;
  font-size: 12px;
}

/* === Forms === */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-input {
  width: 100%;
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  background: var(--bg-deep);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color 0.15s;
}

.form-input:focus {
  border-color: var(--amber);
}

.form-input::placeholder {
  color: var(--text-muted);
}

/* === Auth Layout === */
.auth-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

.auth-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 36px 32px;
  width: 100%;
  max-width: 380px;
}

.auth-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 28px;
}

.auth-logo svg { margin-bottom: 16px; }

.auth-logo h1 {
  font-size: 20px;
  text-align: center;
}

.auth-footer {
  text-align: center;
  margin-top: 20px;
  font-size: 13px;
  color: var(--text-muted);
}

/* === Badges === */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 500;
  border-radius: 10px;
  font-family: 'JetBrains Mono', monospace;
}

.badge-green  { background: var(--green-dim); color: var(--green); }
.badge-red    { background: var(--red-dim); color: var(--red); }
.badge-amber  { background: var(--amber-dim); color: var(--amber); }
.badge-muted  { background: var(--bg-surface); color: var(--text-muted); }

/* === Timeline === */
.timeline {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  line-height: 2;
}

.timeline-row {
  display: flex;
  gap: 16px;
}

.timeline-time { color: var(--text-muted); min-width: 60px; }
.timeline-event { color: var(--text-secondary); min-width: 180px; }
.timeline-detail { color: var(--text-muted); }

/* === Section Headers === */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.section-header h3 { margin: 0; }

/* === Utilities === */
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-green { color: var(--green); }
.text-red { color: var(--red); }
.text-amber { color: var(--amber); }
.text-right { text-align: right; }
.text-sm { font-size: 12px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.gap-2 { gap: 8px; }
.flex { display: flex; }
.items-center { align-items: center; }
.hidden { display: none; }
