* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg-primary: #0f0f23;
  --bg-secondary: #1a1a2e;
  --bg-tertiary: #16213e;
  --accent-primary: #6366f1;
  --accent-secondary: #8b5cf6;
  --accent-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  --text-primary: #ffffff;
  --text-secondary: #94a3b8;
  --text-tertiary: #64748b;
  --success: #10b981;
  --message-sent: #2d3748;
  --message-received: #1e293b;
  --border-color: rgba(255, 255, 255, 0.1);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.4);
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  height: 100vh;
  overflow: hidden;
  position: relative;
}

body::before {
  content: '';
  position: fixed;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle at 20% 50%,
      rgba(99, 102, 241, 0.15) 0%,
      transparent 50%),
    radial-gradient(circle at 80% 80%,
      rgba(139, 92, 246, 0.15) 0%,
      transparent 50%);
  animation: gradient-shift 15s ease infinite;
  z-index: -1;
}

@keyframes gradient-shift {

  0%,
  100% {
    transform: translate(0, 0);
  }

  50% {
    transform: translate(-5%, -5%);
  }
}

.app-container {
  height: 100vh;
  display: flex;
  flex-direction: column;
  max-width: 1200px;
  margin: 0 auto;
  background: rgba(26, 26, 46, 0.6);
  backdrop-filter: blur(20px);
  border-left: 1px solid var(--border-color);
  border-right: 1px solid var(--border-color);
}

/* Header */
.chat-header {
  background: rgba(22, 33, 62, 0.8);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-color);
  box-shadow: var(--shadow-md);
  padding: 1.25rem 2rem;
  position: relative;
  z-index: 10;
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo-icon {
  font-size: 2rem;
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {

  0%,
  100% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.1);
  }
}

.logo h1 {
  font-size: 1.5rem;
  font-weight: 700;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.online-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.2);
  border-radius: 50px;
  font-size: 0.875rem;
}

.status-indicator {
  width: 8px;
  height: 8px;
  background: var(--success);
  border-radius: 50%;
  animation: blink 2s ease-in-out infinite;
}

@keyframes blink {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.5;
  }
}

#client-total {
  font-weight: 700;
  color: var(--success);
  font-size: 1rem;
}

.status-text {
  color: var(--text-secondary);
}

/* Main Chat Area */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 1.5rem;
  position: relative;
}

.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 1rem;
  scroll-behavior: smooth;
}

/* Custom Scrollbar */
.messages-container::-webkit-scrollbar {
  width: 8px;
}

.messages-container::-webkit-scrollbar-track {
  background: transparent;
}

.messages-container::-webkit-scrollbar-thumb {
  background: rgba(99, 102, 241, 0.3);
  border-radius: 10px;
}

.messages-container::-webkit-scrollbar-thumb:hover {
  background: rgba(99, 102, 241, 0.5);
}

/* Message Bubbles */
.message {
  display: flex;
  flex-direction: column;
  max-width: 70%;
  animation: message-in 0.3s ease;
}

@keyframes message-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

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

.message.message-left {
  align-self: flex-start;
}

.message.message-right {
  align-self: flex-end;
}

.message-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
  padding: 0 0.75rem;
}

