/* Base Reset & General Styling */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden; /* prevent body scroll */
}

body {
  background-color: #11112f;
  font-family: 'Segoe UI', sans-serif;
  color: #f1f1f1;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* Container Layout */
.chat-container {
  height: calc(100vh - 40px); /* 20px space top and bottom */
  width: 100%;
  max-width: 600px;
  background-color: #2a2a40;
  border-radius: 12px;
  box-shadow: 0 0 12px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  overflow: hidden;
}

/* Chat Messages */
.chat-box {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  background-color: #2a2a40;
  display: flex;
  flex-direction: column;
  scroll-behavior: smooth;
}

/* Message List */
#messagesList {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Chat Bubbles */
#messagesList li {
  padding: 12px 16px;
  border-radius: 16px;
  max-width: 75%;
  min-width: 130px;
  font-size: 0.95rem;
  word-wrap: break-word;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
  color: #fff;
}

/* Message header styling */
.message-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
  font-size: 0.75rem;
  opacity: 0.8;
}

.user-name {
  font-weight: 600;
}

.message-time {
  font-size: 0.7rem;
  opacity: 0.7;
}

.message-body {
  font-size: 0.95rem;
  line-height: 1.4;
}

#messagesList li.own {
  align-self: flex-end;
  background: #4a90e2;
  border-bottom-right-radius: 4px;
}

#messagesList li.theirs {
  align-self: flex-start;
  background: #3a3a55;
  border-bottom-left-radius: 4px;
}

/* Additional user colors for multi-user chats */
#messagesList li.user-1 { align-self: flex-start; background: #e74c3c !important; border-bottom-left-radius: 4px; }
#messagesList li.user-2 { align-self: flex-start; background: #2ecc71 !important; border-bottom-left-radius: 4px; }
#messagesList li.user-3 { align-self: flex-start; background: #f39c12 !important; border-bottom-left-radius: 4px; }
#messagesList li.user-4 { align-self: flex-start; background: #9b59b6 !important; border-bottom-left-radius: 4px; }
#messagesList li.user-5 { align-self: flex-start; background: #1abc9c !important; border-bottom-left-radius: 4px; }
#messagesList li.user-6 { align-self: flex-start; background: #e67e22 !important; border-bottom-left-radius: 4px; }
#messagesList li.user-7 { align-self: flex-start; background: #34495e !important; border-bottom-left-radius: 4px; }
#messagesList li.user-8 { align-self: flex-start; background: #16a085 !important; border-bottom-left-radius: 4px; }

/* Chat Input Form */
.chat-form {
  display: flex;
  padding: 12px;
  background-color: #222236;
  border-top: 1px solid #333;
}

.chat-form input {
  flex: 1;
  padding: 10px 14px;
  border-radius: 8px;
  border: none;
  font-size: 1rem;
  background-color: #3a3a55;
  color: #f1f1f1;
  margin-right: 8px;
  outline: none;
}

.chat-form input::placeholder {
  color: #bbb;
}

.chat-form button {
  padding: 10px 18px;
  font-size: 1rem;
  border: none;
  border-radius: 8px;
  background-color: #4a90e2;
  color: #fff;
  cursor: pointer;
  transition: background 0.3s ease;
}

/* Chat Input Form */
.chat-form {
  display: flex;
  padding: 12px;
  background-color: #222236;
  border-top: 1px solid #333;
  gap: 8px;
}

.chat-form input {
  flex: 1;
  padding: 10px 14px;
  border-radius: 8px;
  border: none;
  font-size: 1rem;
  background-color: #3a3a55;
  color: #f1f1f1;
  outline: none;
}

.chat-form input::placeholder {
  color: #bbb;
}

.chat-form input:focus {
  background-color: #4a4a65;
  box-shadow: 0 0 0 2px #4a90e2;
}

.chat-form button {
  padding: 10px 18px;
  font-size: 1rem;
  border: none;
  border-radius: 8px;
  color: #fff;
  cursor: pointer;
  transition: background 0.3s ease;
  font-weight: 500;
}

.chat-form .btn-send {
  background-color: #4a90e2;
}

.chat-form .btn-send:hover {
  background-color: #357ab8;
}

