/* ============================================================
   Bet Assist Hub — Shared Component Classes
   Semantic shell classes consumed by both Django template
   partials and React component adapters. Each class uses
   tokens from theme.css so a single edit propagates everywhere.

   Color vars use Tailwind v4 convention: var(--color-*)
   Non-Tailwind vars keep the --bah- prefix.
   Opacity: color-mix() replaces the old RGB-triplet hack.
   ============================================================ */

/* ── Kinetic Gradient ──────────────────────────────────────── */
.bah-kinetic-gradient {
  background-image: var(--bah-gradient-kinetic);
}

.bah-kinetic-text-gradient {
  background-image: var(--bah-gradient-kinetic);
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* ── Material Symbols baseline ─────────────────────────────── */
.bah-icon {
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
}

.bah-tooltip-icon {
  font-size: 14px;
  line-height: 1;
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 14;
}

/* ── Number Input Spinner Reset ────────────────────────────── */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input[type="number"] {
  appearance: textfield;
  -moz-appearance: textfield;
}

/* ── Glass Panel ───────────────────────────────────────────── */
.bah-glass-panel {
  background: rgba(37, 37, 48, 0.7);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

/* ── Card ──────────────────────────────────────────────────── */
.bah-card {
  background-color: var(--color-surface-container-low);
  border-radius: var(--radius-xl);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.bah-card-header {
  padding: 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  background-color: var(--color-surface-container);
}

.bah-card-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.bah-card-title {
  font-family: var(--font-headline);
  font-size: 1.125rem;
  font-weight: 700;
  color: #ffffff;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.bah-card-title-icon {
  color: var(--color-primary);
}

.bah-card-action {
  font-family: var(--font-headline);
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--color-primary);
}

.bah-card-action:hover {
  text-decoration: underline;
}

.bah-card-body {
  padding: 1.5rem;
}

/* ── Sidebar Shell ─────────────────────────────────────────── */
.bah-sidebar {
  display: flex;
  position: fixed;
  left: 0;
  top: 0;
  height: 100vh;
  width: var(--bah-sidebar-width);
  flex-direction: column;
  background-color: var(--color-surface-container-low);
  border-right: 1px solid color-mix(in srgb, var(--color-outline-variant) 20%, transparent);
  padding-top: 1.5rem;
  padding-bottom: 1.5rem;
  box-shadow: var(--bah-shadow-sidebar);
  z-index: 40;
  transition: width var(--bah-transition-sidebar);
}

.bah-sidebar-top {
  padding-left: 1.5rem;
  padding-right: 1.5rem;
  margin-bottom: 2rem;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.bah-sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  overflow: hidden;
}

.bah-sidebar-brand-logo {
  width: 3rem;
  height: 3rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.bah-sidebar-brand-logo img {
  width: 2.5rem;
  height: 2.5rem;
}

.bah-sidebar-brand-copy {
  white-space: nowrap;
}

.bah-sidebar-brand-title {
  font-family: var(--font-headline);
  font-weight: 700;
  color: #ffffff;
  font-size: 1.125rem;
  line-height: 1;
}

.bah-sidebar-brand-subtitle {
  color: var(--color-primary);
  font-size: 0.625rem;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  margin-top: 0.25rem;
}

/* ── Sidebar Toggle ────────────────────────────────────────── */
.bah-sidebar-toggle {
  width: 2rem;
  height: 2rem;
  border: 1px solid color-mix(in srgb, var(--color-outline-variant) 35%, transparent);
  border-radius: var(--radius-lg);
  background: var(--color-surface-container);
  color: var(--color-on-surface-variant);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s, color 0.2s, border-color 0.2s;
  flex-shrink: 0;
  cursor: pointer;
}

.bah-sidebar-toggle:hover {
  background: var(--color-surface-container-high);
  color: var(--color-on-surface);
  border-color: color-mix(in srgb, var(--color-primary) 35%, transparent);
}

/* ── Sidebar User Info ─────────────────────────────────────── */
.bah-sidebar-user {
  padding-left: 1.5rem;
  padding-right: 1.5rem;
  margin-bottom: 2rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.bah-sidebar-user-name {
  font-family: var(--font-headline);
  font-weight: 700;
  font-size: 0.875rem;
  color: #ffffff;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bah-sidebar-user-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 3rem;
  height: 0.5rem;
  margin-top: 0.35rem;
  border-radius: 999px;
  background: var(--color-tertiary-container);
  flex-shrink: 0;
}

.bah-sidebar-user-meta {
  font-size: 0.625rem;
  color: var(--color-on-surface-variant);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Sidebar Nav ───────────────────────────────────────────── */
.bah-sidebar-nav {
  flex: 1;
  padding-left: 1rem;
  padding-right: 1rem;
}

.bah-sidebar-nav-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem 0.75rem;
  border-radius: var(--radius-lg);
  font-family: var(--font-label);
  font-size: 0.875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  transition: color 0.15s, background-color 0.15s;
  text-decoration: none;
  border: none;
  background: transparent;
  cursor: pointer;
}

.bah-sidebar-nav-item--active {
  background-color: color-mix(in srgb, var(--color-primary) 10%, transparent);
  color: var(--color-primary);
}

.bah-sidebar-nav-item--inactive {
  color: #94a3b8; /* slate-400 */
}

.bah-sidebar-nav-item--inactive:hover {
  color: #ffffff;
  background-color: var(--color-surface-container-high);
}

/* ── Sidebar Footer ────────────────────────────────────────── */
.bah-sidebar-footer {
  padding-left: 1rem;
  padding-right: 1rem;
  padding-top: 1.5rem;
  margin-top: auto;
  border-top: 1px solid color-mix(in srgb, var(--color-outline-variant) 15%, transparent);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* ── Sidebar Label (hideable for collapse) ─────────────────── */
/* default shown; hidden when collapsed via runtime class */

/* ── Sidebar always-collapsed on mobile ───────────────────── */
@media (max-width: 767px) {
  .bah-sidebar {
    width: var(--bah-sidebar-collapsed-width);
  }
  .bah-sidebar-brand,
  .bah-sidebar-user {
    display: none;
  }
  .bah-sidebar-top {
    justify-content: center;
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }
  .bah-sidebar-nav-item {
    justify-content: center;
    padding-left: 0.75rem;
    padding-right: 0.75rem;
    gap: 0;
  }
  .bah-sidebar-label {
    display: none;
  }
  .bah-sidebar-desktop-only {
    display: none !important;
  }
  .bah-mobile-hidden {
    display: none !important;
  }
}

/* ── Sidebar Collapse State ────────────────────────────────── */
.bah-sidebar-collapsed .bah-sidebar {
  width: var(--bah-sidebar-collapsed-width);
}

.bah-sidebar-collapsed .bah-sidebar-brand,
.bah-sidebar-collapsed .bah-sidebar-user {
  display: none;
}

.bah-sidebar-collapsed .bah-sidebar-top {
  justify-content: center;
  padding-left: 0.75rem;
  padding-right: 0.75rem;
}

.bah-sidebar-collapsed .bah-sidebar-nav-item {
  justify-content: center;
  padding-left: 0.75rem;
  padding-right: 0.75rem;
  gap: 0;
}

.bah-sidebar-collapsed .bah-sidebar-label {
  display: none;
}

/* ── Main Content Area ─────────────────────────────────────── */
.bah-main {
  min-height: 100vh;
  margin-left: var(--bah-sidebar-collapsed-width);
  padding: 1.5rem;
  background-color: var(--color-surface);
  transition: margin-left var(--bah-transition-sidebar);
}

.bah-sidebar-collapsed .bah-main {
  margin-left: var(--bah-sidebar-collapsed-width);
}

@media (min-width: 768px) {
  .bah-main {
    margin-left: var(--bah-sidebar-width);
    padding: 2.5rem;
  }
}

/* ── Auth Surface (login panel) ────────────────────────────── */
.bah-auth-panel {
  background: color-mix(in srgb, var(--color-surface-container-low) 96%, transparent);
  border: 1px solid color-mix(in srgb, var(--color-outline-variant) 15%, transparent);
  padding: 2rem;
  border-radius: var(--radius-xl);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.bah-auth-title {
  margin: 0 0 0.5rem;
  color: #ffffff;
  font-family: var(--font-headline);
  font-size: 1.5rem;
  font-weight: 700;
}

.bah-auth-subtitle {
  margin: 0;
  color: var(--color-on-surface-variant);
  font-size: 0.875rem;
}

.bah-auth-submit {
  width: 100%;
  min-height: 3.5rem;
  padding: 1rem 1.25rem;
  border: none;
  border-radius: var(--radius-lg);
  background: var(--bah-gradient-kinetic);
  color: #ffffff;
  box-shadow: 0 18px 36px rgba(46, 49, 146, 0.24);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-family: var(--font-headline);
  font-size: 0.9375rem;
  font-weight: 700;
  text-decoration: none;
  transition: transform 0.2s, filter 0.2s, opacity 0.2s, background-color 0.2s;
}

.bah-auth-submit:hover:not(:disabled) {
  filter: brightness(1.08);
}

.bah-auth-submit:active:not(:disabled) {
  transform: scale(0.98);
}

.bah-auth-submit:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ── Form Primitives ───────────────────────────────────────── */
.bah-field-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0 0.25rem;
}

.bah-field-label {
  color: var(--color-on-surface-variant);
  font-family: var(--font-label);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  padding: 0 0.25rem;
}

.bah-field-secondary-action {
  color: var(--color-primary);
  font-size: 0.625rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  transition: color 0.2s;
}

.bah-field-secondary-action:hover {
  color: var(--color-primary-fixed);
}

.bah-input-wrap {
  position: relative;
}

.bah-input-action {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-on-surface-variant);
  transition: color 0.2s;
}

.bah-input-action:hover {
  color: var(--color-on-surface);
}

.bah-input-action--right {
  left: auto;
  right: 1rem;
}

.bah-input-icon {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-on-surface-variant);
  font-size: 1.125rem;
}

.bah-input-icon--right {
  left: auto;
  right: 1rem;
}

.bah-input {
  width: 100%;
  background-color: var(--color-surface-container-highest);
  border: none;
  border-radius: var(--radius-lg);
  color: var(--color-on-surface);
  font-size: 1rem;
  padding: 0.875rem 1rem 0.875rem 3rem;
  box-sizing: border-box;
  transition: box-shadow 0.2s, background-color 0.2s;
}

.bah-input--no-prefix {
  padding-left: 1rem;
}

.bah-input--with-suffix {
  padding-right: 3rem;
}

.bah-input::placeholder {
  color: color-mix(in srgb, var(--color-on-surface-variant) 50%, transparent);
}

.bah-input:focus {
  outline: none;
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--color-primary) 40%, transparent);
  background-color: var(--color-surface-container-highest);
}

.bah-input:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.bah-app-input {
  width: 100%;
  border-radius: var(--radius-lg);
  border: 1px solid color-mix(in srgb, var(--color-on-surface) 10%, transparent);
  background-color: var(--color-surface);
  color: var(--color-on-surface);
  font-size: 0.75rem;
  padding: 0.625rem 0.75rem 0.625rem 2.75rem;
  box-sizing: border-box;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s, opacity 0.2s;
}

.bah-app-input--no-prefix {
  padding-left: 0.75rem;
}

.bah-app-input--with-suffix {
  padding-right: 2.75rem;
}

.bah-app-input::placeholder {
  color: color-mix(in srgb, var(--color-on-surface-variant) 100%, transparent);
}

.bah-app-input:focus {
  border-color: color-mix(in srgb, var(--color-on-surface) 20%, transparent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--color-on-surface) 10%, transparent);
}

