/* =========================================================================
   TRIMAX 3X — Dark Luxury Glass + Gold theme
   Use gold sparingly: numbers, buttons, active nav, icons, headings, borders.
   ========================================================================= */

:root {
  --bg: #08090b;
  --bg-elevated: #0f1013;
  --panel: rgba(255, 255, 255, 0.05);
  --panel-border: rgba(212, 175, 55, 0.20);
  --panel-border-strong: rgba(212, 175, 55, 0.45);
  --gold: #D4AF37;
  --gold-light: #F4D77D;
  --text: #F5F5F0;
  --text-soft: #A9A9AE;
  --text-muted: #6f6f76;
  --danger: #E5484D;
  --warn: #E0A93B;
  --success: #3BC48A;
  --radius: 20px;
  --radius-sm: 12px;
  --sidebar-w: 264px;
}

* { box-sizing: border-box; }

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  margin: 0;
  -webkit-font-smoothing: antialiased;
}

body {
  background-image:
    radial-gradient(circle at 15% 0%, rgba(212, 175, 55, 0.07), transparent 40%),
    radial-gradient(circle at 100% 30%, rgba(212, 175, 55, 0.05), transparent 45%);
  min-height: 100vh;
}

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

h1, h2, h3, h4, h5, h6 { font-weight: 600; letter-spacing: 0.2px; }

.text-gold { color: var(--gold) !important; }
.text-soft { color: var(--text-soft) !important; }
.text-muted-soft { color: var(--text-muted) !important; }

/* ---------- Glass card ---------- */
.glass-card {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-radius: var(--radius);
  box-shadow: 0 15px 45px rgba(0, 0, 0, 0.35);
  transition: border-color .2s ease, transform .2s ease;
}
.glass-card:hover { border-color: var(--panel-border-strong); }
.glass-card.hover-lift:hover { transform: translateY(-2px); }

.glass-panel {
  background: var(--bg-elevated);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
}

/* ---------- Buttons ---------- */
.btn-gold {
  background: linear-gradient(135deg, var(--gold-light), var(--gold));
  border: none;
  color: #1a1305;
  font-weight: 600;
  border-radius: var(--radius-sm);
  padding: 0.65rem 1.4rem;
  transition: filter .15s ease, transform .1s ease;
}
.btn-gold:hover { filter: brightness(1.08); color: #1a1305; }
.btn-gold:active { transform: scale(0.98); }

.btn-outline-gold {
  background: transparent;
  border: 1px solid var(--panel-border-strong);
  color: var(--gold-light);
  border-radius: var(--radius-sm);
  padding: 0.6rem 1.3rem;
}
.btn-outline-gold:hover { background: rgba(212, 175, 55, 0.08); color: var(--gold-light); }

.btn-ghost {
  background: transparent;
  border: none;
  color: var(--text-soft);
}
.btn-ghost:hover { color: var(--text); }

/* ---------- Forms ---------- */
.form-control, .form-select {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.10);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.9rem;
}
.form-control:focus, .form-select:focus {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--panel-border-strong);
  box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.12);
  color: var(--text);
}
.form-control::placeholder { color: var(--text-muted); }
label.form-label { color: var(--text-soft); font-size: 0.85rem; margin-bottom: 0.35rem; }

/* ---------- Badges ---------- */
.badge-gold, .badge-warn, .badge-danger, .badge-muted {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.28rem 0.7rem;
  border-radius: 999px;
  letter-spacing: 0.3px;
}
.badge-gold { background: rgba(212, 175, 55, 0.15); color: var(--gold-light); border: 1px solid rgba(212,175,55,.3); }
.badge-warn { background: rgba(224, 169, 59, 0.15); color: var(--warn); border: 1px solid rgba(224,169,59,.3); }
.badge-danger { background: rgba(229, 72, 77, 0.15); color: var(--danger); border: 1px solid rgba(229,72,77,.3); }
.badge-muted { background: rgba(255, 255, 255, 0.06); color: var(--text-muted); border: 1px solid rgba(255,255,255,.08); }

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

.app-sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--bg-elevated);
  border-right: 1px solid var(--panel-border);
  padding: 1.5rem 1rem;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0 0.5rem 1.25rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--panel-border);
}
.brand .mark {
  width: 38px; height: 38px; border-radius: 10px;
  background: linear-gradient(135deg, var(--gold-light), var(--gold));
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; color: #1a1305;
}
.brand .name { font-weight: 700; font-size: 1.05rem; letter-spacing: 0.5px; }
.brand .sub { font-size: 0.7rem; color: var(--text-muted); }

