/*
  KerpowerCube Dashboard Styles
  - Global theme tokens (CSS variables), including club-brand overrides applied at runtime
  - Layout and component styles for login, dashboard, profile, charts, and modals
  - Utility/animation rules used by app.js state transitions and live gauge effects
*/
:root {
  --bg: #0f1218;
  --bg-soft: #171b23;
  --bg-deep: #0a0d12;
  --card: rgba(25, 30, 40, 0.9);
  --card-border: rgba(255, 255, 255, 0.08);
  --surface-soft: rgba(255, 255, 255, 0.04);
  --surface-strong: rgba(255, 255, 255, 0.08);
  --frame: rgba(255, 255, 255, 0.1);
  --frame-strong: rgba(255, 255, 255, 0.22);
  --input-bg: rgba(10, 12, 18, 0.78);
  --input-text: #f7f7f5;
  --input-muted: #c9d2e3;
  --accent: #f5c46a;
  --accent-2: #7dd3c7;
  --accent-3: #e4875f;
  --text: #f3f3f2;
  --muted: #a5afc1;
  --shadow: 0 30px 60px rgba(0, 0, 0, 0.35);
  --bg-overlay-1: rgba(0, 0, 0, 0.28);
  --bg-overlay-2: rgba(0, 0, 0, 0.28);
}

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

[hidden] {
  display: none !important;
}

body {
  font-family: "Space Grotesk", sans-serif;
  background: linear-gradient(var(--bg-overlay-1), var(--bg-overlay-2)),
    url('https://kerpowsports.com/KerpowCube/bg.jpg') center / cover no-repeat fixed;
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

h1, h2 {
  font-family: "Fraunces", serif;
  letter-spacing: 0.5px;
}

h1 {
  font-size: 2.6rem;
  margin-bottom: 0.75rem;
}

p {
  color: var(--muted);
  line-height: 1.6;
}

.bg-orb {
  position: fixed;
  width: 420px;
  height: 420px;
  border-radius: 50%;
  filter: blur(40px);
  opacity: 0.18;
  z-index: 0;
  animation: float 16s ease-in-out infinite;
}

.orb-1 {
  top: -80px;
  left: -120px;
  background: radial-gradient(circle, rgba(245, 196, 106, 0.9), transparent 60%);
}

.orb-2 {
  bottom: -140px;
  right: -120px;
  background: radial-gradient(circle, rgba(125, 211, 199, 0.9), transparent 60%);
  animation-delay: 4s;
}

.grid-overlay {
  position: fixed;
  inset: 0;
  background-image: linear-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.04) 1px, transparent 1px);
  background-size: 80px 80px;
  opacity: 0.08;
  pointer-events: none;
  z-index: 0;
}

.topbar {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.35rem 2.5vw;
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(14px);
  z-index: 2;
}

.brand {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.logo {
  width: 48px;
  height: 48px;
  object-fit: contain;
  border-radius: 8px;
  background: transparent;
  display: block;
}

.brand-title {
  font-weight: 600;
  font-size: 0.95rem;
}

.brand-sub {
  font-size: 0.75rem;
  color: var(--muted);
}

.status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--muted);
  font-size: 0.8rem;
  flex-wrap: wrap;
}

.topbar-chip {
  margin-left: auto;
  margin-right: 1rem;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #6ad86a;
  box-shadow: 0 0 10px #6ad86a;
}

.debug-badge {
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 140, 102, 0.8);
  background: rgba(255, 109, 58, 0.2);
  color: #ffd8cc;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  line-height: 1;
}

.container {
  padding: 0.75rem 2.5vw 1.5rem;
  display: grid;
  gap: 0.7rem;
  position: relative;
  z-index: 1;
}

.panel {
  background: rgba(0, 0, 0, 0.08);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 0.8rem;
  box-shadow: var(--shadow);
  animation: fadeUp 0.6s ease both;
  backdrop-filter: blur(2px);
}

.welcome-hero {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  align-items: center;
}

.panel-actions {
  background: rgba(255, 255, 255, 0.01);
  border-radius: 10px;
  padding: 0.7rem;
  border: 1px solid var(--frame);
}

.welcome-switch {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.6rem;
}

.welcome-switch .btn.active {
  background: var(--surface-strong);
  border: 1px solid var(--frame-strong);
}

.input-stack label,
.capture-details label {
  color: var(--muted);
  font-size: 0.85rem;
  margin-bottom: 0.35rem;
  display: block;
}

.input-row {
  display: flex;
  gap: 0.5rem;
}