.bah-app-input:disabled {
  opacity: 0.8;
  cursor: not-allowed;
}

.bah-select-wrap {
  position: relative;
}

.bah-select {
  width: 100%;
  appearance: none;
  background-color: var(--color-surface-container-high);
  border: 1px solid color-mix(in srgb, var(--color-outline-variant) 25%, transparent);
  border-radius: var(--radius-lg);
  color: var(--color-on-surface);
  font-family: var(--font-headline);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  line-height: 1.25;
  padding: 0.55rem 2.25rem 0.55rem 1rem;
  text-transform: uppercase;
  transition: border-color 0.2s, box-shadow 0.2s, color 0.2s;
}

.bah-select:focus {
  outline: none;
  border-color: color-mix(in srgb, var(--color-primary) 50%, transparent);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--color-primary) 50%, transparent);
}

.bah-select:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.bah-select-icon {
  position: absolute;
  right: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  color: var(--color-on-surface-variant);
  font-size: 1.125rem;
}

.bah-text-link {
  color: var(--color-primary);
  font-family: var(--font-label);
  font-size: 0.625rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  text-decoration: none;
}

.bah-text-link:hover {
  color: var(--color-primary-fixed);
}

.bah-checkbox-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--color-on-surface-variant);
  font-size: 0.875rem;
  padding: 0.25rem 0;
}