.chat-form .btn-danger {
  background-color: #ff1010;
}

.chat-form .btn-danger:hover {
  background-color: #e00d0d;
}

#sendBtn {
  display: block;
}

/* Chat Header */
.chat-header {
  background-color: #1a1a2e;
  padding: 15px 20px;
  border-bottom: 1px solid #333;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.chat-header h2 {
  margin: 0;
  font-size: 1.2rem;
  color: #f1f1f1;
}

.chat-info {
  font-size: 0.9rem;
  color: #bbb;
  display: flex;
  gap: 15px;
}

.user-count {
  color: #4a90e2;
}

/* Chat Status Messages */
.status-message {
  text-align: center;
  color: #888;
  font-style: italic;
  padding: 10px;
  margin: 5px 0;
}

.connection-status {
  position: absolute;
  top: 10px;
  right: 10px;
  padding: 5px 10px;
  border-radius: 15px;
  font-size: 0.8rem;
  font-weight: bold;
}

.status-connected {
  background-color: #2ecc71;
  color: white;
}

.status-disconnected {
  background-color: #e74c3c;
  color: white;
}

.status-connecting {
  background-color: #f39c12;
  color: white;
}

/* Typing Indicator */
.typing-indicator {
  padding: 10px 20px;
  font-style: italic;
  color: #888;
  background-color: #2a2a40;
  border-top: 1px solid #333;
}

.typing-dots {
  display: inline-block;
}

.typing-dots::after {
  content: '';
  animation: typing 1.5s infinite;
}

@keyframes typing {
  0%, 20% { content: ''; }
  40% { content: '.'; }
  60% { content: '..'; }
  80%, 100% { content: '...'; }
}

/* Scrollbar Customization */
.chat-box::-webkit-scrollbar {
  width: 6px;
}

.chat-box::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 3px;
}

/* Banner & Image */
.banner {
  position: relative;
  width: 100%;
  text-align: center;
  overflow: hidden;
  height: auto;
}

