/* ==========================================================================
   SCAN-TO-WAKE AI ALARM CLOCK - STYLESHEET
   Design: Modern Dark Glassmorphism, Neon Cyber Accents & Micro-Animations
   ========================================================================== */

:root {
  --font-main: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Color Palette */
  --bg-dark: #0b0f19;
  --bg-card: rgba(18, 24, 38, 0.75);
  --bg-card-hover: rgba(26, 35, 56, 0.85);
  --border-color: rgba(255, 255, 255, 0.1);
  --border-glow: rgba(0, 242, 254, 0.3);

  --accent-cyan: #00f2fe;
  --accent-blue: #4facfe;
  --accent-purple: #7f00ff;
  --accent-pink: #e100ff;
  --accent-green: #00e676;
  --accent-amber: #ffab00;
  --accent-red: #ff0055;

  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --shadow-main: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 20px rgba(0, 242, 254, 0.25);
  --shadow-red-glow: 0 0 30px rgba(255, 0, 85, 0.5);

  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 8px;

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

/* Reset & Global Base */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-main);
  background-color: var(--bg-dark);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 24px 16px;
  overflow-x: hidden;
  position: relative;
}

/* Background Glowing Orbs */
.app-background {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.glow-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.25;
  animation: floatOrb 18s ease-in-out infinite alternate;
}

.orb-1 {
  width: 450px;
  height: 450px;
  background: var(--accent-purple);
  top: -100px;
  left: -100px;
}

.orb-2 {
  width: 500px;
  height: 500px;
  background: var(--accent-cyan);
  bottom: -150px;
  right: -100px;
  animation-delay: -6s;
}

.orb-3 {
  width: 350px;
  height: 350px;
  background: var(--accent-pink);
  top: 40%;
  left: 50%;
  transform: translate(-50%, -50%);
  animation-delay: -12s;
}

@keyframes floatOrb {
  0% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(60px, 40px) scale(1.1); }
  100% { transform: translate(-40px, 80px) scale(0.95); }
}

/* App Container */
.container {
  width: 100%;
  max-width: 1100px;
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Header Section */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 16px 28px;
  box-shadow: var(--shadow-main);
  flex-wrap: wrap;
  gap: 16px;
}

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

.brand-icon {
  width: 48px;
  height: 48px;
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-blue));
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  color: #000;
  box-shadow: var(--shadow-glow);
}

.brand-text h1 {
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  background: linear-gradient(90deg, #ffffff, var(--accent-cyan));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-text .tagline {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: 0.5px;
}

/* Digital Clock */
.digital-clock-container {
  text-align: right;
  background: rgba(0, 0, 0, 0.3);
  padding: 8px 18px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.digital-clock {
  font-family: var(--font-mono);
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--accent-cyan);
  letter-spacing: 2px;
  text-shadow: 0 0 10px rgba(0, 242, 254, 0.4);
}

.digital-date {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Model Status Card */
.model-status-card {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px 24px;
  transition: var(--transition-normal);
}

.model-status-card.loading {
  border-color: rgba(79, 172, 254, 0.4);
  box-shadow: 0 0 15px rgba(79, 172, 254, 0.15);
}

.model-status-card.ready {
  border-color: rgba(0, 230, 118, 0.4);
  background: rgba(0, 230, 118, 0.05);
}

.model-status-card.error {
  border-color: rgba(255, 0, 85, 0.4);
  background: rgba(255, 0, 85, 0.05);
}

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

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

.status-check-icon {
  font-size: 20px;
  color: var(--accent-green);
}

.status-info {
  flex: 1;
}

.status-title {
  font-weight: 700;
  font-size: 0.95rem;
}

.status-detail {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.status-badge {
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 1px;
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-muted);
}

.model-status-card.ready .status-badge {
  background: rgba(0, 230, 118, 0.2);
  color: var(--accent-green);
}

.model-status-card.error .status-badge {
  background: rgba(255, 0, 85, 0.2);
  color: var(--accent-red);
}

/* Main Dashboard Grid */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

@media (max-width: 840px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
}

/* Glassmorphism Cards */
.card {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-main);
  display: flex;
  flex-direction: column;
  gap: 20px;
}

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

.card-header h2 {
  font-size: 1.15rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-main);
}

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