.bah-checkbox-row input {
  width: 1rem;
  height: 1rem;
  accent-color: var(--color-primary);
}

/* ── Buttons ───────────────────────────────────────────────── */
.bah-btn-kinetic {
  width: 100%;
  background: var(--bah-gradient-kinetic);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-lg);
  font-family: var(--font-headline);
  font-size: 0.9375rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 1rem 1.25rem;
  cursor: pointer;
  transition: filter 0.2s, transform 0.2s, opacity 0.2s;
}

.bah-btn-kinetic:hover:not(:disabled) {
  filter: brightness(1.1);
}

.bah-btn-kinetic:active:not(:disabled) {
  transform: scale(0.98);
}

.bah-btn-kinetic:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* ── Alerts ────────────────────────────────────────────────── */
.bah-alert {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  border-radius: var(--radius-xl);
  padding: 1rem;
  font-size: 0.875rem;
  margin-bottom: 1.5rem;
}

.bah-alert--error {
  background: color-mix(in srgb, var(--color-error-container) 20%, transparent);
  border: 1px solid color-mix(in srgb, var(--color-error) 30%, transparent);
  color: var(--color-error);
}

.bah-alert--warning {
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(251, 191, 36, 0.3);
}

.bah-alert--success {
  background: color-mix(in srgb, var(--color-tertiary) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--color-tertiary) 30%, transparent);
}

