/* Dark sci-fi theme with neon accents and glassmorphism */
body {
  margin: 0;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(135deg, #ffecd2 0%, #fcb69f 100%);
  text-align: center;
  color: #333;
  transition: background 0.5s cubic-bezier(0.4, 0, 0.2, 1),
              color 0.5s ease;
}

/* Dark Mode with Smooth Transitions */
body.dark-mode {
  background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%);
  color: #e0e0e0;
  animation: fadeInDark 0.5s ease-in-out;
}

@keyframes fadeInDark {
  0% { opacity: 0.8; }
  100% { opacity: 1; }
}

@keyframes fadeInLight {
  0% { opacity: 0.8; }
  100% { opacity: 1; }
}

body:not(.dark-mode) {
  animation: fadeInLight 0.5s ease-in-out;
}

body.dark-mode header {
  background: linear-gradient(135deg, #0d3d42 0%, #0d5066 100%);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
}

body.dark-mode #resultBox {
  color: white;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.5);
}

body.dark-mode .info-box {
  background: rgba(50, 50, 50, 0.9);
  color: #e0e0e0;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
}

body.dark-mode .modal-content {
  background-color: #2d2d2d;
  color: #e0e0e0;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.7);
}

body.dark-mode .logs-list {
  color: #e0e0e0;
}

body.dark-mode .log-entry {
  background-color: #3a3a3a;
  color: #e0e0e0;
  border-left-color: #4dd0e1;
}

body.dark-mode .log-time {
  color: #aaa;
}

body.dark-mode .modal-header {
  background: linear-gradient(135deg, #0d3d42 0%, #0d5066 100%);
}

body.dark-mode .settings-section {
  border-bottom-color: #444;
}

body.dark-mode .logs-btn {
  background-color: #ff9800;
  box-shadow: 0 2px 8px rgba(255, 152, 0, 0.3);
}

body.dark-mode .logs-btn:hover {
  box-shadow: 0 4px 12px rgba(255, 152, 0, 0.5);
}

body.dark-mode .measurement-btn, body.dark-mode .buffer-btn {
  background-color: #ba68c8;
  box-shadow: 0 2px 8px rgba(186, 104, 200, 0.3);
}

body.dark-mode .measurement-btn:hover, body.dark-mode .buffer-btn:hover {
  box-shadow: 0 4px 12px rgba(186, 104, 200, 0.5);
}

body.dark-mode .settings-btn {
  background-color: #4caf50;
  box-shadow: 0 2px 8px rgba(76, 175, 80, 0.3);
}

body.dark-mode .settings-btn:hover {
  box-shadow: 0 4px 12px rgba(76, 175, 80, 0.5);
}

body.dark-mode .help-btn {
  background-color: #2196F3;
  box-shadow: 0 2px 8px rgba(33, 150, 243, 0.3);
}

body.dark-mode .help-btn:hover {
  box-shadow: 0 4px 12px rgba(33, 150, 243, 0.5);
}

header {
  background-color: #006064;
  color: white;
  padding: 20px;
  border-bottom-left-radius: 20px;
  border-bottom-right-radius: 20px;
  box-shadow: 0 4px 10px rgba(0,0,0,0.3);
  transition: background-color 0.5s cubic-bezier(0.4, 0, 0.2, 1),
              box-shadow 0.5s ease;
}

.header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

header h1 {
  font-size: 2.5rem;
  margin: 0;
}

.logs-btn {
  background-color: #ff9800;
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.3s;
}

.measurement-btn, .buffer-btn {
  background-color: #9c27b0;
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.3s;
}

.measurement-btn:hover, .buffer-btn:hover {
  background-color: #7b1fa2;
  transform: scale(1.05);
}

.logs-btn:hover {
  background-color: #e68900;
  transform: scale(1.05);
}

header p {
  font-size: 1rem;
  margin-top: 5px;
  color: #b2ebf2;
}

/* Tab navigation and content */
.tab-nav {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin: 20px 0;
}

.tab-btn {
  padding: 8px 16px;
  border: none;
  background: #ccc;
  border-radius: 5px;
  cursor: pointer;
  transition: background 0.3s;
}

.tab-btn.active {
  background: #006064;
  color: white;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* Personal notes styles */
.note-form, .note-list {
  margin: 20px auto;
  max-width: 500px;
  text-align: left;
}
.note-entry {
  background: #f5f5f5;
  padding: 10px;
  border-radius: 8px;
  margin-bottom: 8px;
}
.note-entry .biz-actions {
  margin-top: 6px;
}

#resultBox {
  margin: 40px auto;
  padding: 40px;
  width: 320px;
  border-radius: 20px;
  color: white;
  background-color: green;
  box-shadow: 0 8px 20px rgba(0,0,0,0.3);
  transition: background-color 0.5s cubic-bezier(0.4, 0, 0.2, 1),
              transform 0.3s,
              box-shadow 0.5s ease;
}

#resultBox.red {
  animation: pulse 1s infinite;
}