/* Alarm Status Pill */
.alarm-status-pill {
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 1px;
}

.alarm-status-pill.disabled {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-dim);
}

.alarm-status-pill.active {
  background: rgba(0, 242, 254, 0.2);
  color: var(--accent-cyan);
  box-shadow: 0 0 10px rgba(0, 242, 254, 0.3);
  animation: pulsePill 2s infinite;
}

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

/* Alarm Time Controls */
.alarm-time-display {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px 20px;
}

.time-picker-wrapper input[type="time"] {
  background: transparent;
  border: none;
  font-family: var(--font-mono);
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--text-main);
  outline: none;
  cursor: pointer;
}

.time-picker-wrapper input[type="time"]::-webkit-calendar-picker-indicator {
  filter: invert(1);
  cursor: pointer;
  opacity: 0.7;
}

/* Switch Toggle Component */
.alarm-toggle-container {
  display: flex;
  align-items: center;
  gap: 12px;
}

.switch {
  position: relative;
  display: inline-block;
  width: 54px;
  height: 30px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: rgba(255, 255, 255, 0.15);
  transition: .3s;
  border-radius: 34px;
  border: 1px solid var(--border-color);
}

.slider:before {
  position: absolute;
  content: "";
  height: 22px;
  width: 22px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .3s;
  border-radius: 50%;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
}

input:checked + .slider {
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-blue));
}

input:checked + .slider:before {
  transform: translateX(24px);
}

.toggle-label {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-muted);
}

/* Quick Presets */
.quick-presets {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.preset-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-right: 4px;
}

.btn-preset {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
}

.btn-preset:hover {
  background: rgba(0, 242, 254, 0.15);
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
}

.divider {
  height: 1px;
  background: var(--border-color);
  margin: 4px 0;
}

/* Select Input Styling */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-group label {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
}

.select-wrapper {
  position: relative;
  width: 100%;
}

.select-wrapper select {
  width: 100%;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  font-family: var(--font-main);
  font-size: 0.95rem;
  color: var(--text-main);
  appearance: none;
  outline: none;
  cursor: pointer;
  transition: var(--transition-fast);
}

.select-wrapper select:focus {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 10px rgba(0, 242, 254, 0.2);
}

.select-arrow {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.field-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* Buttons */
.action-buttons {
  display: flex;
  gap: 12px;
  margin-top: 4px;
}

.btn {
  flex: 1;
  padding: 12px 18px;
  border-radius: var(--radius-md);
  font-family: var(--font-main);
  font-size: 0.9rem;
  font-weight: 700;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: var(--transition-fast);
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-blue));
  color: #000;
  box-shadow: 0 4px 15px rgba(0, 242, 254, 0.3);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 242, 254, 0.5);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.25);
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--accent-cyan);
  color: var(--accent-cyan);
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  cursor: pointer;
}

.btn-outline:hover {
  background: rgba(0, 242, 254, 0.15);
}

.btn-danger {
  background: linear-gradient(135deg, #ff0055, #ff5252);
  color: white;
  box-shadow: 0 4px 15px rgba(255, 0, 85, 0.4);
}

.btn-danger:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(255, 0, 85, 0.6);
}

/* Vision Card & Camera Viewport */
.vision-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.live-dot {
  width: 8px;
  height: 8px;
  background-color: var(--text-dim);
  border-radius: 50%;
}

.live-dot.active {
  background-color: var(--accent-green);
  box-shadow: 0 0 8px var(--accent-green);
  animation: blink 1.2s infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.webcam-container {
  width: 100%;
  height: 240px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.webcam-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
  padding: 20px;
  color: var(--text-muted);
}

.webcam-placeholder i {
  font-size: 2.8rem;
  color: var(--text-dim);
}

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

#webcam-canvas {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Animated Scanner HUD Overlay */
.scanner-overlay {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  pointer-events: none;
}

.scan-corner {
  position: absolute;
  width: 20px;
  height: 20px;
  border-color: var(--accent-cyan);
  border-style: solid;
}

.top-left { top: 12px; left: 12px; border-width: 3px 0 0 3px; }
.top-right { top: 12px; right: 12px; border-width: 3px 3px 0 0; }
.bottom-left { bottom: 12px; left: 12px; border-width: 0 0 3px 3px; }
.bottom-right { bottom: 12px; right: 12px; border-width: 0 3px 3px 0; }

.scan-line {
  position: absolute;
  left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent-cyan), transparent);
  box-shadow: 0 0 10px var(--accent-cyan);
  animation: scanMove 2.5s ease-in-out infinite alternate;
}

