/**
 * css/hand-tracking/ht-panel.css
 *
 * PURPOSE: Floating hand-tracking control panel — Light theme, RTL first.
 *          Professional, highly accurate Arabic UI design with bilingual support.
 */

#ht-panel {
  position: fixed;
  top: 76px;
  left: 24px; /* Fixed on the left side to align with the header button in RTL */
  z-index: 9000;
  width: 320px;
  max-height: calc(100vh - 100px);
  display: flex;
  flex-direction: column;
  
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.05);
  
  font-family: var(--font-ui, 'Inter', system-ui, sans-serif);
  font-size: 13px;
  color: #1e293b;
  user-select: none;
  
  transition: opacity 0.25s ease, transform 0.25s ease;
  will-change: transform;
  
  /* Force explicit RTL for the panel to guarantee perfect Arabic alignment */
  direction: rtl;
}

#ht-panel.ht-entering {
  opacity: 0;
  transform: translateY(-12px) scale(0.97);
}

#ht-panel[data-hidden="true"] {
  opacity: 0;
  transform: translateY(-12px) scale(0.97);
  pointer-events: none;
}

/* ── Header ───────────────────────────────────────────────────────────────── */
.ht-panel-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  border-radius: 16px 16px 0 0;
  cursor: grab;
}

.ht-panel-header:active { cursor: grabbing; }

.ht-header-icon {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(13, 138, 116, 0.1);
  border-radius: 8px;
  color: #0d8a74;
}

.ht-header-text {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.ht-header-title {
  font-weight: 700;
  font-size: 13.5px;
  color: #0f172a;
  line-height: 1.3;
}

.ht-header-sub {
  font-size: 10px;
  color: #64748b;
  line-height: 1.2;
}

.ht-header-controls {
  display: flex;
  gap: 8px;
  align-items: center;
}

.ht-toggle-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 20px;
  border: 1px solid #cbd5e1;
  background: #f1f5f9;
  color: #64748b;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.ht-toggle-btn:hover {
  background: #e2e8f0;
  color: #334155;
}

.ht-toggle-btn[data-active="true"] {
  background: #0d8a74;
  border-color: #0d8a74;
  color: #ffffff;
}

.ht-toggle-btn .ht-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.ht-toggle-btn[data-active="true"] .ht-dot {
  animation: ht-pulse-dot 1.5s infinite;
}

@keyframes ht-pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.7); }
}

.ht-close-btn {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: #94a3b8;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s;
}

.ht-close-btn:hover {
  background: #fee2e2;
  color: #ef4444;
}

/* ── Panel body ───────────────────────────────────────────────────────────── */
.ht-panel-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
}

/* ── Cards ────────────────────────────────────────────────────────────────── */
.ht-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ht-card-label {
  font-size: 10.5px;
  font-weight: 700;
  color: #64748b;
  padding-bottom: 6px;
  border-bottom: 1px solid #e2e8f0;
}

/* ── Config Rows ──────────────────────────────────────────────────────────── */
.ht-config-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.ht-config-label {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.ht-config-label span:first-child {
  font-size: 11.5px;
  font-weight: 700;
  color: #334155;
}

.ht-config-label span:last-child {
  font-size: 10px;
  color: #64748b;
}

/* Pill Buttons */
.ht-pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 20px;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #475569;
  font-family: inherit;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  min-width: 75px;
  justify-content: center;
}

.ht-pill-btn:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
}

.ht-pill-btn[data-swapped="true"] {
  background: #f3e8ff;
  border-color: #d8b4fe;
  color: #7c3aed;
}

.ht-pill-btn[data-active="false"] {
  background: #fee2e2;
  border-color: #fca5a5;
  color: #dc2626;
}

.ht-pill-btn[data-active="true"] {
  background: #ecfdf5;
  border-color: #6ee7b7;
  color: #059669;
}

/* ── Status Grid ──────────────────────────────────────────────────────────── */
.ht-status-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.ht-status-card {
  padding: 10px;
  gap: 8px;
}

.ht-mini-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ht-mini-key {
  font-size: 10px;
  font-weight: 600;
  color: #64748b;
}

.ht-status-value {
  font-size: 11px;
  font-weight: 700;
  color: #1e293b;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  padding: 4px 8px;
  border-radius: 6px;
  text-align: center;
  min-height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Gesture specific colors */
.ht-status-value[data-gesture="penlight"] { background: #fffbeb; border-color: #fcd34d; color: #b45309; }
.ht-status-value[data-gesture="cover"] { background: #ecfdf5; border-color: #6ee7b7; color: #047857; }
.ht-status-value[data-gesture="prism"] { background: #eff6ff; border-color: #bfdbfe; color: #1d4ed8; }
.ht-status-value[data-gesture="move"] { background: #f3e8ff; border-color: #d8b4fe; color: #6d28d9; }
.ht-status-value[data-gesture="reset"] { background: #fff7ed; border-color: #fed7aa; color: #c2410c; }
.ht-status-value[data-gesture="disabled"] { background: #fef2f2; border-color: #fecaca; color: #dc2626; }

/* ── Error / Notice ───────────────────────────────────────────────────────── */
.ht-error-msg {
  display: none;
  padding: 10px;
  border-radius: 8px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #dc2626;
  font-size: 11.5px;
  font-weight: 600;
}
.ht-error-msg[data-visible="true"] { display: block; }
.ht-error-msg[data-kind="notice"] {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #2563eb;
}

/* ── Sliders ──────────────────────────────────────────────────────────────── */
.ht-slider-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ht-slider-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.ht-slider-header span:first-child {
  font-size: 11px;
  font-weight: 700;
  color: #475569;
}

.ht-slider-val {
  font-size: 11px;
  font-weight: 700;
  color: #0d8a74;
}

input[type="range"].ht-range {
  -webkit-appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 2px;
  background: #e2e8f0;
  outline: none;
}

input[type="range"].ht-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #0d8a74;
  cursor: grab;
  box-shadow: 0 0 0 4px rgba(13, 138, 116, 0.15);
}

/* ── Instructions ─────────────────────────────────────────────────────────── */
.ht-instructions-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ht-instructions-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 700;
  color: #475569;
  cursor: pointer;
  transition: background 0.2s;
}

.ht-instructions-header:hover {
  background: #f1f5f9;
}

.ht-instructions-chevron {
  transition: transform 0.3s;
}

.ht-instructions-header[data-open="true"] .ht-instructions-chevron {
  transform: rotate(180deg);
}

.ht-instructions-body {
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.3s ease;
}

.ht-instructions-inner {
  padding: 8px 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ht-legend-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ht-legend-title {
  font-size: 11px;
  font-weight: 700;
  color: #0d8a74;
}

.ht-legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: #475569;
  background: #f8fafc;
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid #e2e8f0;
}

.ht-legend-emoji {
  font-size: 14px;
}