.nav-side { display: flex; flex-direction: column; gap: 0.2rem; }
.nav-side a {
  display: flex; align-items: center; gap: 0.7rem;
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-sm);
  color: var(--text-soft);
  font-size: 0.9rem;
  font-weight: 500;
}
.nav-side a i, .nav-side a .icon { width: 18px; text-align: center; color: var(--text-muted); }
.nav-side a:hover { background: rgba(255,255,255,0.04); color: var(--text); }
.nav-side a.active {
  background: rgba(212, 175, 55, 0.10);
  color: var(--gold-light);
  border: 1px solid rgba(212, 175, 55, 0.25);
}
.nav-side a.active i, .nav-side a.active .icon { color: var(--gold); }
.nav-side .nav-section-label {
  font-size: 0.68rem; text-transform: uppercase; letter-spacing: 1px;
  color: var(--text-muted); margin: 0.9rem 0.75rem 0.3rem;
}

.app-main { flex: 1; min-width: 0; }

.app-topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--panel-border);
  position: sticky; top: 0; z-index: 20;
  background: rgba(8, 9, 11, 0.85);
  backdrop-filter: blur(12px);
}

.app-content { padding: 1.5rem; max-width: 1400px; margin: 0 auto; }

.sidebar-toggle { display: none; }

/* ---------- Stat tiles ---------- */
.stat-tile { padding: 1.25rem 1.4rem; }
.stat-tile .stat-label { font-size: 0.78rem; color: var(--text-soft); margin-bottom: 0.4rem; }
.stat-tile .stat-value { font-size: 1.6rem; font-weight: 700; color: var(--gold-light); }
.stat-tile .stat-icon {
  width: 42px; height: 42px; border-radius: 12px;
  background: rgba(212, 175, 55, 0.12);
  color: var(--gold);
  display: flex; align-items: center; justify-content: center;
}

/* ---------- Tables ---------- */
.table-glass { width: 100%; border-collapse: separate; border-spacing: 0; }
.table-glass th {
  text-align: left; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--text-muted); padding: 0.75rem 1rem; border-bottom: 1px solid var(--panel-border);
}
.table-glass td { padding: 0.85rem 1rem; border-bottom: 1px solid rgba(255,255,255,0.05); font-size: 0.9rem; }
.table-glass tr:hover td { background: rgba(255,255,255,0.02); }

.table-responsive-wrap { overflow-x: auto; }

/* ---------- Auth pages ---------- */
.auth-shell {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 1.5rem;
}
.auth-card { width: 100%; max-width: 440px; padding: 2.25rem 2rem; }

/* ---------- Progress ---------- */
.progress-gold { height: 10px; border-radius: 999px; background: rgba(255,255,255,0.06); overflow: hidden; }
.progress-gold .bar { height: 100%; background: linear-gradient(90deg, var(--gold), var(--gold-light)); }

/* ---------- Responsive ---------- */
@media (max-width: 991px) {
  .app-sidebar {
    position: fixed; left: 0; top: 0; z-index: 1050;
    transform: translateX(-100%);
    transition: transform .25s ease;
    box-shadow: 20px 0 60px rgba(0,0,0,0.5);
  }
  .app-sidebar.open { transform: translateX(0); }
  .sidebar-toggle { display: inline-flex; }
  .sidebar-backdrop {
    display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.6);
    z-index: 1040;
  }
  .sidebar-backdrop.show { display: block; }
  .app-content { padding: 1rem; }
}

/* ---------- Genealogy tree ---------- */
.tree-toolbar { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.tree-search-box { position: relative; width: 260px; max-width: 100%; }
.tree-search-results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 30;
  background: var(--bg-elevated); border: 1px solid var(--panel-border);
  border-radius: var(--radius-sm); max-height: 260px; overflow-y: auto;
  box-shadow: 0 15px 45px rgba(0,0,0,0.5);
}
.tree-search-results .result-item { padding: 0.55rem 0.8rem; cursor: pointer; font-size: 0.85rem; }
.tree-search-results .result-item:hover { background: rgba(212,175,55,0.08); }
.tree-search-results .result-item .rid { color: var(--gold-light); font-weight: 600; margin-right: 0.4rem; }