#resultBox.yellow {
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

.progress-bar {
  width: 100%;
  height: 15px;
  background: #eee;
  border-radius: 10px;
  margin-top: 15px;
  overflow: hidden;
}

#distanceBar {
  height: 100%;
  width: 0%;
  background: #00bfa5;
  transition: width 0.3s;
  border-radius: 10px;
}

.info-box {
  margin: 30px auto;
  padding: 20px;
  width: 400px;
  background: rgba(255,255,255,0.8);
  border-radius: 15px;
  box-shadow: 0 4px 15px rgba(0,0,0,0.2);
  text-align: left;
  transition: background 0.5s ease,
              color 0.5s ease,
              box-shadow 0.5s ease;
}

/* Modal Styles */
.modal {
  display: none;
  position: fixed;
  z-index: 1;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0,0,0,0.5);
}

.modal.active {
  display: flex;
  justify-content: center;
  align-items: center;
}

.modal-content {
  background-color: white;
  padding: 0;
  border-radius: 15px;
  width: 80%;
  max-width: 600px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
  transition: background-color 0.5s ease,
              color 0.5s ease,
              box-shadow 0.5s ease;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px;
  border-bottom: 2px solid #f0f0f0;
  background-color: #006064;
  color: white;
  border-radius: 15px 15px 0 0;
  transition: background-color 0.5s cubic-bezier(0.4, 0, 0.2, 1),
              border-bottom-color 0.5s ease;
}

.modal-header h2 {
  margin: 0;
  font-size: 1.5rem;
}

.close-btn {
  font-size: 2rem;
  cursor: pointer;
  color: white;
  transition: color 0.3s;
}

.close-btn:hover {
  color: #ff9800;
}

.logs-list {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  color: #333;
}

.log-entry {
  background-color: #f9f9f9;
  padding: 12px;
  margin: 8px 0;
  border-left: 4px solid #006064;
  border-radius: 5px;
  display: flex;
  justify-content: space-between;
}

.log-entry.danger {
  border-left-color: #f44336;
  background-color: #ffebee;
}

.log-entry.caution {
  border-left-color: #ff9800;
  background-color: #fff3e0;
}

.log-entry.safe {
  border-left-color: #4caf50;
  background-color: #f1f8f6;
}

.log-time {
  font-weight: bold;
  color: #666;
}

.log-details {
  color: #333;
  margin-left: 10px;
}

.modal-footer {
  padding: 15px;
  border-top: 1px solid #f0f0f0;
  text-align: right;
}

.clear-btn {
  background-color: #f44336;
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 8px;
  cursor: pointer;
  transition: background-color 0.3s;
}

.clear-btn:hover {
  background-color: #d32f2f;
}

/* Header Buttons */
.header-buttons {
  display: flex;
  gap: 10px;
}

.settings-btn {
  background-color: #4caf50;
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.3s;
}

.settings-btn:hover {
  background-color: #45a049;
  transform: scale(1.05);
}

/* Help Button */
.help-btn {
  background-color: #2196F3;
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.3s;
}

.help-btn:hover {
  background-color: #0b7dda;
  transform: scale(1.05);
}

/* Business Button */
.business-btn {
  background-color: #673ab7;
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.3s;
}

.business-btn:hover {
  background-color: #5b2fa6;
  transform: scale(1.05);
}

/* Business modal tweaks reuse existing modal styles */
.business-modal {
  max-width: 720px;
}

.business-modal .setting-item input,
.business-modal .setting-item textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #ccc;
  border-radius: 6px;
}

.business-entry {
  padding: 10px;
  border-bottom: 1px solid #eaeaea;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.business-entry .biz-actions button {
  margin-left: 8px;
}

/* Buffer controls styling */
#bufferCount {
  background: #f0f0f0;
  padding: 6px 10px;
  border-radius: 6px;
  font-weight: 600;
}

.clear-btn, .reset-btn { display: inline-block }

/* Splash overlay styles */
.splash {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.6);
  z-index: 9999;
  transition: opacity 0.5s ease, transform 0.5s ease;
}
.splash-content {
  background: white;
  padding: 26px 34px;
  border-radius: 12px;
  text-align: center;
  max-width: 540px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.4);
}
.splash h1 { margin: 0 0 8px 0; font-size: 1.6rem; }
.splash p { margin: 0; color: #444; }
.splash.hidden { opacity: 0; transform: scale(0.98); }

/* Overview banner shown after splash */
.overview-banner {
  position: fixed;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255,255,255,0.95);
  color: #222;
  padding: 10px 14px;
  border-radius: 8px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.15);
  display: none;
  opacity: 0;
  z-index: 9998;
  transition: opacity 0.5s ease, transform 0.4s ease;
}
.overview-banner.visible { display: block; opacity: 1; transform: translateX(-50%) translateY(0); }

