/* Global Styling */
/* Prevent long-press zooming & saving images on iOS */
* {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

body {
  background: #121212;
  color: #e0e0e0;
  font-family: 'Noto Sans JP', sans-serif;
  overflow: hidden;
  height: 100dvh;
}

.chat-container {
  background: rgba(24, 24, 24, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.1);
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
  overflow:hidden; /* TEMP FIX FOR BLINK ISSUE DISPLAY ISSUE ON TABLE. ITS FINE IN FULL SCREEN AND PWA. */

}

/* Fix chat box to display messages at the bottom */
.chat-box {
  display: flex;
  flex-direction: column;
  justify-content: flex-end; /* Keeps .messages-container at the bottom */
  padding-top: 60px; /* Add space for header */
  flex: 1;
  position: relative;
  mask-image: linear-gradient(to bottom, transparent 0%, transparent 50%, black 80%);
  -webkit-mask-image: linear-gradient(to bottom, transparent 0%, transparent 50%, black 80%);
}

.messages-container {
  width: 100%;
  padding: 10px 0;
  overflow-y: auto; 
  scrollbar-width: none; /* Hide scrollbar in Firefox */
  -ms-overflow-style: none; /* Hide scrollbar in IE/Edge */
  max-height: calc(100vh - 280px);
  height: 50%;
  overflow-anchor: auto;
  scroll-behavior: smooth; /* For smooth scrolling */
}

/* Hide scrollbar in WebKit browsers (Chrome, Safari, newer Edge) */
.messages-container::-webkit-scrollbar {
  display: none;
}

/* Header Styling */
@keyframes headerFadeOut {
  from { opacity: 0.90; }
  to { opacity: 0; }
}

@keyframes headerFadeIn {
  from { opacity: 0; }
  to { opacity: 0.90; }
}

.chat-header {
  display: flex;
  position: absolute;
  width: 100%;
  top: -5px;
  left:1px;
  background-color: rgba(24, 24, 24, 0.90);
  z-index: 10;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  will-change: opacity;
  opacity: 0.90;
}

/* Header Styling - Andrews fading header */
.chat-header.hidden {
  animation: headerFadeOut 3s forwards;
  pointer-events: auto; 
}

/* Header Styling - Andrews Fading Header */
.chat-header.interactive {
  animation: headerFadeIn 0.5s forwards;
  pointer-events: auto;
}

.logo {
  font-size: 1.6rem;
  font-weight: 100;
  text-transform: uppercase;
  letter-spacing: 4px;
  color: #f1c40f;
  /* Gold accent */
}

.settings-button {
  cursor: pointer;
  transition: transform 0.2s;
}

.settings-button:hover {
  transform: rotate(45deg);
}

/* Settings Dropdown */
.dropdown {
  position: absolute;
  top: 50px;
  right: 20px;
  background: rgba(30, 30, 30, 0.95);
  backdrop-filter: blur(10px);
  border-radius: 8px;
  padding: 8px;
  min-width: 250px;
  display: none;
  flex-direction: column;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
  z-index: 2;
}

.dropdown a {
  color: #e0e0e0;
  padding: 10px;
  text-decoration: none;
  display: block;
  transition: background 0.2s;
}

.dropdown a:hover {
  background: rgba(255, 255, 255, 0.1);
}

/* Enhance dropdown menu appearance */
.dropdown a {
  transition: background-color 0.2s;
}

.dropdown a:hover {
  background-color: rgba(243, 192, 69, 0.2);
}

.character-spacer {
  height: 100px;
}

/* Input and Buttons */
.input-wrapper {
  padding: 8px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.input-box {
  display: flex;
  align-items: center;
  background: rgba(50, 50, 50, 0.9);
  border-radius: 6px;
  padding: 4px 10px;
  z-index: 10;
}

.input-box input {
  flex-grow: 1;
  background: transparent;
  border: none;
  outline: none;
  color: white;
  font-size: 16px;
  padding: 8px;
}

#send-button {
  z-index: 10;
  display:none;
}

.button-container {
  display: flex;
  /*justify-content: space-between;*/
  gap: 6px;
}

.button {
  flex: 1;
  padding: 12px;
  /*display: flex;
  align-items: center;
  justify-content: center;*/
  border-radius: 8px;
  transition: all 0.2s;
  text-align: center;
  font-size: 16px;
  transition: all 0.3s ease;
  user-select: none;
  -moz-user-select: none;
  -webkit-user-select: none;
}

.button:hover {
  /* transform: translateY(-2px); */
  filter: brightness(1.2);
}



/* COMMENTING OUT OLD MIC BUTTON STYLES
.mic-button {
  background-color: #374151; /* bg-gray-700 equivalent 
  color: #ffffff;  text-white equivalent 
  border-radius: 0.5rem; /* rounded-lg equivalent 
}


.mic-button:hover {
  background-color: #4b5563;

.mic-button:active {
  background-color: rgb(177, 28, 57);
}
*/

/* New SVG mic button styles */
.mic-button {
  background-color: transparent;
  color: #ffffff;
  border-radius: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  z-index: 8;
  position: relative; /* Establish positioning context */
  padding-right: 20px;
  overflow: visible; /* Allow overflow for the animation */
  /*-webkit-user-drag: none; */
}

.mic-button * {
  pointer-events: none; /* Prevent interaction with child elements */
}

.mic-button svg {
  width: 110px;
  height: 110px;
  animation: pulse-animation 2s infinite ease-in-out;
  transition: transform 0.2s ease-out;
  position: relative;
  z-index: 7;
}

.mic-button img {
  width: 110px;
  height: 110px;
  animation: pulse-animation 2s infinite ease-in-out;
  transition: transform 0.2s ease-out;
  position: relative;
  z-index: 7;
}

/* Make this animation apply ONLY to the mic button svg */
@keyframes pulse-animation {
  0% { transform: scale(1); }
  50% { transform: scale(1.07); }
  100% { transform: scale(1); }
}

/* Right column layout adjustments */
.right-column .chat-box {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  flex: 1;
  width: 100%;
  min-height: 40vh;
  margin-bottom: 2vh;
  z-index: 10;
}

.right-column .messages-container {
  max-height: 40vh;
  overflow-y: auto;
  padding: 15px;

  border-radius: 10px;
  margin-bottom: 2vh;
  backdrop-filter: blur(5px);
}

/* Ensure taskbar container positions mic button at bottom */
.taskbar-button-container {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  width: 100%;
  position: relative;
  z-index: 5;
  margin-top: auto;
  padding-bottom: 2vh;
  padding-right: 2vw;
}

/* Override the button's active state to stop interference */
.button:active {
  /* Remove transform and filter properties that might interfere */
  transform: none;
}

/* Ensure only the mic button svg gets the animation */
.mic-button:hover svg {
  animation-play-state: running;
}

.mic-button:hover img {
  animation-play-state: running;
}

.mic-button:active svg {
  transform: scale(0.95);
  animation-play-state: paused;
}

.mic-button:active img {
  transform: scale(0.95);
  animation-play-state: paused;
}

/* Mic Click Animation */
.mic-click-circle {
  position: absolute;
  width: 0;
  height: 0;
  background-color: rgba(250, 239, 93, 0.7); /* Yellow with 0.7 opacity */
  border-radius: 50%;
  pointer-events: none;
  opacity: 0;
  z-index: -1; /* Place behind the mic button svg */
  top: 50%;
  right: 75px; /* Position at the center of the mic button */
  transform-origin: center;
  transform: translate(50%, -50%); /* Center at button - translate by 50% of its width and height */
  transition: width 0.3s ease-out, height 0.3s ease-out, opacity 0.3s ease-out;
}

.mic-click-circle.active {
  width: 600px; /* Double the radius for diameter */
  height: 600px;
  opacity: 1;
}

/* Listening Signage */
.listening-signage {
  position: absolute;
  pointer-events: none;
  opacity: 0;
  z-index: 5; /* Above mic-click-circle but below the mic button */
  top: 50%;
  right: 85px; /* Match mic-click-circle position */
  transform: translate(50%, -50%);
  transition: opacity 0.3s ease-out;
  width: 350px; /* Fixed size for the listening signage */
  height: 350px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.listening-signage img {
  width: 100%;
  height: 100%;
  opacity: 0.8;
}

/* Show listening signage when mic-click-circle is active */
.mic-click-circle.active + .listening-signage {
  opacity: 1;
}

/* Suggestion Boxes */
.suggestion-boxes {
  display: flex;
  justify-content: space-evenly;
  gap: 10px;
  flex-grow: 1;
  overflow-x: auto;
  -ms-overflow-style: none; /* Hide scrollbar for IE and Edge */
  scrollbar-width: none; /* Hide scrollbar for Firefox */
  padding: 5px 0;
  width: 100%;
}

.suggestion-boxes::-webkit-scrollbar {
  display: none; /* Hide scrollbar for Chrome, Safari, and Opera */
}

@keyframes float {
  0%, 100% {
    transform: translateY(0);
  }
  25% {
    transform: translateY(-2px);
  }
  75% {
    transform: translateY(2px);
  }
}

.suggestion-box {
  border: 2px solid #ffd013;
  border-radius: 12px;
  background-color: #80690d;
  background: radial-gradient(rgba(175, 144, 18, 0.7), rgba(241, 196, 15, 0.7));
  color: white;
  padding: 1vw 1.5vw; /* Adjusted padding */
  font-size: 1.4vw; /* Adjusted font size */
  cursor: pointer;
  transition: all 0.2s ease;
  text-shadow: 0px 3px 8px rgba(0, 0, 0, 1), 0 0 15px rgba(0, 0, 0, 1); /* Increased text shadow for better readability */
  box-shadow: inset 0 0 10px 2px rgba(255, 255, 255, 1.0), 0 2px 4px rgba(0, 0, 0, 0.2); /* Add subtle shadow */
  flex: 1;
  max-width: 15vw; 
  max-height:12vw;
  height: 12vh;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  word-wrap: break-word;
  line-height: 1.2;
  animation: float 5s ease-in-out infinite;
}

/* Stagger animation for each suggestion box */
.suggestion-box:nth-child(1) {
  animation-delay: 0s;
}

.suggestion-box:nth-child(2) {
  animation-delay: 1.8s;
}

.suggestion-box:nth-child(3) {
  animation-delay: 0.7s;
}

.suggestion-box:nth-child(4) {
  animation-delay: 1.8s;
}

.suggestion-box:nth-child(5) {
  animation-delay: 2.0s;
}

.suggestion-box:hover {
  background-color: rgba(241, 196, 15, 0.8);
}

.suggestion-box:active {
  transform: translateY(0);
  opacity: 0.9;
}

/* Media Query for larger screens (e.g., 1080px width portrait displays) */
@media (min-width: 1000px) and (orientation: portrait) {
  @keyframes float {
    0%, 100% {
      transform: translateY(0);
    }
    25% {
      transform: translateY(-5px);
    }
    75% {
      transform: translateY(5px);
    }
  }

  .suggestion-box {
    padding: 0.8vw 1.2vw;
    font-size: 2.2vw; /* Slightly smaller font on large portrait */
    min-width: 12vw;
    max-width: 20vw;
    height: 8vh; /* Reduced height */
  }

  .mic-button {
    padding-right: 30px; /* Adjust padding for larger button */
  }

  .mic-button svg,
  .mic-button img {
    width: 150px; /* Increased size */
    height: 150px; /* Increased size */
  }

  .mic-click-circle {
    right: 100px; /* Adjusted for larger mic button */
  }

  .mic-click-circle.active {
    width: 800px; /* Scale with larger mic */
    height: 800px;
  }

  .listening-signage {
    right: 110px; /* Adjusted for larger mic button */
    width: 450px; /* Scale with larger mic */
    height: 450px;
  }

  .suggestion-boxes {
    max-width: calc(100% - 180px); /* Reserve space for new mic button size (150px + 30px padding) */
    gap: 40px; /* Increased gap for larger screens */
  }
}

/* Action buttons row - SIMPLIFIED */
.action-buttons-row {
  position: fixed;
  bottom: 35%;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 50px;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease;
}

.action-buttons-row.show {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

/* Add proper hide animation styles */
.action-buttons-row.hide {
  opacity: 1; /* Start visible */
  visibility: visible;
  pointer-events: none; /* Prevent clicks during fade-out */
  transition: opacity 0.5s ease;
}

.action-button {
  width: 90px;
  height: 90px;
  cursor: pointer;
  opacity: 0;
  transform: translateY(20px);
  transition: transform 0.2s ease, opacity 0.5s ease, box-shadow 0.2s ease;
}

/* Remove the appeared class and action-button-spawn animation */
.action-buttons-row.show .action-button {
  opacity: 1;
  transform: translateY(0);
}

/* Add hide animation for buttons - reverse the appearance animation */
.action-buttons-row.hide .action-button {
  opacity: 0;
  transform: translateY(20px);
  transition: transform 0.3s ease, opacity 0.5s ease;
}

/* Staggered animation delays for showing */
.action-buttons-row.show .action-button:nth-child(1) {
  transition-delay: 0s;
}

.action-buttons-row.show .action-button:nth-child(2) {
  transition-delay: 0.1s;
}

.action-buttons-row.show .action-button:nth-child(3) {
  transition-delay: 0.2s;
}

.action-buttons-row.show .action-button:nth-child(4) {
  transition-delay: 0.3s;
}

/* Staggered animation delays for hiding - reverse order */
.action-buttons-row.hide .action-button:nth-child(4) {
  transition-delay: 0s; /* Last button disappears first */
}

.action-buttons-row.hide .action-button:nth-child(3) {
  transition-delay: 0.1s;
}

.action-buttons-row.hide .action-button:nth-child(2) {
  transition-delay: 0.2s;
}

.action-buttons-row.hide .action-button:nth-child(1) {
  transition-delay: 0.3s; /* First button disappears last */
}

.action-button:hover {
  transform: scale(1.05);
}

.action-button:active {
  transform: scale(0.8);
}

/* Special positioning for first and fourth buttons */
.action-buttons-row .action-button:first-child,
.action-buttons-row .action-button:nth-child(4) {
  top: -70px;
  position: relative;
}

.start-button {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: rgba(16, 16, 16, 0.9);
  box-shadow: 0px 0px 10px rgba(3, 3, 3, 0.5);
  text-shadow: 0px 0px 4px black;
  border: 1px solid #f1c40f;
  font-size: 2em;
  font-weight: bold;
  width: 200px;
  height: 200px;
  display: flex;
  justify-content: center;
  align-items: center;
  color: #ebebeb;
  transition: all 0.5s ease-out;
  cursor: pointer;
}

.start-button:hover {
  filter: brightness(0.3);
}

.start-button.hide {
  opacity: 0;
  user-select: none;
  pointer-events: none;
}

/* Disclaimer Text */
.disclaimer {
  text-align: center;
  font-size: 12px;
  color: rgba(200, 200, 200, 0.7);
  margin-top: 4px;
  z-index:10;
}

/* QoS Status Message */
.qos-status {
  position: absolute;
  top: 100px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(69, 40, 40, 0.9);
  box-shadow: 0px 4px 10px rgba(0, 0, 0, 0.5);
  color: white;
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: bold;
  transition: opacity 0.3s ease, transform 0.3s ease;
  opacity: 0;
}

.qos-status.show {
  opacity: 1;
  transform: translateX(-50%) translateY(-10px);
}

/* Typing Indicator */
.typing-indicator {
  position: absolute;
  bottom: 160px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(30, 30, 30, 0.8);
  border-radius: 1em;
  transition: opacity 0.3s ease, transform 0.3s ease;
  opacity: 0;
}

.typing-indicator.show {
  opacity: 1;
}

.typing {
  display: flex;
  align-items: center;
  gap: 4px;
}

.dot {
  width: 6px;
  height: 6px;
  background: rgba(255, 255, 255, 0.6);
  border-radius: 50%;
  animation: blink 1.5s infinite;
}

.dot:nth-child(2) {
  animation-delay: 0.2s;
}

.dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes blink {
  0% {
    opacity: 0.3;
  }

  50% {
    opacity: 1;
  }

  100% {
    opacity: 0.3;
  }
}

/* Avatar */
.avatar-container {
  position: absolute;
  bottom: 0px;
  left: 50%;
  top: 0px;
  transform: translateX(-25%);
  width: 100%;
  overflow: hidden;
  pointer-events: none;
  z-index: 2;
}

.avatar-placeholder {
  position: absolute;
  bottom: 0px;
  max-width: 260px;
  right: 0px;
  transform: translateX(-50%);
  transition: opacity 1.3s ease-out;
  opacity: 1;
}

.avatar-renderer {
  position: absolute;
  width: calc(100% + 350px);
  height: 100%;
  top: 0px;
  right: -350px;
  transition: opacity 1.3s ease-out;
  opacity: 0;
}

.avatar-placeholder.hide {
  opacity: 0;
}

.avatar-renderer.show {
  opacity: 1;
}

/* Create separate layers for different UI elements */
.base-layer {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.overlay-layer {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
  /* Allow clicks to pass through to elements below */
}

.overlay-layer>* {
  pointer-events: auto;
  /* Re-enable clicks for children of overlay */
}

/* Emoji Rain Canvas */
.emoji-rain-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  /* Allows clicks to go through */
  z-index: 1000;
  /* Above everything else */
}

@keyframes fadeOutEmoji {
  from {
    opacity: 1;
  }

  to {
    opacity: 0;
  }
}

/* Responsive Column Layout */
.main-layout {
  display: flex;
  height: 100vh;
  width: 100%;
  position: relative;
  background-image: url('../assets/img/blink-horizontal.png');
  background-size: cover;
  background-position: left;
  backdrop-filter: blur(10px);
}

.left-column {
  flex: 0 0 65%;
  display: flex;
  flex-direction: column;
  min-width: 300px;
  overflow-y: auto;
  gap: 2vh;
  padding-top: 1vh;
  padding-right:25px;
  position: relative;
  z-index: 10;
  margin-left: 1vw;
}

.right-column {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  min-width: 300px;
  gap: 2vh;
  overflow: visible;
  z-index: 1;
  padding: 1vh 1vw 1vh 0;
  /* Extend left behind the left column */
  margin-left: -200px;
  padding-left: 200px;
}

/* Responsive breakpoints */
@media (max-width: 768px) {
  .main-layout {
    flex-direction: column;
    position: static;
  }
  
  .left-column {
    flex: none;
    max-width: 100%;
    min-width: auto;
    order: 2;
    gap: 1vh;
    padding: 0.5vh;
    margin-left: 0;
    position: static;
    z-index: auto;
  }
  
  .right-column {
    flex: none;
    width: 100%;
    order: 1;
    min-height: 60vh;
    z-index: auto;
    margin-left: 0;
    padding-left: 0;
    padding: 1vh;
  }
  
  .taskbar-button-container {
    justify-content: center;
    padding-right: 0;
  }
}

@media (max-width: 480px) {
  .main-layout {
    padding: 0.5vh;
    gap: 1vh;
  }
}