input, select, textarea {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border-radius: 10px;
  border: 1px solid var(--frame);
  background: var(--input-bg);
  color: var(--input-text);
  -webkit-text-fill-color: var(--input-text);
  caret-color: var(--input-text);
  font-size: 1rem;
}

input::placeholder,
textarea::placeholder {
  color: var(--input-muted);
  opacity: 0.22;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--frame-strong);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.08);
}

select option {
  background: var(--input-bg);
  color: var(--input-text);
}

/* Force autofill text/background to follow dynamic theme vars */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
textarea:-webkit-autofill,
textarea:-webkit-autofill:hover,
textarea:-webkit-autofill:focus,
select:-webkit-autofill,
select:-webkit-autofill:hover,
select:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--input-text);
  box-shadow: 0 0 0 1000px var(--input-bg) inset;
  transition: background-color 9999s ease-out 0s;
}

.color-input {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.color-input input[type="color"] {
  width: 44px;
  padding: 0;
  border-radius: 8px;
  background: transparent;
}

.color-value {
  font-size: 0.85rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.btn {
  border: none;
  padding: 0.55rem 1rem;
  border-radius: 999px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-3));
  color: #1a1206;
  box-shadow: 0 18px 30px rgba(245, 196, 106, 0.25);
}

.btn.ghost {
  background: var(--surface-soft);
  color: var(--text);
}

.btn.outline {
  background: transparent;
  border: 1px solid var(--frame);
  color: var(--text);
}

.btn.danger {
  background: linear-gradient(135deg, #d14f4f, #9c2020);
  color: #fff5f5;
  box-shadow: 0 12px 24px rgba(209, 79, 79, 0.35);
}

.btn:hover:not(:disabled) {
  transform: translateY(-2px);
}

.topbar-link {
  padding: 0.45rem 0.9rem;
  font-size: 0.75rem;
  text-decoration: none;
}

.topbar-link.active {
  background: linear-gradient(135deg, var(--accent), var(--accent-3));
  color: #1a1206;
  border-color: transparent;
}

.hint {
  margin-top: 0.75rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.payment-warning {
  color: #ffd27a;
  font-weight: 600;
}

.master-temp-password {
  margin-top: 0.85rem;
  padding: 0.8rem 0.9rem;
  border-radius: 10px;
  border: 1px solid rgba(106, 216, 106, 0.4);
  background: rgba(40, 100, 46, 0.22);
  color: #d8ffd8;
  font-size: 0.9rem;
  line-height: 1.45;
}

.master-temp-password strong {
  color: #ffffff;
}

.cube-device-alert {
  margin-top: 0.75rem;
  padding: 0.65rem 0.8rem;
  border-radius: 10px;
  border: 1px solid rgba(235, 87, 87, 0.55);
  background: rgba(122, 20, 20, 0.28);
  color: #ffd8d8;
  font-size: 0.9rem;
  font-weight: 600;
}

.hidden {
  display: none;
}

.hidden-control {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.identity-card {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: 120px 1fr;
  align-items: center;
}

.user-list {
  display: grid;
  gap: 0.6rem;
  margin-top: 0.5rem;
}

.user-list-item {
  display: grid;
  grid-template-columns: 64px 1fr auto;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem;
  border-radius: 12px;
  border: 1px solid var(--frame);
  background: rgba(0, 0, 0, 0.06);
}

.user-list-item.no-avatar {
  grid-template-columns: 1fr auto;
}

.user-list-item img {
  width: 64px;
  height: 64px;
  border-radius: 12px;
  object-fit: cover;
  background: var(--surface-strong);
}

.user-list-meta {
  font-size: 0.85rem;
  color: var(--muted);
}

.identity-card img {
  width: 120px;
  height: 120px;
  border-radius: 16px;
  object-fit: cover;
  border: 2px solid var(--frame);
  background: var(--surface-strong);
}

.button-row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.5rem;
}

.exhibition-panel {
  margin: 0.85rem 0 0.7rem;
  padding: 0.85rem;
  border-radius: 14px;
  border: 1px solid var(--frame);
  background: rgba(0, 0, 0, 0.08);
}

.exhibition-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
}

.exhibition-panel-header h3 {
  margin: 0;
  font-size: 1rem;
}

.exhibition-panel-header .muted {
  margin: 0.25rem 0 0;
}

.exhibition-panel-actions {
  margin-top: 0;
}

.toggle-inline {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.45rem 0.65rem;
  border-radius: 999px;
  border: 1px solid var(--frame);
  background: var(--surface-soft);
  white-space: nowrap;
  font-size: 0.9rem;
}

.toggle-inline input {
  margin: 0;
}

.exhibition-controls {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(180px, 1fr) repeat(4, auto);
  gap: 0.5rem;
  align-items: center;
  margin-top: 0.65rem;
}

.exhibition-controls input {
  min-width: 0;
}

@media (max-width: 980px) {
  .exhibition-controls {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .exhibition-panel-header {
    flex-direction: column;
    align-items: stretch;
  }

  .toggle-inline {
    width: fit-content;
  }
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.6rem;
}

.cube-header-row {
  justify-content: flex-start;
  margin-bottom: 0.3rem;
}

.capture-grid,
.test-grid {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.cube-panel {
  overflow: hidden;
}

.cube-layout {
  display: grid;
  gap: 0.8rem;
  grid-template-columns: minmax(0, 1fr);
}

.cube-display {
  position: relative;
  padding: 0.6rem;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.08);
  border: 1px solid var(--frame);
  box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.35);
  overflow: hidden;
}

.cube-hit-flash {
  position: absolute;
  inset: 0;
  background: rgba(0, 255, 0, 0.22);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
  z-index: 1;
}

.cube-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 0.6rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--frame);
  position: relative;
  z-index: 2;
}