.message-user-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.user-icon {
  font-size: 1.25rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.message-name {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.message-time {
  font-size: 0.7rem;
  color: var(--text-tertiary);
}

.message-content {
  padding: 0.875rem 1rem;
  border-radius: 1.25rem;
  word-wrap: break-word;
  line-height: 1.5;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s ease;
}

.message-content:hover {
  transform: translateY(-2px);
}

.message-left .message-content {
  background: var(--message-received);
  border-bottom-left-radius: 0.25rem;
}

.message-right .message-content {
  background: var(--accent-gradient);
  border-bottom-right-radius: 0.25rem;
}

/* Typing Feedback */
.typing-feedback {
  min-height: 1.5rem;
  padding: 0 1rem;
  font-size: 0.875rem;
  color: var(--text-secondary);
  font-style: italic;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.typing-feedback:not(:empty) {
  opacity: 1;
}

/* Message Form */
.message-form {
  display: flex;
  gap: 0.75rem;
  padding: 1.25rem;
  background: rgba(22, 33, 62, 0.6);
  backdrop-filter: blur(10px);
  border-radius: 1.5rem;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-lg);
  position: relative;
  z-index: 1;
}

.name-input,
.message-input {
  padding: 0.875rem 1.25rem;
  background: rgba(15, 15, 35, 0.8);
  border: 1px solid var(--border-color);
  border-radius: 1rem;
  color: var(--text-primary);
  font-size: 0.95rem;
  font-family: inherit;
  outline: none;
  transition: all 0.3s ease;
}

.name-input {
  flex: 0 0 180px;
}

.message-input {
  flex: 1;
}

.name-input:focus,
.message-input:focus {
  border-color: var(--accent-primary);
  background: rgba(15, 15, 35, 1);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.name-input::placeholder,
.message-input::placeholder {
  color: var(--text-tertiary);
}

.send-button {
  padding: 0.875rem 1.5rem;
  background: var(--accent-gradient);
  border: none;
  border-radius: 1rem;
  color: var(--text-primary);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.send-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(99, 102, 241, 0.4);
}

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

.send-button svg {
  width: 20px;
  height: 20px;
}

/* Footer */
.chat-footer {
  padding: 1rem;
  text-align: center;
  border-top: 1px solid var(--border-color);
  background: rgba(22, 33, 62, 0.4);
  font-size: 0.75rem;
  color: var(--text-tertiary);
}

/* Responsive Design */
@media (max-width: 768px) {
  .chat-header {
    padding: 1rem 1.5rem;
  }

  .logo h1 {
    font-size: 1.25rem;
  }

  .chat-main {
    padding: 1rem;
  }

  .message-form {
    flex-direction: column;
    padding: 1rem;
  }

  .name-input {
    flex: 1;
  }

  .message {
    max-width: 85%;
  }

  .send-button {
    width: 100%;
  }
}

@media (max-width: 480px) {
  .header-content {
    flex-direction: column;
    gap: 1rem;
  }

  .message {
    max-width: 90%;
  }
}

/* Reply Styles */
.reply-button {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.75rem;
  margin-top: 0.5rem;
  background: rgba(99, 102, 241, 0.1);
  border: 1px solid rgba(99, 102, 241, 0.3);
  border-radius: 0.75rem;
  color: var(--accent-primary);
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  opacity: 0;
}

.message:hover .reply-button {
  opacity: 1;
}

.reply-button:hover {
  background: rgba(99, 102, 241, 0.2);
  border-color: var(--accent-primary);
  transform: translateX(-2px);
}


.reply-button svg {
  width: 14px;
  height: 14px;
}

/* Reply Indicator (above input when replying) */
.reply-indicator {
  display: none;
  margin-bottom: 0.75rem;
}

.replying-to {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  background: rgba(99, 102, 241, 0.1);
  border-left: 3px solid var(--accent-primary);
  border-radius: 0.75rem;
}

.replying-to-content {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex: 1;
}

.replying-to-icon {
  font-size: 1.5rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.replying-to-name {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent-primary);
  margin-bottom: 0.25rem;
}

.replying-to-message {
  font-size: 0.8rem;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 300px;
}

.cancel-reply {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  border-radius: 50%;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 0.875rem;
}

.cancel-reply:hover {
  background: rgba(255, 255, 255, 0.2);
  color: var(--text-primary);
}

/* Message Reply (quoted message in bubble) */
.message-reply {
  display: flex;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  margin: 0 0.75rem 0.5rem 0.75rem;
  background: rgba(0, 0, 0, 0.2);
  border-left: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 0.5rem;
  font-size: 0.75rem;
}

.reply-icon-emoji {
  font-size: 1rem;
  opacity: 0.9;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.reply-content {
  flex: 1;
  overflow: hidden;
}

.reply-name {
  font-weight: 600;
  color: var(--accent-primary);
  margin-bottom: 0.15rem;
}

.reply-text {
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.7rem;
}