* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  /* Prevent body scroll, handle in chat-box */
}

body {
  background: linear-gradient(135deg, #01B0D3 0%, #0077C8 100%);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  display: flex;
  justify-content: center;
  color: #fff;
}

.container {
  width: 100%;
  max-width: 1000px;
  /* Increased from 800px for wider desktop view */
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 20px;
}

.header {
  font-size: 24px;
  font-weight: bold;
  margin-bottom: 15px;
  text-align: center;
  flex-shrink: 0;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.chat-box {
  background: #ffffff;
  color: #333;
  flex-grow: 1;
  overflow-y: auto;
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
  -webkit-overflow-scrolling: touch;
  /* Smooth scrolling on iOS */
  display: flex;
  flex-direction: column;
  scroll-behavior: smooth;
  /* Hardware acceleration for better performance */
  transform: translateZ(0);
  will-change: scroll-position;
}

.chat-box p {
  margin: 8px 0;
  line-height: 1.6;
  /* Smooth fade-in for new messages */
  animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(5px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* User name tag in blue */
.chat-box .user-name {
  color: #0077C8;
}

/* Poke Bot name tag in red */
.chat-box .bot-name {
  color: #C31E1E !important;
}

.chat-box b {
  color: #0077C8;
}

.input-box {
  margin-top: 15px;
  display: flex;
  gap: 10px;
  width: 100%;
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.1);
  padding: 5px;
  border-radius: 12px;
}

input {
  flex: 1;
  padding: 14px;
  border-radius: 8px;
  border: none;
  font-size: 16px;
  outline: none;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
  transition: box-shadow 0.2s;
  /* Prevent zoom on iOS */
  font-size: 16px;
}

input:focus {
  box-shadow: 0 3px 8px rgba(1, 176, 211, 0.3);
}

input:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

button {
  background: #0077C8;
  border: none;
  padding: 0 24px;
  border-radius: 8px;
  color: white;
  cursor: pointer;
  font-weight: bold;
  font-size: 16px;
  transition: all 0.2s;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
  /* Prevent tap delay on mobile */
  touch-action: manipulation;
}

button:hover:not(:disabled) {
  background: #005b98;
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

button:active:not(:disabled) {
  transform: scale(0.98);
}

button:disabled {
  cursor: not-allowed;
}

/* Loading animation */
.loading-dots {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: #0077C8;
  font-style: italic;
}

.loading-dots span {
  display: inline-block;
  width: 8px;
  height: 8px;
  background: #0077C8;
  border-radius: 50%;
  animation: bounce 1.4s infinite ease-in-out both;
}

.loading-dots span:nth-child(1) {
  animation-delay: -0.32s;
}

.loading-dots span:nth-child(2) {
  animation-delay: -0.16s;
}

@keyframes bounce {

  0%,
  80%,
  100% {
    transform: scale(0);
    opacity: 0.5;
  }

  40% {
    transform: scale(1);
    opacity: 1;
  }
}

/* Typing animation for streaming text */
.typing-cursor {
  display: inline-block;
  width: 2px;
  height: 1em;
  background: #0077C8;
  margin-left: 2px;
  animation: blink 1s infinite;
}

@keyframes blink {

  0%,
  49% {
    opacity: 1;
  }

  50%,
  100% {
    opacity: 0;
  }
}

/* Responsive adjustments for mobile */
@media (max-width: 600px) {
  .container {
    padding: 10px;
    height: 100vh;
    /* Fallback */
    height: 100dvh;
    /* Dynamic viewport height for mobile browsers to handle URL bar */
  }

  .header {
    font-size: 20px;
    margin-bottom: 10px;
    padding-top: 5px;
  }

  .chat-box {
    border-radius: 12px;
    padding: 15px;
  }

  .input-box {
    margin-top: 10px;
    padding: 0;
    background: transparent;
  }

  input {
    padding: 12px;
  }

  button {
    padding: 0 18px;
  }
}

/* Improve scrollbar appearance */
.chat-box::-webkit-scrollbar {
  width: 8px;
}

.chat-box::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 10px;
}

.chat-box::-webkit-scrollbar-thumb {
  background: #0077C8;
  border-radius: 10px;
}

.chat-box::-webkit-scrollbar-thumb:hover {
  background: #005b98;
}