/* ── Dialog Shell ──────────────────────────────────────────── */
.bah-dialog-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
}

.bah-dialog-backdrop[hidden] {
  display: none;
}

.bah-dialog-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
}

.bah-dialog-panel {
  position: relative;
  z-index: 1;
  background: var(--color-surface-container);
  border: 1px solid color-mix(in srgb, var(--color-outline-variant) 20%, transparent);
  border-radius: var(--radius-xl);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.4);
  width: min(30rem, calc(100% - 2rem));
  max-height: calc(100vh - 2rem);
  overflow: auto;
}

.bah-dialog-close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  width: 2.25rem;
  height: 2.25rem;
  border: 1px solid color-mix(in srgb, var(--color-outline-variant) 28%, transparent);
  border-radius: var(--radius-xl);
  background: color-mix(in srgb, var(--color-surface-container-low) 90%, transparent);
  color: var(--color-on-surface-variant);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: color 0.2s, background-color 0.2s, border-color 0.2s;
}

.bah-dialog-close:hover {
  color: var(--color-on-surface);
  background: color-mix(in srgb, var(--color-surface-container-high) 95%, transparent);
  border-color: color-mix(in srgb, var(--color-primary) 28%, transparent);
}

/* ── Auth Footer ───────────────────────────────────────────── */
.bah-auth-footer {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid color-mix(in srgb, var(--color-outline-variant) 10%, transparent);
  text-align: center;
}

.bah-auth-footer p {
  margin: 0;
  color: var(--color-on-surface-variant);
  font-size: 0.875rem;
}

.bah-auth-footer a {
  color: var(--color-primary);
  font-weight: 700;
  margin-left: 0.25rem;
  text-decoration: none;
}

.bah-auth-footer a:hover {
  text-decoration: underline;
  text-underline-offset: 0.25rem;
}

/* ── Backward-Compatible Aliases ───────────────────────────── */
/* These allow existing templates to keep using the old class
   names while new code should prefer the bah- prefix.        */
.kinetic-gradient      { background-image: var(--bah-gradient-kinetic); }
.kinetic-text-gradient {
  background-image: var(--bah-gradient-kinetic);
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.glass-panel {
  background: rgba(37, 37, 48, 0.7);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.material-symbols-outlined {
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
}

.material-symbols-outlined.bah-tooltip-icon {
  font-size: 14px;
  line-height: 1;
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 14;
}
