/* styles.css */

/* Reset and base styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

html, body {
  background: linear-gradient(135deg, #0a0d12, #1c0f0f); /* Darker with red undertone */
  height: 100%; /* Full height, respects viewport */
  width: 100%;
  overflow: hidden; /* Disable all scrolling */
  display: flex;
  flex-direction: column;
  align-items: center;
  color: #d1d5db;
  transition: font-size 0.3s ease;
}

body.accessibility {
  font-size: 1.25rem;
}

/* Menu Bar */
#menuBar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 20px;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 -2px 5px rgba(0, 0, 0, 0.4);
  z-index: 1000;
  height: 64px;
}

#channelIndicator, #usersOnline, #personIcon {
  display: flex;
  align-items: center;
  cursor: pointer;
  padding: 8px 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  transition: background 0.2s ease;
  min-width: 32px;
  height: 100%;
}

#channelIndicator:hover, #usersOnline:hover, #personIcon:hover {
  background: rgba(255, 255, 255, 0.1);
}

#userCount {
  margin-left: 8px;
  font-weight: 600;
  color: white; /* Red accent */
}

/* Overlay */
#overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

#overlay.active {
  opacity: 1;
  pointer-events: auto;
}

/* Sidebar */
#sidebar {
  position: fixed;
  bottom: -100%;
  left: 0;
  right: 0;
  height: 60vh;
  max-height: 500px;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.5);
  padding: 20px;
  transition: bottom 0.3s ease;
  z-index: 1001;
  display: flex;
  flex-direction: column;
}

#sidebar.active {
  bottom: 0;
}

#sidebar-tabs {
  display: flex;
  justify-content: space-around;
  margin-top: auto; /* Pins tabs to bottom */
  margin-bottom: 20px; /* Respectable margin */
}

#sidebar-tabs span {
  padding: 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  cursor: pointer;
  transition: background 0.2s ease;
}

#sidebar-tabs span.active {
  background: rgba(255, 255, 255, 0.15);
}

#sidebar-tabs img {
  width: 24px;
  height: 24px;
}

#tab-home, #tab-mic, #tab-info {
  display: none;
}

#tab-home.active, #tab-mic.active, #tab-info.active {
  display: block;
}

label {
  display: block;
  margin: 15px 0 10px;
  font-weight: 500;
  color: #d1d5db;
}

.input-container {
  margin-bottom: 20px;
}

input[type="text"], select {
  width: 100%;
  padding: 10px;
  border: none;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  color: #d1d5db;
  font-size: 1rem;
  transition: background 0.2s ease;
}

input[type="text"]:hover, select:hover {
  background: rgba(255, 255, 255, 0.1);
}

input[type="checkbox"], input[type="radio"] {
  margin-right: 8px;
  accent-color: #ef4444; /* Red accent */
}

.option-container {
  margin: 20px 0; /* Spaced-out for echo mode and app sounds */
}

.radio-option-container {
  margin: 10px 0; /* Tighter spacing before Rec button mode */
}

.radio-group {
  display: flex;
  flex-direction: column;
  gap: 6px; /* Tighter spacing for Hold to talk and Click to start/stop */
}

.radio-group label {
  margin: 5px 0; /* Tighter spacing for radio labels */
}

.button-container button {
  display: block;
  width: 100%;
  padding: 12px;
  margin: 10px 0;
  border: none;
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(153, 27, 27, 0.8), rgba(220, 38, 38, 0.8)); /* Darker red with transparency */
  color: white;
  font-size: 1rem; /* Matches Rec button mode */
  font-weight: 500; /* Matches Rec button mode */
  cursor: pointer;
  transition: background 0.2s ease, transform 0.1s ease;
}

.button-container button:hover {
  background: linear-gradient(135deg, rgba(127, 29, 29, 0.8), rgba(153, 27, 27, 0.8));
  transform: translateY(-2px);
}

.button-container button:active {
  transform: translateY(0);
}

/* Indicators */
#indicators {
  position: fixed;
  top: 20px; /* Top-right */
  left: 0;
  right: 0;
  display: flex;
  justify-content: flex-end; /* All indicators to the right */
  align-items: center;
  padding: 0 20px;
  font-size: 0.75rem; /* Smaller text */
  color: #d1d5db;
  gap: 15px;
}