.banner-container {
  position: relative;
  text-align: center;
  padding: 1em 2em 2em;
  max-width: 600px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.banner-container a {
  display: inline-block;
  text-decoration: none;
  border: none;
  outline: none;
}

.banner-container a:hover img {
  opacity: 0.8;
  transition: opacity 0.3s ease;
}

.banner img {
  display: block;
  width: 40%;
  height: auto;
  max-height: none;
  object-fit: contain;
  margin: 0 auto;
  position: relative;
  top: 0;
  cursor: pointer;
}

/* Admin Controls */
.admin-controls {
  text-align: center;
  margin: 20px 0;
}

.admin-controls button {
  background-color: #dc3545;
  color: black;
  border: none;
  padding: 10px 20px;
  font-size: 16px;
  border-radius: 5px;
  cursor: pointer;
}

.admin-controls button:hover {
  background-color: #c82333;
}

.admin-message {
  text-align: center;
  color: green;
  font-weight: bold;
}

/* Watermark */
.watermark {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: brightness(0.8) saturate(1);
  z-index: 0;
  pointer-events: none;
}

/* Result Styling */
.result {
  background-color: #2a2a40;
  color: #f1f1f1;
  padding: 2em;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  max-width: 600px;
  width: 90%;
  margin: 2rem auto 0;
  text-align: left;
  box-sizing: border-box;
  position: relative;
  z-index: 1;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.result h2 {
  color: #4a90e2;
  margin-bottom: 1rem;
  font-size: 1.3rem;
}

.result p {
  line-height: 1.6;
  margin-bottom: 1rem;
}

.page-content {
  margin-top: 0;
  text-align: center;
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
}

.qr-code-wrapper {
  position: fixed;
  top: 50%;
  left: 0;
  width: calc((100vw - 600px) / 2);
  transform: translateY(-50%);
  z-index: 100;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  pointer-events: none;
}

.qr-code-wrapper > * {
  background: #fff;
  padding: 12px;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  transition: box-shadow 0.3s ease;
  pointer-events: auto;
  transform: scale(1.25);
}

.qr-code-wrapper > *:hover {
  box-shadow: 0 6px 20px rgba(0,0,0,0.25);
}

/* Main Form Styles (for non-chat pages) */
.overlay-form {
  position: relative;
  width: 100%;
  max-width: 400px;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.overlay-input {
  font-size: 16px;
  padding: 12px 20px;
  width: 100%;
  max-width: 300px;
  border-radius: 25px;
  border: 1px solid #ccc;
  box-shadow: 0 2px 5px rgba(0,0,0,0.1);
  background: white;
  color: #333;
  outline: none;
}

.overlay-input:focus {
  border-color: #4a90e2;
  box-shadow: 0 0 0 2px rgba(74, 144, 226, 0.2);
}

.search-box {
  text-align: center;
}

.submit-btn {
  display: none;
}

.form-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

/* JOIN FORM STYLES - CLEANED UP */
.form-layout {
  display: flex;
  gap: 30px;
  margin-top: 20px;
  align-items: flex-start;
  justify-content: center;
  max-width: 1100px;
  width: 100%;
}

.help-section {
  flex: 2;
  max-width: 650px;
  min-width: 500px;
  background-color: #2a2a40;
  border-left: 4px solid #4a90e2;
  color: #f1f1f1;
  padding: 2em;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  font-size: 0.95rem;
}

.help-section h3 {
  margin: 0 0 0.5em 0;
  font-size: 1.1rem;
  color: #ffffff;
}

.help-section ul {
  padding-left: 1.2em;
  list-style-type: disc;
}

.help-section li {
  margin-bottom: 0.8em;
  line-height: 1.5;
}

.form-section {
  flex: 1;
  max-width: 400px;
}

.join-form {
  background: rgba(42, 42, 64, 0.95);
  padding: 2rem;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.join-form h2 {
  text-align: center;
  margin-bottom: 1.5rem;
  color: #f1f1f1;
  font-size: 1.4rem;
}

.input-group {
  margin-bottom: 2rem;
}

.input-group input {
  width: 100%;
  font-size: 16px;
  padding: 12px 16px;
  border-radius: 8px;
  border: none;
  background-color: #3a3a55;
  color: #f1f1f1;
  outline: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  margin-bottom: 1rem;
}

.input-group input::placeholder {
  color: #bbb;
}

.input-group input:focus {
  background-color: #4a4a65;
  box-shadow: 0 0 0 2px #4a90e2;
}

.button-group {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.primary-buttons {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
}

.action-buttons {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
}

/* Button Styles */
.btn {
  padding: 10px 18px;
  font-size: 1rem;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.3s ease;
  min-width: 80px;
  font-weight: 500;
}

.btn-primary {
  background-color: #10aa10;
  color: #fff;
}

.btn-primary:hover {
  background-color: #0e990e;
}

.btn-secondary {
  background-color: #4a90e2;
  color: #fff;
}

.btn-secondary:hover {
  background-color: #357ab8;
}

.btn-danger {
  background-color: #ff1010;
  color: #fff;
}

.btn-danger:hover {
  background-color: #e00d0d;
}

/* Mobile Optimization */
@media (max-width: 768px) {
  body,
  html {
    overflow: auto !important;
    height: auto !important;
  }
  
  body {
    padding: 1em;
    align-items: flex-start;
    padding-top: 2rem;
  }
  
  .chat-container {
    height: 90vh;
    border-radius: 0;
    overflow-y: auto !important;
    max-height: 100vh;
  }
  
  .chat-form input,
  .chat-form button {
    font-size: 1rem;
  }
  
  .form-layout {
    flex-direction: column-reverse;
    align-items: center;
    gap: 1.5rem;
    margin-top: 1rem;
  }
  
  .help-section,
  .form-section {
    max-width: 95%;
    width: 100%;
    min-width: unset;
  }
  
  .help-section {
    padding: 1.5em;
    font-size: 0.9rem;
    border-top: 4px solid #4a90e2;
    border-left: none;
    margin-top: 1rem;
  }
  
  .help-section h3 {
    margin-top: 0.5em;
  }
  
  .primary-buttons,
  .action-buttons {
    flex-direction: column;
  }
  
  .btn {
    width: 100%;
  }
  
  .qr-code-wrapper {
    display: none !important;
    pointer-events: none;
    visibility: hidden;
  }
}