.cube-field {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.cube-label {
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.65rem;
  color: var(--muted);
}

.cube-value {
  font-size: 1rem;
  font-weight: 600;
}

.cube-value select {
  width: 100%;
  padding: 0.45rem 0.6rem;
  border-radius: 10px;
  font-size: 0.9rem;
}

.cube-controls {
  display: flex;
  gap: 0.45rem;
  align-items: center;
  align-self: end;
  justify-self: end;
}

.cube-gauges {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.9rem;
  padding: 0.3rem 0 0.6rem;
  position: relative;
  z-index: 2;
}

.cube-gauge {
  flex: 1 1 0;
  text-align: center;
}

.cube-gauge svg {
  width: 100%;
  max-width: 100%;
  height: auto;
}

.dial-value {
  font-size: 2.1rem;
  font-weight: 700;
  margin-top: -0.35rem;
}

.cube-gauge.hf .dial-value {
  font-size: 2.3rem;
}

.dial-label {
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin-top: 0.25rem;
}

.cube-metrics {
  display: grid;
  gap: 0.6rem;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  position: relative;
  z-index: 2;
}

.hf-pulse {
  filter: drop-shadow(0 0 12px rgba(255, 51, 204, 0.7));
  transform: scale(1.05);
  transition: transform 0.15s ease, filter 0.15s ease;
}

.capture-box {
  display: grid;
  gap: 0.75rem;
}

.capture-frame {
  position: relative;
}

.profile-grid {
  display: grid;
  gap: 0.9rem;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  margin: 1rem 0;
}

.history-card {
  margin-top: 1.5rem;
  padding: 1rem;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.08);
  border: 1px solid var(--frame);
}

.history-card h3 {
  font-family: "Fraunces", serif;
  margin-bottom: 0.75rem;
}

.history-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.history-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.history-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: minmax(0, 1fr) minmax(0, 0.85fr);
}

.history-table-wrap {
  position: relative;
  max-height: 22.5rem;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 0.2rem;
}

.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
  table-layout: fixed;
}

.history-table thead th {
  text-align: left;
  padding: 0.6rem 1rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.history-table thead th:nth-child(1) { width: 26%; }
.history-table thead th:nth-child(2) { width: 28%; }
.history-table thead th:nth-child(3) { width: 24%; }
.history-table thead th:nth-child(4) { width: 22%; }

.history-table tbody td {
  padding: 0.45rem 0.8rem;
  border-bottom: none;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
  vertical-align: middle;
}

.history-table tbody td:nth-child(1),
.history-table tbody td:nth-child(4) {
  white-space: nowrap;
}

.history-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.025);
}

.filter-btn {
  background: transparent;
  border: none;
  padding: 0;
  color: var(--muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  cursor: pointer;
}

.filter-btn:hover {
  color: var(--text);
}

.filter-btn.active {
  color: var(--accent);
}

.filter-btn.active::after {
  content: "•";
  margin-left: 0.35rem;
  font-size: 0.9rem;
}

.history-list {
  display: table-row-group;
}

.history-item {
  display: table-row;
}

.history-meta {
  color: var(--muted);
  font-size: 0.85rem;
}

.filter-modal {
  position: fixed;
  inset: 0;
  background: rgba(5, 7, 10, 0.6);
  display: grid;
  place-items: center;
  z-index: 10;
}

.filter-modal.hidden {
  display: none;
}

.filter-modal.anchored {
  background: transparent;
  display: block;
}

.filter-modal-card {
  width: min(420px, 92vw);
  background: rgba(12, 15, 20, 0.98);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 18px;
  padding: 1.1rem;
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.45);
  display: grid;
  gap: 1rem;
}

