/* ==========================================================================
   GESTURA AI - Hand Gesture Tracking & Cyber HUD Stylesheet
   ========================================================================== */

/* Floating Webcam PIP Feed & Tracking Overlay */
#gesture-hud-widget {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  width: 250px;
  background: var(--bg-hud);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: var(--card-radius);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.7), 0 0 15px rgba(0, 240, 255, 0.15);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: transform var(--transition-normal), opacity var(--transition-normal);
}

#gesture-hud-widget.minimized {
  width: 210px;
}

#gesture-hud-widget.minimized .pip-viewport-area {
  display: none;
}

/* Header with Drag/Toggle/Status */
.gesture-hud-header {
  padding: 0.5rem 0.75rem;
  background: rgba(14, 23, 47, 0.9);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.hud-status-wrapper {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-family: var(--font-family-tech);
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-primary);
  text-transform: uppercase;
}

.cam-led {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: background var(--transition-fast), box-shadow var(--transition-fast);
}

.cam-led.active {
  background: var(--cyan-core);
  box-shadow: 0 0 8px var(--cyan-core);
}

.cam-led.standby {
  background: var(--warning);
  box-shadow: 0 0 8px rgba(245, 158, 11, 0.5);
}

.cam-led.error {
  background: var(--danger);
  box-shadow: 0 0 8px rgba(239, 68, 68, 0.6);
}

.hud-controls-right {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.hud-icon-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
}

.hud-icon-btn:hover {
  color: var(--cyan-core);
  background: rgba(255, 255, 255, 0.05);
}

/* PIP Viewport Canvas and Hidden Video */
.pip-viewport-area {
  position: relative;
  width: 100%;
  height: 160px;
  background: #000;
  overflow: hidden;
}

#gesture-video-feed {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1); /* Mirror camera feed */
  opacity: 0.65;
}

#gesture-canvas-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  transform: scaleX(-1); /* Mirror skeleton landmarks */
  z-index: 5;
}

/* Standby Overlay when Camera is OFF */
.pip-standby-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(6, 11, 25, 0.94);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 15;
  text-align: center;
  padding: 0.75rem;
}

.btn-pip-start {
  background: linear-gradient(135deg, rgba(0, 240, 255, 0.15), rgba(0, 102, 255, 0.25));
  border: 1px solid var(--cyan-core);
  border-radius: 8px;
  color: #fff;
  padding: 0.65rem 0.85rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  cursor: pointer;
  transition: all var(--transition-fast);
  box-shadow: 0 0 15px rgba(0, 240, 255, 0.2);
  width: 100%;
}

.btn-pip-start:hover {
  background: linear-gradient(135deg, rgba(0, 240, 255, 0.3), rgba(0, 102, 255, 0.4));
  box-shadow: 0 0 22px rgba(0, 240, 255, 0.45);
  transform: translateY(-1px);
}

.btn-pip-start svg {
  color: var(--cyan-core);
}

.btn-pip-start span {
  font-family: var(--font-family-tech);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: #fff;
}

.btn-pip-start small {
  font-size: 0.68rem;
  color: var(--cyan-core);
  opacity: 0.9;
}

/* AI Model Loading Spinner Overlay */
.pip-loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(6, 11, 25, 0.92);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  z-index: 15;
  text-align: center;
  color: var(--cyan-core);
}

.pip-spinner {
  width: 26px;
  height: 26px;
  border: 3px solid rgba(0, 240, 255, 0.2);
  border-top-color: var(--cyan-core);
  border-radius: 50%;
  animation: pipSpin 0.8s linear infinite;
}

@keyframes pipSpin {
  to { transform: rotate(360deg); }
}

.pip-loading-overlay span {
  font-family: var(--font-family-tech);
  font-size: 0.78rem;
  font-weight: 700;
  color: #fff;
}

.pip-loading-overlay small {
  font-size: 0.65rem;
  color: var(--text-secondary);
}

/* Real-time Detection Status Banner */
.pip-detection-banner {
  position: absolute;
  top: 0.35rem;
  left: 0.35rem;
  right: 0.35rem;
  background: rgba(6, 11, 25, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  padding: 0.2rem 0.4rem;
  font-size: 0.68rem;
  text-align: center;
  z-index: 12;
  font-family: var(--font-family-tech);
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
}

.pip-detection-banner.tracked {
  border-color: rgba(0, 240, 255, 0.5);
  background: rgba(0, 40, 50, 0.85);
  color: #00f0ff;
}

.pip-detection-banner.searching {
  border-color: rgba(245, 158, 11, 0.4);
  background: rgba(40, 30, 10, 0.85);
  color: #fbbf24;
}

/* Quick Gesture Simulation Toolbar */
.hud-sim-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.25rem;
  padding-top: 0.4rem;
  border-top: 1px dashed rgba(255, 255, 255, 0.1);
}

