:root {
  --bg-dark: #0f172a;
  --panel-bg: rgba(30, 41, 59, 0.7);
  --glass-border: rgba(255, 255, 255, 0.1);
  --primary: #38bdf8;
  --secondary: #818cf8;
  --accent-coffee: #d97706;
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --success: #22c55e;
  --danger: #ef4444;
  --font-main: 'Outfit', 'Noto Sans TC', sans-serif;
}

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

body {
  background-color: var(--bg-dark);
  color: var(--text-main);
  font-family: var(--font-main);
  overflow-x: hidden;
  min-height: 100vh;
}

/* 背景動態光效 */
.bg-glow {
  position: fixed;
  width: 50vw;
  height: 50vw;
  border-radius: 50%;
  filter: blur(120px);
  z-index: -1;
  opacity: 0.15;
  pointer-events: none;
}

.bg-glow-1 {
  top: -10%;
  left: -10%;
  background: var(--primary);
  animation: float 20s infinite alternate;
}

.bg-glow-2 {
  bottom: -10%;
  right: -10%;
  background: var(--accent-coffee);
  animation: float 25s infinite alternate-reverse;
}

@keyframes float {
  from { transform: translate(0, 0); }
  to { transform: translate(10%, 10%); }
}

/* Dashboard 佈局 */
.dashboard-wrapper {
  max-width: 1400px;
  margin: 0 auto;
  padding: 2rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

/* Header */
.main-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 0;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo .icon { font-size: 2rem; }
.logo h1 {
  font-size: 1.8rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, #fff, #94a3b8);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.badge {
  background: rgba(56, 189, 248, 0.15);
  color: var(--primary);
  padding: 0.2rem 0.6rem;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
}

.status-indicators {
  display: flex;
  gap: 1.5rem;
}

.indicator {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #475569;
}

.dot.active {
  background: var(--success);
  box-shadow: 0 0 12px var(--success);
}

/* Grid System */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 2rem;
}

/* Glass Panel Base */
.glass-panel {
  background: var(--panel-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  border-radius: 24px;
  padding: 1.5rem;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

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

.panel-header h2, .panel-header h3 {
  font-size: 1.25rem;
  font-weight: 600;
}

/* Viewport Area */
.visual-viewport {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: 16px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

#webcam-view, .preview-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.placeholder {
  text-align: center;
}

.placeholder .icon {
  font-size: 3rem;
  display: block;
  margin-bottom: 1rem;
  opacity: 0.5;
}

/* Scan Overlay */
.overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.scanning-bar {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: linear-gradient(to right, transparent, var(--primary), transparent);
  box-shadow: 0 0 15px var(--primary);
  animation: scan 3s linear infinite;
  z-index: 2;
}

.scanning-grid {
  position: absolute;
  inset: 0;
  background-image: 
    linear-gradient(rgba(56, 189, 248, 0.1) 1px, transparent 1px),
    linear-gradient(90deg, rgba(56, 189, 248, 0.1) 1px, transparent 1px);
  background-size: 30px 30px;
  opacity: 0.5;
  pointer-events: none;
  animation: gridPulse 4s ease-in-out infinite;
}

@keyframes gridPulse {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 0.6; }
}

@keyframes scan {
  0% { top: 0; }
  100% { top: 100%; }
}

/* Alert States */
.visual-viewport.alert-bad {
  border: 2px solid var(--danger);
  box-shadow: 0 0 30px rgba(239, 68, 68, 0.4);
  animation: shake 0.5s cubic-bezier(.36,.07,.19,.97) both;
}

@keyframes shake {
  10%, 90% { transform: translate3d(-1px, 0, 0); }
  20%, 80% { transform: translate3d(2px, 0, 0); }
  30%, 50%, 70% { transform: translate3d(-4px, 0, 0); }
  40%, 60% { transform: translate3d(4px, 0, 0); }
}

/* Buttons */
.btn {
  padding: 0.6rem 1.2rem;
  border-radius: 12px;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  border: none;
}

.btn-primary { background: var(--primary); color: #000; }
.btn-primary:hover { transform: scale(1.05); filter: brightness(1.1); }

.btn-secondary { background: var(--secondary); color: #fff; }
.btn-outline {
  background: transparent;
  border: 1px solid var(--glass-border);
  color: var(--text-main);
}
.btn-outline:hover { background: rgba(255, 255, 255, 0.05); }

/* Sidebar */
.sidebar {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.custom-select {
  width: 100%;
  padding: 0.8rem;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.5);
  border: 1px solid var(--glass-border);
  color: var(--text-main);
  font-size: 1rem;
  outline: none;
}

/* Result Display */
.result-display {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.label-heading {
  font-size: 0.8rem;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 1px;
}

.prediction-value {
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--primary);
}

.prob-bars {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.prob-item {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.prob-info {
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
}

.progress-bg {
  height: 6px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--primary);
  width: 0%;
  transition: width 0.4s ease;
}

/* Info Rows */
.info-row {
  display: flex;
  justify-content: space-between;
  margin-top: 1rem;
  font-size: 0.9rem;
}

.info-row .attr { color: var(--text-muted); }
.info-row .val { font-weight: 600; }

@media (max-width: 1024px) {
  .dashboard-grid { grid-template-columns: 1fr; }
  .sidebar { flex-direction: row; flex-wrap: wrap; }
  .sidebar > .panel { flex: 1; min-width: 300px; }
}

@media (max-width: 640px) {
  .dashboard-wrapper { padding: 1rem; }
  .visual-viewport { aspect-ratio: 1; }
  .prediction-value { font-size: 1.8rem; }
}
/* Gallery Tabs */
.gallery-tabs {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--glass-border);
  padding-bottom: 0.5rem;
}

.tab-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-main);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0.5rem 0.25rem;
  position: relative;
  transition: color 0.2s;
}

.tab-btn.active {
  color: var(--primary);
}

.tab-btn.active::after {
  content: '';
  position: absolute;
  bottom: -0.5rem;
  left: 0;
  width: 100%;
  height: 2px;
  background: var(--primary);
  box-shadow: 0 0 10px var(--primary);
}

.tab-content {
  display: none;
  animation: fadeIn 0.3s ease;
}

.tab-content.active {
  display: block;
}

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

/* Example Grid */
.example-grid {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.example-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.group-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  margin-bottom: 0.2rem;
}

.group-label.success { color: var(--success); }
.group-label.danger { color: var(--danger); }

.thumbnails {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
}

.example-thumb {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 12px;
  object-fit: cover;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.example-thumb:hover {
  transform: scale(1.08);
  border-color: rgba(255, 255, 255, 0.3);
}

.example-thumb.active {
  border-color: var(--primary);
  box-shadow: 0 0 15px var(--primary);
}

/* Tooltips */
[data-tooltip] {
  position: relative;
  cursor: help;
}

[data-tooltip]:hover::before {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 125%;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.95);
  color: #fff;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  font-size: 0.75rem;
  white-space: nowrap;
  z-index: 100;
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(4px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
  pointer-events: none;
}

/* Fullscreen Button */
.fullscreen-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--glass-border);
  color: #fff;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}

.fullscreen-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  transform: scale(1.1);
}

/* Drag & Drop Highlight */
.tab-content#upload-area.drag-over {
  background: rgba(56, 189, 248, 0.05);
  border: 2px dashed var(--primary);
  border-radius: 12px;
}