@keyframes scanMove {
  0% { top: 10%; }
  100% { top: 90%; }
}

.target-badge {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  border: 1px solid var(--accent-cyan);
  padding: 4px 14px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--accent-cyan);
}

/* Predictions Panel */
.predictions-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.predictions-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 600;
}

.loop-badge {
  font-size: 0.7rem;
  background: rgba(127, 0, 255, 0.2);
  color: #c084fc;
  padding: 2px 8px;
  border-radius: 10px;
}

.predictions-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 80px;
}

.empty-predictions {
  text-align: center;
  font-size: 0.82rem;
  color: var(--text-dim);
  padding: 16px;
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-sm);
}

/* Prediction Class Bar */
.prediction-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.prediction-label-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
  font-weight: 600;
}

.class-name {
  color: var(--text-main);
}

.class-percentage {
  font-family: var(--font-mono);
  color: var(--accent-cyan);
}

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

.prediction-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-blue), var(--accent-cyan));
  border-radius: 4px;
  transition: width 0.15s ease-out;
}

.prediction-row.target-match .prediction-bar-fill {
  background: linear-gradient(90deg, var(--accent-green), #69f0ae);
  box-shadow: 0 0 8px var(--accent-green);
}

/* Alarm Ringing Modal Overlay */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(5, 5, 10, 0.88);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.3s ease;
}

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

.alarm-modal-content {
  width: 100%;
  max-width: 480px;
  background: var(--bg-card);
  border: 2px solid var(--accent-red);
  border-radius: var(--radius-lg);
  padding: 30px 24px;
  box-shadow: var(--shadow-red-glow);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 20px;
  position: relative;
  animation: modalPulse 1.5s infinite alternate;
}

@keyframes modalPulse {
  0% { box-shadow: 0 0 20px rgba(255, 0, 85, 0.4); }
  100% { box-shadow: 0 0 50px rgba(255, 0, 85, 0.8); }
}

.alarm-icon-ring {
  width: 64px;
  height: 64px;
  background: rgba(255, 0, 85, 0.15);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  color: var(--accent-red);
  border: 1px solid var(--accent-red);
}

.alarm-title {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--accent-red);
  letter-spacing: 1px;
}

.alarm-subtitle {
  font-size: 0.88rem;
  color: var(--text-muted);
}

.target-instruction-card {
  width: 100%;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 0, 85, 0.3);
  border-radius: var(--radius-md);
  padding: 12px;
}

.target-label-sm {
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 1px;
  color: var(--accent-amber);
}

.target-name {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--accent-cyan);
  margin: 4px 0;
}

.modal-webcam-box {
  width: 100%;
  height: 220px;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 2px solid var(--accent-cyan);
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Disarm Progress Bar */
.disarm-progress-box {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: relative;
}

.disarm-progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  font-weight: 700;
}

.progress-bar-track {
  width: 100%;
  height: 14px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 7px;
  overflow: hidden;
  border: 1px solid var(--border-color);
}

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

.threshold-marker {
  font-size: 0.7rem;
  color: var(--accent-green);
  text-align: right;
  font-weight: 700;
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  background: rgba(18, 24, 38, 0.95);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  padding: 12px 20px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-main);
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.88rem;
  color: var(--text-main);
  animation: slideToast 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

@keyframes slideToast {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.toast.info i { color: var(--accent-cyan); }
.toast.success i { color: var(--accent-green); }
.toast.warning i { color: var(--accent-amber); }
.toast.error i { color: var(--accent-red); }

/* Utility Classes */
.hidden {
  display: none !important;
}
