/* ==========================================================================
   SCAN TO WAKE - AI OBJECT DETECTION ALARM CLOCK
   Style System & Dark Mode UI Theme
   ========================================================================== */

:root {
  /* Color Palette - Dark Cyber Modern Theme */
  --bg-main: #0b0f19;
  --bg-card: #151c2c;
  --bg-card-hover: #1c263b;
  --bg-input: #0f172a;
  
  /* Brand Accents */
  --accent-cyan: #06b6d4;
  --accent-magenta: #ec4899;
  --accent-green: #10b981;
  --accent-amber: #f59e0b;
  --accent-red: #ef4444;
  --accent-gradient: linear-gradient(135deg, #06b6d4 0%, #ec4899 100%);
  --accent-gradient-active: linear-gradient(135deg, #ec4899 0%, #ef4444 100%);

  /* Text & Borders */
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --border-color: rgba(255, 255, 255, 0.08);
  --border-glow: rgba(6, 182, 212, 0.3);

  /* Radius & Shadows */
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-pill: 9999px;
  --shadow-card: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
  --glow-cyan: 0 0 20px rgba(6, 182, 212, 0.35);
  --glow-magenta: 0 0 20px rgba(236, 72, 153, 0.35);
  --glow-red: 0 0 30px rgba(239, 68, 68, 0.6);

  /* Transitions */
  --transition-fast: 0.2s ease;
  --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Reset & Box Sizing */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  background-color: var(--bg-main);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.5;
  overflow-x: hidden;
}

/* Helper Utilities */
.hidden {
  display: none !important;
}

/* Main Container Layout */
.app-container {
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  gap: 24px;
}

/* Top Header Navigation */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-card);
  padding: 16px 24px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-card);
  flex-wrap: wrap;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-icon {
  width: 44px;
  height: 44px;
  background: var(--accent-gradient);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  color: #000;
  box-shadow: var(--glow-cyan);
}

.brand-text h1 {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-subtitle {
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-weight: 500;
}

/* Real-Time Clock Widget */
.clock-widget {
  text-align: center;
  background: var(--bg-input);
  padding: 8px 22px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--accent-cyan);
}

.clock-widget i {
  font-size: 1.1rem;
}

#current-time {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: 1px;
  font-variant-numeric: tabular-nums;
}

/* Model Loader Badge */
.model-status-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-input);
  padding: 8px 16px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-color);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background-color: var(--accent-amber);
}

.status-dot.pulsing {
  animation: pulseDot 1.5s infinite;
}

.status-dot.ready {
  background-color: var(--accent-green);
  box-shadow: 0 0 10px var(--accent-green);
  animation: none;
}

@keyframes pulseDot {
  0% { transform: scale(0.9); opacity: 0.7; }
  50% { transform: scale(1.2); opacity: 1; }
  100% { transform: scale(0.9); opacity: 0.7; }
}

/* Main Cards Layout Grid */
.main-content {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  flex: 1;
}

/* Responsive Grid adjustment */
@media (max-width: 900px) {
  .main-content {
    grid-template-columns: 1fr;
  }
}

.card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-card);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.card-header h2 {
  font-size: 1.25rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;

  /* Standard and vendor-prefixed clip */
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.card-header h2 i {
  -webkit-text-fill-color: var(--accent-cyan);
}

.card-header p {
  font-size: 0.88rem;
  color: var(--text-secondary);
}

/* Inputs & Form Elements */
.input-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 20px;
}

.input-group label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.time-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.time-input-wrapper input[type="time"] {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--accent-cyan);
  font-family: inherit;
  outline: none;
  transition: var(--transition-fast);
}

.time-input-wrapper input[type="time"]:focus {
  border-color: var(--accent-cyan);
  box-shadow: var(--glow-cyan);
}

.input-icon {
  position: absolute;
  right: 20px;
  font-size: 1.4rem;
  color: var(--text-muted);
  pointer-events: none;
}

/* Buttons System */
.button-group {
  display: flex;
  gap: 12px;
}

.btn {
  border: none;
  border-radius: var(--radius-md);
  padding: 14px 20px;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: var(--transition-normal);
  font-family: inherit;
}

.btn-primary {
  background: var(--accent-gradient);
  color: #000;
  flex: 1;
  box-shadow: var(--glow-cyan);
}

.btn-primary:hover {
  transform: translateY(-2px);
  filter: brightness(1.1);
}

.btn-danger {
  background: var(--accent-red);
  color: #fff;
  flex: 1;
  box-shadow: 0 0 15px rgba(239, 68, 68, 0.4);
}

.btn-danger:hover {
  transform: translateY(-2px);
  filter: brightness(1.1);
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  width: 100%;
}

.btn-outline:hover {
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
  background: rgba(6, 182, 212, 0.05);
}

.btn-success {
  background: var(--accent-green);
  color: #000;
  box-shadow: 0 0 20px rgba(16, 185, 129, 0.4);
  padding: 16px 28px;
  font-size: 1rem;
}

/* Active Alarm Display Box */
.active-alarm-box {
  margin-top: 20px;
  background: rgba(6, 182, 212, 0.08);
  border: 1px solid var(--accent-cyan);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  animation: fadeIn 0.4s ease;
}

.alarm-info {
  display: flex;
  align-items: center;
  gap: 14px;
}

.alarm-icon {
  font-size: 1.6rem;
  color: var(--accent-cyan);
  animation: bellRing 2s infinite ease-in-out;
}

@keyframes bellRing {
  0%, 100% { transform: rotate(0); }
  10%, 30%, 50% { transform: rotate(15deg); }
  20%, 40% { transform: rotate(-15deg); }
  60% { transform: rotate(0); }
}

.alarm-label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.alarm-time-text {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--text-primary);
}

