/**
 * MechCore shared UI components — load immediately after mechcore-theme.css.
 */

/* ═══════════════════════════════
   CARDS
═══════════════════════════════ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--s5);
  transition:
    transform var(--t-base),
    box-shadow var(--t-base),
    border-color var(--t-base);
}
.card-interactive {
  cursor: pointer;
}
.card-interactive:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-gold);
  border-color: var(--border-gold);
}
.card-interactive:active {
  transform: translateY(0px);
  transition: transform var(--t-fast);
}
.card-critical {
  border-left: 3px solid var(--critical);
  background: linear-gradient(
    135deg,
    var(--critical-dim) 0%,
    var(--surface) 100%
  );
}
.card-gold {
  border-left: 3px solid var(--gold);
}

/* ═══════════════════════════════
   STATUS BADGES
═══════════════════════════════ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
}
.badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.badge-critical {
  background: var(--critical-dim);
  color: var(--critical);
  border: 1px solid rgba(224, 85, 85, 0.25);
}
.badge-high {
  background: var(--high-dim);
  color: var(--high);
  border: 1px solid rgba(224, 122, 53, 0.25);
}
.badge-medium {
  background: var(--gold-dim);
  color: var(--gold);
  border: 1px solid var(--border-gold);
}
.badge-low {
  background: rgba(156, 154, 146, 0.1);
  color: var(--text-muted);
  border: 1px solid rgba(156, 154, 146, 0.2);
}
.badge-ok {
  background: var(--ok-dim);
  color: var(--ok);
  border: 1px solid rgba(74, 222, 128, 0.2);
}
.badge-parsed {
  background: var(--ok-dim);
  color: var(--ok);
}
.badge-pending {
  background: var(--gold-dim);
  color: var(--gold);
  animation: badgePulse 1.5s ease infinite;
}
.badge-failed {
  background: var(--critical-dim);
  color: var(--critical);
}

@keyframes badgePulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.6;
  }
}

/* ═══════════════════════════════
   BUTTONS
═══════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  padding: 10px 20px;
  border-radius: var(--r-sm);
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition:
    background var(--t-fast),
    transform var(--t-fast),
    box-shadow var(--t-fast),
    opacity var(--t-fast);
  min-height: 44px;
  white-space: nowrap;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.btn:active {
  transform: scale(0.97);
}
.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.btn:disabled:active {
  transform: none;
}

.btn-primary {
  background: var(--gold);
  color: var(--bg);
}
.btn-primary:hover {
  background: var(--gold-bright);
  box-shadow: var(--shadow-gold);
}

.btn-secondary {
  background: var(--gold-dim);
  color: var(--gold);
  border: 1px solid var(--border-gold);
}
.btn-secondary:hover {
  background: rgba(200, 169, 110, 0.2);
  border-color: var(--gold);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-ghost:hover {
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.15);
  background: var(--surface-2);
}

.btn-danger {
  background: var(--critical-dim);
  color: var(--critical);
  border: 1px solid rgba(224, 85, 85, 0.25);
}
.btn-danger:hover {
  background: rgba(224, 85, 85, 0.2);
  box-shadow: var(--shadow-critical);
}

.btn-sm {
  padding: 6px 14px;
  font-size: 13px;
  min-height: 36px;
}
.btn-lg {
  padding: 14px 28px;
  font-size: 16px;
  min-height: 52px;
}
.btn-full {
  width: 100%;
}

/* ═══════════════════════════════
   INPUTS
═══════════════════════════════ */
.input {
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text);
  padding: 10px 14px;
  font-family: var(--font-sans);
  font-size: 15px;
  width: 100%;
  min-height: 44px;
  transition:
    border-color var(--t-fast),
    box-shadow var(--t-fast);
  -webkit-appearance: none;
  appearance: none;
}
.input::placeholder {
  color: var(--text-dim);
}
.input:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-dim);
}

/* ═══════════════════════════════
   SKELETON LOADERS
   Must match content shape exactly
═══════════════════════════════ */
@keyframes shimmer {
  0% {
    background-position: -200% 0;
  }
  100% {
    background-position: 200% 0;
  }
}
.skeleton {
  background: linear-gradient(
    90deg,
    var(--surface) 0%,
    var(--surface-2) 50%,
    var(--surface) 100%
  );
  background-size: 200% 100%;
  animation: shimmer 1.8s ease infinite;
  border-radius: var(--r-sm);
}
/* Skeleton shapes */
.skel-text {
  height: 16px;
  border-radius: 4px;
}
.skel-text-sm {
  height: 13px;
  border-radius: 4px;
}
.skel-title {
  height: 22px;
  border-radius: 4px;
}
.skel-badge {
  height: 22px;
  width: 80px;
  border-radius: 20px;
}
.skel-card {
  height: 80px;
  border-radius: var(--r-md);
  margin-bottom: var(--s3);
}
.skel-stat {
  height: 60px;
  border-radius: var(--r-md);
}