.sim-label {
  font-size: 0.65rem;
  font-family: var(--font-family-tech);
  color: var(--text-muted);
  font-weight: 700;
  margin-right: 0.1rem;
}

.sim-chip-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 3px;
  color: var(--text-secondary);
  font-size: 0.65rem;
  padding: 0.15rem 0.35rem;
  cursor: pointer;
  transition: all var(--transition-fast);
  font-family: var(--font-family-tech);
}

.sim-chip-btn:hover {
  background: rgba(0, 240, 255, 0.15);
  border-color: var(--cyan-core);
  color: var(--cyan-core);
}

.sim-chip-btn.active {
  background: var(--cyan-core);
  color: #060b19;
  border-color: var(--cyan-core);
  font-weight: 700;
}

.sim-chip-btn.reset {
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.3);
}

.sim-chip-btn.reset:hover {
  background: rgba(239, 68, 68, 0.2);
  border-color: #ef4444;
  color: #fff;
}

/* Active Gesture Notification Overlay */
.pip-gesture-badge-bar {
  position: absolute;
  bottom: 0.4rem;
  left: 0.4rem;
  right: 0.4rem;
  background: rgba(6, 11, 25, 0.85);
  border: 1px solid rgba(0, 240, 255, 0.3);
  border-radius: 6px;
  padding: 0.3rem 0.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 10;
}

.current-gesture-label {
  font-family: var(--font-family-tech);
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--cyan-core);
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

/* Circular Cooldown Ring */
.cooldown-ring-wrapper {
  position: relative;
  width: 18px;
  height: 18px;
}

.cooldown-svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.cooldown-circle-bg {
  fill: none;
  stroke: rgba(255, 255, 255, 0.1);
  stroke-width: 3;
}

.cooldown-circle-fg {
  fill: none;
  stroke: var(--cyan-core);
  stroke-width: 3;
  stroke-dasharray: 44;
  stroke-dashoffset: 44;
  transition: stroke-dashoffset 0.1s linear;
}

/* Gestures Legend in HUD */
.hud-legend-drawer {
  padding: 0.6rem 0.75rem;
  background: rgba(11, 18, 36, 0.8);
  font-size: 0.72rem;
  color: var(--text-secondary);
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.legend-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.legend-item span {
  color: var(--cyan-core);
  font-family: var(--font-family-tech);
  font-weight: 600;
}

/* Virtual On-Screen Gesture Cursor */
#virtual-gesture-pointer {
  position: fixed;
  top: 0;
  left: 0;
  width: 28px;
  height: 28px;
  pointer-events: none;
  z-index: 99999;
  transform: translate(-50%, -50%);
  display: none;
  transition: transform 0.04s ease-out;
}

#virtual-gesture-pointer.visible {
  display: block;
}

.pointer-ring {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 2px solid var(--cyan-core);
  box-shadow: 0 0 12px var(--cyan-glow);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pointer-ring::after {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--cyan-core);
  box-shadow: 0 0 6px var(--cyan-core);
}

.pointer-dwell-circle {
  position: absolute;
  top: -4px;
  left: -4px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid transparent;
  border-top-color: var(--cyan-core);
  opacity: 0;
  transition: opacity 0.2s ease;
}

#virtual-gesture-pointer.dwelling .pointer-dwell-circle {
  opacity: 1;
  animation: dwellSpin 1.2s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes dwellSpin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Camera Permission Guide Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: var(--bg-overlay);
  backdrop-filter: blur(12px);
  z-index: 50000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.modal-overlay.active {
  display: flex;
}

.modal-card {
  background: var(--bg-hud);
  border: 1px solid var(--cyan-core);
  border-radius: var(--card-radius);
  max-width: 520px;
  width: 100%;
  padding: 2rem;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.9), 0 0 25px var(--cyan-glow);
}

.modal-card h3 {
  font-family: var(--font-family-tech);
  font-size: 1.5rem;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.modal-card p {
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 1.5;
  margin-bottom: 1.25rem;
}

.permission-steps {
  list-style: none;
  margin-bottom: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.permission-steps li {
  font-size: 0.85rem;
  color: var(--text-secondary);
  background: rgba(14, 23, 47, 0.7);
  border-left: 3px solid var(--cyan-core);
  padding: 0.6rem 0.85rem;
  border-radius: 0 6px 6px 0;
}

.modal-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
}

@media (max-width: 600px) {
  #gesture-hud-widget {
    bottom: 1rem;
    right: 1rem;
    width: 180px;
  }
  .pip-viewport-area {
    height: 120px;
  }
}
