/* ===========================
  Basic Reset & Base Styles
  =========================== */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
}

body {
  display: flex;
  flex-direction: column;
  font-family: 'Poppins', Arial, sans-serif;
  background: linear-gradient(135deg, #1e293b, #0f172a);
  color: #fff;
  line-height: 1.6;
  transition: background 0.5s, color 0.5s;
  overscroll-behavior: none;
}

/* Dark Mode */
body.dark {
  background: linear-gradient(135deg, #1f1f1f, #1a1a1a);
}

/* ===========================
  Main Content Wrapper
  =========================== */
main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
}

/* ===========================
  Logo / Page Title
  =========================== */
.logo {
  font-size: 2.5em;
  font-weight: bold;
  text-shadow: 0 4px 6px rgba(0,0,0,0.3), 0 0 15px rgba(72,157,241,0.5);
  background: linear-gradient(90deg, #4caf50, #2563eb);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-align: center;
  animation: glow 2s infinite;
  user-select: none;
  margin-bottom: 25px;
  will-change: text-shadow;
  font-family: sans-serif;
}

@keyframes glow {
  0%, 100% {
   text-shadow: 0 0 5px rgba(72,157,241,0.5), 0 0 10px rgba(76,175,80,0.7);
  }
  50% {
   text-shadow: 0 0 15px rgba(72,157,241,0.8), 0 0 20px rgba(76,175,80,1);
  }
}

/* ===========================
  Search Bar Section
  =========================== */
.search-container {
  width: 100%;
  max-width: 600px;
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 0 auto;
  background: rgba(255,255,255,0.05);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 16px;
  padding: 24px;
  transition: transform 0.3s;
}

.search-container:hover {
  transform: translateY(-3px);
}

.input-wrapper {
  position: relative;
  width: 100%;
  margin-bottom: 20px;
}

#inputbox {
  width: 100%;
  padding: 15px 20px 15px 20px;
  padding-right: 55px;
  font-size: 18px;
  border: none;
  border-radius: 50px;
  outline: none;
  background: rgba(255,255,255,0.1);
  color: #fff;
  box-shadow: inset 0 2px 5px rgba(0,0,0,0.2), 0 0 10px rgba(255,255,255,0.2);
  transition: background-color 0.3s, box-shadow 0.3s;
  caret-color: #fff;
}

#inputbox:focus {
  background: rgba(255,255,255,0.15);
  box-shadow: 0 0 15px rgba(255,255,255,0.6);
}

#inputbox:-webkit-autofill,
#inputbox:-webkit-autofill:hover,
#inputbox:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0 1000px rgba(255,255,255,0.1) inset !important;
  -webkit-text-fill-color: #fff !important;
  transition: background-color 5000s ease-in-out 0s;
}

#inputbox::placeholder {
  color: rgba(255,255,255,0.7);
  transition: opacity 0.3s;
}

#inputbox:focus::placeholder {
  opacity: 0.9;
}

/* ===========================
  Mic Icon (Voice Icon)
  =========================== */
.mic-icon {
  position: absolute;
  top: 50%;
  right: 15px;
  transform: translateY(-50%);
  width: 35px;
  height: 35px;
  background: rgba(255,255,255,0.1);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.3s, box-shadow 0.3s;
  color: #fff;
  font-size: 18px;
  z-index: 10;
  user-select: none;
}

.mic-icon:hover {
  background: rgba(255,255,255,0.2);
  box-shadow: 0 0 12px rgba(255,255,255,0.2);
}

.mic-icon.active {
  background: rgba(255,255,255,0.3);
}

/* Voice Icon Wave Animation */
@keyframes voiceWave {
  0%, 100% { transform: scaleY(1);}
  50% { transform: scaleY(1.4);}
}

.mic-icon.active rect:nth-child(1) { animation: voiceWave 1s infinite ease-in-out; }
.mic-icon.active rect:nth-child(2) { animation: voiceWave 1s infinite ease-in-out; animation-delay: 0.1s; }
.mic-icon.active rect:nth-child(3) { animation: voiceWave 1s infinite ease-in-out; animation-delay: 0.2s; }
.mic-icon.active rect:nth-child(4) { animation: voiceWave 1s infinite ease-in-out; animation-delay: 0.1s; }
.mic-icon.active rect:nth-child(5) { animation: voiceWave 1s infinite ease-in-out; }

/* ===========================
  Slider & Tooltip
  =========================== */
.slider-container {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  max-width: 500px;
  margin-bottom: 20px;
  position: relative;
}

.tooltip {
  position: absolute;
  top: -35px;
  font-size: 0.9em;
  color: #fff;
  background: rgba(0,0,0,0.7);
  padding: 5px 10px;
  border-radius: 5px;
  visibility: hidden;
  opacity: 0;
  transition: visibility 0.2s, opacity 0.2s;
  pointer-events: none;
  z-index: 10;
}

.slider-container:hover .tooltip {
  visibility: visible;
  opacity: 1;
}

.slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 12px;
  background: linear-gradient(90deg, #2563eb, #4caf50, #e11d48);
  border-radius: 10px;
  outline: none;
  transition: opacity 0.2s, background 0.3s, box-shadow 0.3s;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
  -webkit-tap-highlight-color: transparent;
}