/* ═══════════════════════════════
   TOAST NOTIFICATIONS
═══════════════════════════════ */
#toast-container {
  position: fixed;
  bottom: calc(var(--s6) + env(safe-area-inset-bottom));
  right: var(--s5);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: var(--s2);
  pointer-events: none;
}
.toast {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--s4) var(--s5);
  min-width: 280px;
  max-width: 360px;
  display: flex;
  align-items: center;
  gap: var(--s3);
  box-shadow: var(--shadow-lg);
  pointer-events: all;
  animation: toastIn var(--t-slow) ease forwards;
}
.toast.toast-exit {
  animation: toastOut var(--t-slow) ease forwards;
}
.toast-success {
  border-left: 3px solid var(--ok);
}
.toast-error {
  border-left: 3px solid var(--critical);
}
.toast-info {
  border-left: 3px solid var(--gold);
}

.toast-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}
.toast-msg {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
}

@keyframes toastIn {
  from {
    transform: translateX(110%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}
@keyframes toastOut {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(110%);
    opacity: 0;
  }
}

/* ═══════════════════════════════
   NAV
═══════════════════════════════ */
.nav {
  position: sticky;
  top: 0;
  z-index: 200;
  height: 56px;
  background: rgba(15, 14, 12, 0.95);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  will-change: backdrop-filter;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  gap: var(--s4);
}
[data-theme='bright'] .nav,
[data-theme='light'] .nav {
  background: rgba(255, 255, 255, 0.92);
}

.nav-logo {
  font-size: 20px;
  letter-spacing: -0.02em;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  flex-shrink: 0;
}
.nav-logo span {
  font-weight: 400;
  color: var(--gold);
}

/* ═══════════════════════════════
   BOTTOM NAV (mobile)
═══════════════════════════════ */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: rgba(28, 26, 23, 0.95);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--border);
  display: flex;
  padding-bottom: env(safe-area-inset-bottom);
  height: calc(56px + env(safe-area-inset-bottom));
}
[data-theme='bright'] .bottom-nav,
[data-theme='light'] .bottom-nav {
  background: rgba(255, 255, 255, 0.95);
}
.bottom-nav-item,
.bottom-nav .bn-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 11px;
  font-weight: 500;
  transition: color var(--t-fast);
  -webkit-tap-highlight-color: transparent;
  min-height: 44px;
  background: none;
  border: none;
  outline: none;
  cursor: pointer;
  font-family: var(--font-sans);
  letter-spacing: 0.02em;
  -webkit-appearance: none;
  appearance: none;
}
.bottom-nav-item.active,
.bottom-nav .bn-item.active {
  color: var(--gold);
  font-weight: 600;
}
.bottom-nav-item:active,
.bottom-nav .bn-item:active {
  opacity: 0.7;
}

/* class="has-bottom-nav" on body where bottom nav is present */
body.has-bottom-nav {
  padding-bottom: calc(56px + env(safe-area-inset-bottom));
}

/* ═══════════════════════════════
   DIVIDERS + SPACING
═══════════════════════════════ */
.divider {
  height: 1px;
  background: var(--border);
  margin: var(--s5) 0;
}
.section {
  margin-bottom: var(--s6);
}
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--s4);
}

/* Page enter — avoids hard pop on load */
body {
  opacity: 0;
  transition: opacity 0.35s ease;
}
body.mc-page-ready {
  opacity: 1;
}

/* Primary interactive controls — press affordance */
button:active,
.submit-btn:active,
.nav-cta:active,
.hamburger-btn:active,
.back-btn:active,
.carr-btn:active,
.bn-item:active,
.hbtn-price:active,
.cc-view-btn:active {
  transform: scale(0.97);
}
.theme-pill:active {
  transform: scale(0.97);
}

/* Common elevated cards (Franco-facing pages) */
.cc-card-wrap,
.def-card-wrap,
.cc-card,
.def-card,
.panel,
.pblock {
  transition:
    transform var(--t-base),
    box-shadow var(--t-base),
    border-color var(--t-base);
}
.cc-card-wrap:hover,
.def-card-wrap:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-gold);
  border-color: var(--border-gold) !important;
}

/* CRITICAL deficiency / badge — high-visibility pulse */
.severity-CRITICAL,
[data-severity='CRITICAL'],
.badge-critical,
.mc-sev-critical {
  animation: mcCriticalPulse 1.25s ease-in-out infinite !important;
  box-shadow: 0 0 0 0 var(--critical-glow, rgba(224, 85, 85, 0.45));
}

@keyframes mcCriticalPulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(224, 85, 85, 0.35);
    opacity: 1;
  }
  50% {
    box-shadow: 0 0 0 8px rgba(224, 85, 85, 0);
    opacity: 0.92;
  }
}

/* Equipment — voice control idle “breathing” */
.hbtn-voice:not(.recording),
.vr-mic-btn.idle {
  animation: mcVoiceBreathe 2.8s ease-in-out infinite;
}

@keyframes mcVoiceBreathe {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(200, 169, 110, 0);
    border-color: var(--border);
  }
  50% {
    box-shadow: 0 0 0 6px rgba(200, 169, 110, 0.12);
    border-color: var(--gold-border, rgba(200, 169, 110, 0.45));
  }
}

/* Stat numbers — count up when marked (see theme.js helper) */
.mc-count-up {
  font-variant-numeric: tabular-nums;
}