body.dark-mode .splash-content { background: #222; color: #eaeaea; }
body.dark-mode .overview-banner { background: rgba(40,40,40,0.95); color: #eaeaea; }

/* Settings Modal */
.settings-modal {
  max-width: 500px;
}

.settings-container {
  padding: 20px;
  max-height: 60vh;
  overflow-y: auto;
}

.settings-section {
  margin-bottom: 25px;
  text-align: left;
  border-bottom: 1px solid #ddd;
  padding-bottom: 15px;
  transition: border-bottom-color 0.5s ease;
}

body.dark-mode .settings-section {
  border-bottom-color: #444;
}

.settings-section h3 {
  margin: 0 0 15px 0;
  color: #006064;
  font-size: 1.1rem;
  transition: color 0.5s ease;
}

body.dark-mode .settings-section h3 {
  color: #4dd0e1;
}

.setting-item {
  margin-bottom: 15px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.setting-item label {
  margin: 0;
  font-weight: 500;
  flex: 1;
}

/* Color Picker Group */
.color-picker-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.color-picker {
  width: 50px;
  height: 40px;
  border: 2px solid #ccc;
  border-radius: 5px;
  cursor: pointer;
  transition: border-color 0.5s ease,
              background-color 0.5s ease;
}

body.dark-mode .color-picker {
  border-color: #555;
  background-color: #3a3a3a;
}

.color-display {
  width: 40px;
  height: 40px;
  border-radius: 5px;
  border: 1px solid #999;
  display: inline-block;
  transition: background-color 0.3s ease,
              border-color 0.5s ease;
}

/* Toggle Switch */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 60px;
  height: 30px;
}

.toggle-input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  transition: background-color 0.5s cubic-bezier(0.4, 0, 0.2, 1),
              box-shadow 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 30px;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 24px;
  width: 24px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1),
              box-shadow 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 50%;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.toggle-input:checked + .toggle-slider {
  background-color: #2196F3;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1),
              0 0 15px rgba(33, 150, 243, 0.3);
}

.toggle-input:checked + .toggle-slider:before {
  transform: translateX(30px);
  box-shadow: 0 2px 8px rgba(33, 150, 243, 0.4);
}

/* Reset Button */
.reset-btn {
  width: 100%;
  background-color: #ff9800;
  color: white;
  border: none;
  padding: 12px 20px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1rem;
  transition: background-color 0.3s, box-shadow 0.3s;
}

.reset-btn:hover {
  background-color: #e68900;
}

/* Threshold Input */
.threshold-input-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.threshold-input {
  width: 80px;
  padding: 8px 10px;
  border: 2px solid #ccc;
  border-radius: 5px;
  font-size: 1rem;
  transition: border-color 0.3s, background-color 0.3s;
}

body.dark-mode .threshold-input {
  border-color: #555;
  background-color: #3a3a3a;
  color: #e0e0e0;
}

.threshold-input:focus {
  outline: none;
  border-color: #006064;
  box-shadow: 0 0 5px rgba(0, 96, 100, 0.3);
}

body.dark-mode .threshold-input:focus {
  border-color: #4dd0e1;
  box-shadow: 0 0 5px rgba(77, 208, 225, 0.3);
}

.threshold-value {
  display: inline-block;
  min-width: 40px;
  padding: 5px 10px;
  background-color: #f0f0f0;
  border-radius: 5px;
  font-weight: bold;
  color: #006064;
}

body.dark-mode .threshold-value {
  background-color: #3a3a3a;
  color: #4dd0e1;
}

/* Setting Info Box */
.setting-info {
  background-color: #f9f9f9;
  border-left: 4px solid #4caf50;
  padding: 12px;
  border-radius: 5px;
  margin-top: 12px;
  font-size: 0.9rem;
}

body.dark-mode .setting-info {
  background-color: #3a3a3a;
  border-left-color: #81c784;
  color: #e0e0e0;
}

.setting-info p {
  margin: 0 0 8px 0;
  font-weight: 600;
  color: #333;
}

body.dark-mode .setting-info p {
  color: #e0e0e0;
}

.setting-info ul {
  margin: 0;
  padding-left: 20px;
  color: #555;
}

body.dark-mode .setting-info ul {
  color: #ccc;
}

.setting-info li {
  margin: 4px 0;
}

/* ============ HELP MODAL STYLES ============ */
.help-modal {
  max-width: 700px;
  max-height: 85vh;
}

.help-container {
  padding: 20px;
  overflow-y: auto;
  max-height: 70vh;
}

.help-section {
  margin-bottom: 25px;
  padding-bottom: 20px;
  border-bottom: 2px solid #e0e0e0;
}

body.dark-mode .help-section {
  border-bottom-color: #444;
}

.help-section h3 {
  margin-top: 0;
  margin-bottom: 15px;
  color: #006064;
  font-size: 1.2rem;
}

body.dark-mode .help-section h3 {
  color: #4dd0e1;
}

.help-section ul {
  margin: 10px 0;
  padding-left: 25px;
  color: #333;
}

body.dark-mode .help-section ul {
  color: #e0e0e0;
}

.help-section li {
  margin: 8px 0;
  line-height: 1.5;
}

/* Alert Guide Styles */
.alert-guide {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.alert-item {
  display: flex;
  gap: 12px;
  padding: 12px;
  border-radius: 8px;
  background-color: #f9f9f9;
}

body.dark-mode .alert-item {
  background-color: #3a3a3a;
}

.alert-item.safe {
  background-color: #f1f8f6;
  border-left: 4px solid #4caf50;
}

body.dark-mode .alert-item.safe {
  background-color: #1a3a34;
  border-left-color: #81c784;
}

.alert-item.caution {
  background-color: #fff3e0;
  border-left: 4px solid #ff9800;
}

body.dark-mode .alert-item.caution {
  background-color: #3a2a1a;
  border-left-color: #ffb74d;
}

.alert-item.danger {
  background-color: #ffebee;
  border-left: 4px solid #f44336;
}

body.dark-mode .alert-item.danger {
  background-color: #3a1a1a;
  border-left-color: #ef5350;
}

.alert-color {
  width: 12px;
  height: 100%;
  border-radius: 4px;
}

.alert-item.safe .alert-color {
  background-color: #4caf50;
}

.alert-item.caution .alert-color {
  background-color: #ff9800;
}

.alert-item.danger .alert-color {
  background-color: #f44336;
}

.alert-info {
  flex: 1;
}

.alert-info strong {
  display: block;
  margin-bottom: 5px;
  color: #333;
  font-size: 1.05rem;
}

body.dark-mode .alert-info strong {
  color: #e0e0e0;
}

.alert-info p {
  margin: 5px 0;
  font-size: 0.9rem;
  color: #555;
}

body.dark-mode .alert-info p {
  color: #ccc;
}

/* Tutorial Section */
.tutorial-content {
  background-color: #f0f7ff;
  padding: 15px;
  border-radius: 8px;
  text-align: center;
}

body.dark-mode .tutorial-content {
  background-color: #1a2a3a;
}

.tutorial-btn {
  background-color: #2196F3;
  color: white;
  border: none;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 1rem;
  cursor: pointer;
  margin: 10px 0;
  transition: all 0.3s;
}

.tutorial-btn:hover {
  background-color: #0b7dda;
  transform: scale(1.05);
}

.voice-status {
  margin-top: 10px;
  font-size: 0.95rem;
  color: #666;
  font-style: italic;
}

body.dark-mode .voice-status {
  color: #aaa;
}

/* FAQ Styles */
.faq-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.faq-item {
  border: 1px solid #ddd;
  border-radius: 8px;
  overflow: hidden;
  background-color: #fafafa;
}

body.dark-mode .faq-item {
  border-color: #444;
  background-color: #2a2a2a;
}

.faq-toggle {
  width: 100%;
  padding: 12px 15px;
  background-color: #f5f5f5;
  border: none;
  text-align: left;
  cursor: pointer;
  font-weight: 600;
  color: #333;
  transition: all 0.3s;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

body.dark-mode .faq-toggle {
  background-color: #333;
  color: #e0e0e0;
}

.faq-toggle:hover {
  background-color: #e0e0e0;
}

body.dark-mode .faq-toggle:hover {
  background-color: #444;
}

.faq-toggle::after {
  content: "▼";
  font-size: 0.8rem;
  transition: transform 0.3s;
}

.faq-toggle.active::after {
  transform: rotate(-180deg);
}

.faq-answer {
  padding: 15px;
  background-color: white;
  color: #555;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
}

body.dark-mode .faq-answer {
  background-color: #2a2a2a;
  color: #ccc;
}

.faq-item.active .faq-answer {
  max-height: 500px;
  transition: max-height 0.3s ease;
}

.faq-answer p {
  margin: 0;
  line-height: 1.6;
}