.filter-modal.anchored .filter-modal-card {
  position: fixed;
  z-index: 20;
}

.filter-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.filter-modal-actions {
  display: flex;
  justify-content: flex-end;
}

.filter-field label {
  display: block;
  margin-bottom: 0.4rem;
  color: var(--muted);
  font-size: 0.8rem;
}

.filter-modal input,
.filter-modal select {
  padding: 0.6rem 0.75rem;
  font-size: 0.95rem;
}

.app-dialog-card {
  width: min(460px, 92vw);
}

.app-dialog-body {
  display: grid;
  gap: 0.7rem;
}

.app-dialog-message {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.app-dialog-input-wrap label {
  display: block;
  margin-bottom: 0.4rem;
  color: var(--muted);
  font-size: 0.8rem;
}

.app-dialog-actions {
  gap: 0.6rem;
}

.history-chart {
  background: rgba(0, 0, 0, 0.08);
  border-radius: 12px;
  padding: 0.65rem;
  border: 1px solid var(--frame);
  min-height: 280px;
  cursor: zoom-in;
}

.chart-fullscreen-active {
  overflow: hidden;
}

.chart-modal {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: rgba(5, 7, 10, 0.9);
  display: grid;
  place-items: center;
  padding: 1rem;
  box-sizing: border-box;
}

.chart-modal.hidden {
  display: none;
}

.chart-modal-panel {
  width: min(1400px, calc(100vw - 2rem));
  height: calc(100dvh - 2rem);
  background: rgba(10, 13, 18, 0.98);
  border: 1px solid var(--frame);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 0.85rem;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 0.65rem;
}

.chart-modal-close {
  justify-self: end;
}

.chart-modal-canvas {
  width: 100% !important;
  height: 100% !important;
}

.leaderboard-card {
  margin-top: 0.75rem;
  padding-top: 0.7rem;
  border-top: 1px solid var(--frame);
  display: grid;
  gap: 0.65rem;
}

.leaderboard-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
}

.leaderboard-header h3 {
  font-family: "Fraunces", serif;
  font-size: 1.1rem;
}

.leaderboard-filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.6rem;
}

.leaderboard-filters label {
  display: block;
  margin-bottom: 0.3rem;
  color: var(--muted);
  font-size: 0.8rem;
}

.leaderboard-top {
  font-size: 0.92rem;
  padding: 0.55rem 0.7rem;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--frame);
}

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

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

.leaderboard-table th,
.leaderboard-table td {
  padding: 0.55rem 0.65rem;
  text-align: left;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  white-space: nowrap;
}

.leaderboard-table th {
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

#userName,
#chipName {
  cursor: pointer;
}

#userName:hover,
#chipName:hover {
  text-decoration: underline;
}

#camera,
#snapshot {
  width: 100%;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--frame);
}

#snapshot {
  display: none;
  position: absolute;
  inset: 0;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
}

.user-chip img {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  object-fit: cover;
}

.metrics {
  display: grid;
  gap: 0.6rem;
  margin-top: 0.8rem;
}

.add-technique {
  display: flex;
  gap: 0.75rem;
  margin-top: 0.75rem;
}

.add-technique input {
  flex: 1;
}

.metric {
  padding: 0.6rem;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.06);
  border: 1px solid var(--frame);
}

.metric-label {
  font-size: 0.85rem;
  color: var(--muted);
}

.metric-value {
  font-size: 1.35rem;
  margin-top: 0.2rem;
}

.chart-card {
  background: rgba(6, 8, 12, 0.6);
  border-radius: 16px;
  padding: 1.1rem;
  border: 1px solid var(--frame);
  min-height: 320px;
}

.muted {
  color: var(--muted);
}

@keyframes float {
  0%, 100% { transform: translateY(0px); }
  50% { transform: translateY(20px); }
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 720px) {
  .topbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }

  h1 { font-size: 2.1rem; }
  .identity-card { grid-template-columns: 1fr; }
  .panel-header { flex-direction: column; align-items: flex-start; }
  .history-grid { grid-template-columns: 1fr; }
  .history-actions { justify-content: flex-start; }
  .cube-layout { grid-template-columns: 1fr; }
  .cube-header { grid-template-columns: 1fr; align-items: stretch; }
  .cube-controls { justify-content: flex-start; justify-self: start; align-self: start; }
  .cube-gauges { flex-direction: column; }
  .cube-metrics { grid-template-columns: 1fr; }
  .topbar-chip { margin-left: 0; margin-right: 0; }
}