.badge {
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  font-size: 0.75rem;
  font-weight: 700;
}

.badge-success {
  background: rgba(16, 185, 129, 0.15);
  color: var(--accent-green);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.test-trigger-wrapper {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px dashed var(--border-color);
}

/* Items List Section */
.items-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 0;
  gap: 12px;
  color: var(--text-muted);
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border-color);
  border-top-color: var(--accent-cyan);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.items-list {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}

.item-chip {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.88rem;
  font-weight: 600;
  transition: var(--transition-fast);
}

.item-chip:hover {
  border-color: var(--accent-cyan);
  transform: translateY(-2px);
}

.item-chip i {
  color: var(--accent-cyan);
}

/* Footer */
.app-footer {
  text-align: center;
  padding: 16px;
  font-size: 0.82rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border-color);
  margin-top: auto;
}

/* ==========================================================================
   ALARM RINGING MODAL & LIVE CAMERA SCANNER
   ========================================================================== */

.alarm-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.3s ease;
}

.modal-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(11, 15, 25, 0.95);
  backdrop-filter: blur(12px);
}

.modal-content {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 900px;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 2px solid var(--accent-red);
  box-shadow: var(--glow-red), 0 20px 50px rgba(0, 0, 0, 0.8);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  max-height: 95vh;
  overflow-y: auto;
}

/* Alert Banner */
.alarm-alert-banner {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid var(--accent-red);
  border-radius: var(--radius-md);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--accent-red);
  position: relative;
  overflow: hidden;
}

.alarm-alert-banner h2 {
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: 0.5px;
}

.pulse-ring {
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  background: rgba(239, 68, 68, 0.2);
  animation: flashAlert 1s infinite alternate;
}

@keyframes flashAlert {
  from { opacity: 0.2; }
  to { opacity: 0.6; }
}

/* Challenge Banner Box */
.challenge-box {
  background: linear-gradient(135deg, rgba(6, 182, 212, 0.15) 0%, rgba(236, 72, 153, 0.15) 100%);
  border: 1px solid var(--accent-cyan);
  border-radius: var(--radius-md);
  padding: 18px 24px;
  text-align: center;
}

.challenge-subtitle {
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 1.5px;
  color: var(--accent-cyan);
  display: block;
  margin-bottom: 4px;
}

#target-object-name {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.challenge-instruction {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* Main Scanner Layout Grid */
.scanner-container {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 20px;
  align-items: start;
}

@media (max-width: 768px) {
  .scanner-container {
    grid-template-columns: 1fr;
  }
}

/* Webcam Viewport Frame */
.webcam-viewport {
  position: relative;
  background: #000;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border-color);
  aspect-ratio: 4/3;
  display: flex;
  align-items: center;
  justify-content: center;
}

.webcam-wrapper {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.webcam-wrapper canvas,
.webcam-wrapper video {
  width: 100% !important;
  height: 100% !important;
  object-fit: cover;
}

/* Animated HUD Scanner Overlay */
.hud-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.hud-corner {
  position: absolute;
  width: 24px;
  height: 24px;
  border: 3px solid var(--accent-cyan);
}

.top-left { top: 12px; left: 12px; border-right: none; border-bottom: none; }
.top-right { top: 12px; right: 12px; border-left: none; border-bottom: none; }
.bottom-left { bottom: 12px; left: 12px; border-right: none; border-top: none; }
.bottom-right { bottom: 12px; right: 12px; border-left: none; border-top: none; }

.hud-line.horizontal {
  position: absolute;
  top: 50%;
  left: 10%;
  right: 10%;
  height: 1px;
  background: rgba(6, 182, 212, 0.3);
}

.hud-line.vertical {
  position: absolute;
  left: 50%;
  top: 10%;
  bottom: 10%;
  width: 1px;
  background: rgba(6, 182, 212, 0.3);
}

/* Real-Time Detection Panel */
.detection-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: var(--bg-input);
  padding: 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  height: 100%;
}

.detection-panel h4 {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.confidence-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 200px;
  overflow-y: auto;
  padding-right: 4px;
}

.confidence-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.confidence-item-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
  font-weight: 600;
}

.confidence-item-header.is-target {
  color: var(--accent-cyan);
  font-weight: 800;
}

.bar-bg {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-pill);
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  width: 0%;
  background: var(--accent-gradient);
  border-radius: var(--radius-pill);
  transition: width 0.15s ease-out;
}

.bar-fill.target-fill {
  background: var(--accent-gradient);
  box-shadow: var(--glow-cyan);
}

/* Consecutive Hold Verification Progress Bar */
.hold-progress-container {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.hold-progress-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--accent-green);
}

.progress-bar-bg {
  width: 100%;
  height: 12px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-pill);
  overflow: hidden;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.progress-bar-fill {
  height: 100%;
  width: 0%;
  background: var(--accent-green);
  box-shadow: 0 0 10px var(--accent-green);
  transition: width 0.1s linear;
}

/* Success Card Overlay */
.success-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(11, 15, 25, 0.95);
  backdrop-filter: blur(10px);
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 30px;
  animation: scaleUp 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.success-card {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  max-width: 480px;
}

.success-icon {
  width: 80px;
  height: 80px;
  background: rgba(16, 185, 129, 0.15);
  border: 2px solid var(--accent-green);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  color: var(--accent-green);
  box-shadow: 0 0 30px rgba(16, 185, 129, 0.5);
  animation: bounce 1s infinite alternate;
}

@keyframes bounce {
  from { transform: translateY(0); }
  to { transform: translateY(-10px); }
}

.success-card h2 {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--accent-green);
}

.success-card p {
  font-size: 0.95rem;
  color: var(--text-secondary);
}

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes scaleUp {
  from { transform: scale(0.8); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