.slider:hover {
  box-shadow: 0 0 10px rgba(255,255,255,0.3);
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 24px;
  height: 24px;
  background: #fff;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0,0,0,0.3), 0 0 0 4px rgba(76,175,80,0.2);
  transition: box-shadow 0.3s, transform 0.2s;
  border: 2px solid #4caf50;
}

.slider::-webkit-slider-thumb:hover {
  box-shadow: 0 4px 8px rgba(0,0,0,0.4), 0 0 0 6px rgba(76,175,80,0.3);
  transform: scale(1.1);
}

.slider::-moz-range-thumb {
  width: 24px;
  height: 24px;
  background: #fff;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0,0,0,0.3), 0 0 0 4px rgba(76,175,80,0.2);
  border: 2px solid #4caf50;
  transition: box-shadow 0.3s, transform 0.2s;
}

.slider::-moz-range-thumb:hover {
  box-shadow: 0 4px 8px rgba(0,0,0,0.4), 0 0 0 6px rgba(76,175,80,0.3);
  transform: scale(1.1);
}

.slider::-moz-range-track {
  width: 100%;
  height: 12px;
  background: linear-gradient(90deg, #2563eb, #4caf50, #e11d48);
  border-radius: 10px;
}

/* ===========================
  Search Button
  =========================== */
#searchBtn {
  padding: 12px 30px;
  font-size: 18px;
  color: #fff;
  background-color: var(--btn-color, #4caf50);
  border: none;
  border-radius: 50px;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s, background 0.3s;
  box-shadow: 0 4px 6px rgba(0,0,0,0.3);
  -webkit-tap-highlight-color: transparent;
}

#searchBtn:hover {
  transform: scale(1.05);
  box-shadow: 0 0 15px var(--btn-hover-color, rgba(76,175,80,0.7));
}

/* ===========================
  Dark Mode Toggle Button
  =========================== */
.dark-mode-toggle {
  background: transparent;
  border: none;
  color: #fff;
  cursor: pointer;
  position: fixed;
  top: 20px;
  right: 20px;
  padding: 8px;
  font-size: 16px;
  transition: transform 0.3s, opacity 0.3s;
  border-radius: 4px;
}

.dark-mode-toggle:hover {
  opacity: 0.8;
  transform: scale(1.1);
}

.dark-mode-toggle .toggle-icon {
  width: 24px;
  height: 24px;
  transition: transform 0.5s, opacity 0.5s;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
}

body.dark .dark-mode-toggle .toggle-icon {
  transform: rotate(180deg);
}

/* ===========================
  Search History Styles
  =========================== */
.search-history {
  margin-top: 20px;
  width: 100%;
  max-width: 600px;
}

.search-history ul,
.search-history-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.search-history li,
.search-history-list li {
  position: relative;
  padding: 8px 35px 8px 8px;
  cursor: pointer;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  border-radius: 12px;
  transition: background 0.3s, transform 0.2s;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.search-history li:last-child {
  border-bottom: none;
}

.search-history li:hover,
.search-history-list .dragging {
  background: rgba(255,255,255,0.1);
}

.search-history-list li {
  cursor: grab;
}

.search-history-list .dragging {
  transform: scale(1.05);
  opacity: 0.8;
}

.remove-icon {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  cursor: pointer;
  display: none;
  color: rgba(255,255,255,0.6);
  transition: transform 0.2s, color 0.2s;
}

.search-history li:hover .remove-icon {
  display: block;
}

.remove-icon:hover {
  transform: translateY(-50%) scale(1.1);
  color: rgba(255,255,255,0.8);
}

/* ===========================
  Responsive & Accessibility
  =========================== */
@media (max-width: 768px) {
  .logo { font-size: 2em; }
  #inputbox { font-size: 16px; padding: 12px 50px 12px 15px; }
  #searchBtn { font-size: 16px; padding: 10px 25px; }
  .tooltip { font-size: 0.8em; }
}

@media (max-width: 480px) {
  .logo { font-size: 1.8em; }
  #inputbox { font-size: 14px; padding: 10px 50px 10px 12px; }
  .mic-icon { width: 30px; height: 30px; font-size: 16px; }
  #searchBtn { font-size: 14px; padding: 8px 20px; }
  .tooltip { font-size: 0.7em; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ===========================
  Focus & User Select
  =========================== */
:focus {
  outline: 2px solid #60a5fa;
  outline-offset: 2px;
}

.dark-mode-toggle:focus,
.dark-mode-toggle:active,
.mic-icon:focus,
.mic-icon:active,
.slider-container:focus,
.slider-container:active,
.slider:focus,
.slider:active,
.tooltip:focus,
.tooltip:active {
  outline: none !important;
  outline-offset: 0 !important;
  box-shadow: none !important;
  -webkit-tap-highlight-color: transparent !important;
}

.logo,
.mic-icon,
#searchBtn,
.dark-mode-toggle,
.slider,
.tooltip {
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

#inputbox {
  -webkit-user-select: text;
  -moz-user-select: text;
  -ms-user-select: text;
  user-select: text;
}