#versionIndicator, #indicators > span {
  flex: 0 0 auto; /* Grouped tightly */
  text-shadow: 0 0 8px rgba(0, 0, 0, 0.8); /* Black glow */
}

.indicator {
  display: inline-block;
  width: 8px; /* Smaller dots */
  height: 8px;
  border-radius: 50%;
  background: #4a1b1b; /* Very dark red for inactive */
  margin-right: 5px;
  -webkit-animation: flicker 1.5s infinite; /* Vendor prefix for Safari */
  -moz-animation: flicker 1.5s infinite; /* Vendor prefix for Firefox */
  -o-animation: flicker 1.5s infinite; /* Vendor prefix for Opera */
  animation: flicker 1.5s infinite; /* Standard animation */
}

.indicator.active {
  background: #ef4444; /* Red for active */
  -webkit-animation: none; /* Stop flicker when active */
  -moz-animation: none; /* Stop flicker when active */
  -o-animation: none; /* Stop flicker when active */
  animation: none; /* Stop flicker when active */
}

#netIndicator.disconnected {
  background: #ef4444; /* Red accent for disconnected state */
}

/* Flicker Animation */
@-webkit-keyframes flicker { /* Vendor prefix for Safari */
  0% { opacity: 0.7; }
  50% { opacity: 1; }
  100% { opacity: 0.7; }
}
@-moz-keyframes flicker { /* Vendor prefix for Firefox */
  0% { opacity: 0.7; }
  50% { opacity: 1; }
  100% { opacity: 0.7; }
}
@-o-keyframes flicker { /* Vendor prefix for Opera */
  0% { opacity: 0.7; }
  50% { opacity: 1; }
  100% { opacity: 0.7; }
}
@keyframes flicker { /* Standard animation */
  0% { opacity: 0.7; }
  50% { opacity: 1; }
  100% { opacity: 0.7; }
}

/* App Main Area */
#app {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 600px;
  min-height: 100vh; /* Respect viewport */
  height: 100%; /* Fit within parent */
  margin: 0 auto; /* Center without adding height */
  position: relative; /* For absolute positioning of children */
  overflow: hidden; /* Prevent internal scrolling */
}

/* Controls Container for Buttons and Record Progress */
#controlsContainer {
  position: absolute;
  top: 43vh; /* Unchanged, higher position */
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 600px;
}

#playbackInfo {
  position: absolute;
  top: 20vh; /* Fixed high position */
  text-align: center;
  padding: 10px;
  border-radius: 10px;
  /* Transparent, no background or backdrop-filter */
  opacity: 0;
  transition: opacity 0.3s ease; /* Fade-in and fade-out */
  width: 90vw;
  user-select: none; /* Prevent text/image selection */
  -webkit-touch-callout: none; /* Disable iOS context menu */
  touch-action: manipulation; /* Optimize touch behavior */
}

#playbackInfo.active {
  opacity: 1;
}

#currentSpeaker {
  font-size: 1.8rem; /* Unchanged */
  font-weight: 600;
  color: #ffffff; /* White text */
}

#playbackCounter {
  font-size: 1.0rem; /* Unchanged */
  color: #d1d5db;
}

#recordProgress {
  width: 160px; /* Matches larger talk button */
  height: 8px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 20px;
  opacity: 0;
  transition: opacity 0.3s ease;
}

#recordProgress.active {
  opacity: 1;
}

#recordProgressBar {
  height: 100%;
  width: 100%;
  background: #34c759;
  transition: width 0.1s linear, background 0.3s ease;
}

#buttonContainer {
  display: flex;
  align-items: center; /* Vertically center buttons */
  justify-content: center; /* Center buttons, no edge hugging */
  gap: 45px; /* Increased gap for better spacing */
  padding: 0 20px; /* Unchanged, prevent buttons from hitting edges */
  width: 100%; /* Ensure full width within app */
}