.tree-breadcrumb { display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem; font-size: 0.82rem; color: var(--text-soft); margin-bottom: 0.75rem; }
.tree-breadcrumb a { color: var(--text-soft); }
.tree-breadcrumb a:hover { color: var(--gold-light); }
.tree-breadcrumb .sep { color: var(--text-muted); }

.tree-viewport {
  position: relative; overflow: hidden; height: 560px;
  border-radius: var(--radius); border: 1px solid var(--panel-border);
  background: radial-gradient(circle at 50% 0%, rgba(212,175,55,0.05), transparent 60%), var(--bg-elevated);
  cursor: grab;
}
.tree-viewport.grabbing { cursor: grabbing; }
.tree-canvas {
  position: absolute; top: 0; left: 50%;
  padding: 2.5rem 2rem 3rem;
  transform-origin: top center;
  transition: transform .05s linear;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
}
.tree-zoom-controls { position: absolute; right: 14px; bottom: 14px; z-index: 10; display: flex; flex-direction: column; gap: 6px; }
.tree-zoom-controls button {
  width: 36px; height: 36px; border-radius: 10px;
  background: var(--bg-elevated); border: 1px solid var(--panel-border);
  color: var(--gold-light);
}
.tree-zoom-controls button:hover { border-color: var(--panel-border-strong); }

.tree-node-wrap { display: flex; flex-direction: column; align-items: center; }
.tree-node {
  width: 168px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  padding: 0.7rem 0.6rem;
  text-align: center;
  cursor: pointer;
  position: relative;
  transition: border-color .15s ease, transform .1s ease;
}
.tree-node:hover { border-color: var(--panel-border-strong); transform: translateY(-2px); }
.tree-node.is-self { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(212,175,55,0.12); }
.tree-node .avatar {
  width: 40px; height: 40px; border-radius: 50%; margin: 0 auto 0.4rem;
  background: linear-gradient(135deg, var(--gold-light), var(--gold));
  color: #1a1305; font-weight: 700; font-size: 0.85rem;
  display: flex; align-items: center; justify-content: center;
}
.tree-node .n-name { font-size: 0.8rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tree-node .n-id { font-size: 0.7rem; color: var(--gold-light); }
.tree-node .n-status { margin-top: 0.3rem; }
.tree-node .expand-btn {
  position: absolute; bottom: -12px; left: 50%; transform: translateX(-50%);
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--gold); color: #1a1305; border: 2px solid var(--bg-elevated);
  font-size: 0.7rem; display: flex; align-items: center; justify-content: center;
  cursor: pointer; z-index: 5;
}
.tree-node .expand-btn:hover { filter: brightness(1.1); }
.tree-node .slot-badge {
  position: absolute; top: -10px; left: -10px;
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--bg-elevated); border: 1px solid var(--panel-border-strong);
  font-size: 0.65rem; display: flex; align-items: center; justify-content: center;
  color: var(--text-muted);
}

.tree-children { display: flex; justify-content: center; }
.tree-child-branch { position: relative; padding: 34px 14px 0; }
.tree-child-branch::before {
  content: ''; position: absolute; top: 0; left: 50%; width: 0;
  border-left: 1px solid var(--panel-border-strong); height: 22px;
}
.tree-child-branch::after {
  content: ''; position: absolute; top: 22px; height: 0;
  border-top: 1px solid var(--panel-border-strong);
}
.tree-child-branch:only-child::after { display: none; }
.tree-child-branch:first-child:not(:only-child)::after { left: 50%; right: 0; }
.tree-child-branch:last-child:not(:only-child)::after { left: 0; right: 50%; }
.tree-child-branch:not(:first-child):not(:last-child)::after { left: 0; right: 0; }
.tree-child-branch:only-child { padding-top: 22px; }

.detail-row { display: flex; justify-content: space-between; padding: 0.5rem 0; border-bottom: 1px solid rgba(255,255,255,0.05); font-size: 0.88rem; }
.detail-row:last-child { border-bottom: none; }
.detail-row .k { color: var(--text-muted); }

@media (max-width: 576px) {
  .stat-tile .stat-value { font-size: 1.35rem; }
  .auth-card { padding: 1.75rem 1.25rem; }
}