/* Buttons */
#talkButton, #skipButton, #blockButton {
  border: none;
  border-radius: 12px; /* Default for skip and block */
  background-size: 60% auto; /* Adjusted for square SVG fit */
  background-position: center;
  background-repeat: no-repeat; /* Prevent tiling */
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.2s ease, opacity 0.3s ease;
  user-select: none; /* Prevent text/image selection */
  -webkit-touch-callout: none; /* Disable iOS context menu */
  touch-action: manipulation; /* Optimize touch behavior */
}

#talkButton {
  width: 160px; /* Larger size */
  height: 160px;
  background-image: url('img/mic.svg');
  background-color: #002147; /* Ominous dark blue default */
  border-radius: 20px; /* More rounded corners */
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
}

#talkButton.talking {
  background-color: #3b82f6; /* Eerie brighter blue when talking */
}

#talkButton.disabled {
  background-color: #333333; /* Gray when disabled */
  cursor: not-allowed;
}

#skipButton {
  width: 80px;
  height: 80px;
  background-image: url('img/skip.svg');
  background-color: rgba(34, 139, 34, 0.8);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  opacity: 0.5; /* Fade to 50% transparency */
  transition: opacity 0.3s ease; /* Fade-in and fade-out */
}

#skipButton.active {
  opacity: 1;
}

#blockButton {
  width: 80px;
  height: 80px;
  background-image: url('img/block.svg');
  background-size: 50% auto; /* Smaller icon for square fit */
  background-color: rgba(127, 29, 29, 0.8); /* Dark red body */
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  opacity: 0.5; /* Fade to 50% transparency */
  transition: opacity 0.3s ease; /* Fade-in and fade-out */
}

#blockButton.active {
  opacity: 1;
}

#talkButton:hover, #skipButton:hover, #blockButton:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.6);
}

#talkButton:active, #skipButton:active, #blockButton:active {
  transform: scale(0.95);
}

/* User List Modal */
#userListModal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 1002;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

#userListModal.active {
  opacity: 1;
  pointer-events: auto;
}

#userList {
  width: 90%;
  max-width: 400px;
  max-height: 60vh;
  overflow-y: auto;
  background: rgba(0, 0, 0, 0.5);
  border-radius: 15px;
  padding: 20px;
  list-style: none;
}

#userList li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.15);
}

#userList li:last-child {
  border-bottom: none;
}

.channel-info, .user-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.nickname {
  font-weight: 500;
  color: #ef4444; /* Red accent */
}

.block-btn {
  background: none;
  border: none;
  cursor: pointer;
}

.block-btn img {
  width: 24px;
  height: 24px;
}

#userListCloseButton {
  margin-top: 20px;
}

#closeUserList {
  padding: 12px 24px;
  border: none;
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(153, 27, 27, 0.8), rgba(220, 38, 38, 0.8)); /* Darker red with transparency */
  color: white;
  font-size: 1rem; /* Matches Rec button mode */
  font-weight: 500; /* Matches Rec button mode */
  cursor: pointer;
  transition: background 0.2s ease, transform 0.1s ease;
}

#closeUserList:hover {
  background: linear-gradient(135deg, rgba(127, 29, 29, 0.8), rgba(153, 27, 27, 0.8));
  transform: translateY(-2px);
}

#closeUserList:active {
  transform: translateY(0);
}

/* Responsive adjustments */
@media (max-width: 600px) {
  #sidebar {
    height: 80vh;
  }

  #menuBar {
    padding: 8px;
  }

  #indicators {
    top: 15px; /* Adjusted for mobile */
    padding: 0 15px;
  }

  #controlsContainer {
    top: 46vh; /* Unchanged, higher position */
  }

  #buttonContainer {
    gap: 40px; /* Increased gap for better spacing on mobile */
    padding: 0 15px; /* Unchanged, prevent buttons from hitting edges */
    justify-content: center; /* Center buttons, no edge hugging */
  }

  #talkButton {
    width: 140px; /* Larger size for mobile */
    height: 140px;
    border-radius: 20px; /* Keep rounded corners consistent */
  }

  #recordProgres {
    width: 140px; /* Matches larger talk button */
  }

  #playbackInfo {
    width: 90vw; /* Matches larger talk button */
  }
  
  #skipButton, #blockButton {
    width: 60px;
    height: 60px;
    background-size: 50% auto; /* Smaller icon for square fit on mobile */
  }
}