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

body,
html {
  height: 100%;
  margin: 0;
  padding: 0;
  font-family: 'Figtree', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #ffffff;
}

#root {
  height: 100vh;
  width: 100vw;
  display: flex;
  flex-direction: column;
}

/* Welcome Screen Styles */
.welcome-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  background: #ffffff;
  padding: 20px;
}

.welcome-container {
  background: white;
  border-radius: 12px;
  padding: 60px 50px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
  border: 1px solid #e5e5e5;
  text-align: center;
  max-width: 450px;
  width: 100%;
}

.welcome-title {
  font-size: 42px;
  font-weight: 700;
  color: #000000;
  margin-bottom: 12px;
  letter-spacing: -0.5px;
}

.welcome-subtitle {
  font-size: 20px;
  font-weight: 400;
  color: #666666;
  margin-bottom: 40px;
}

.welcome-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.username-input {
  width: 100%;
  padding: 18px 24px;
  font-size: 16px;
  font-family: 'Figtree', sans-serif;
  border: 2px solid #042dac;
  border-radius: 8px;
  outline: none;
  transition: all 0.2s ease;
  background: #ffffff;
  min-height: 56px;
  display: flex;
  align-items: center;
}

.username-input:focus {
  border-color: #042dac;
  box-shadow: 0 0 0 4px rgba(4, 45, 172, 0.1);
}

.username-input::placeholder {
  color: #aaa;
}

.enter-chat-button {
  width: 100%;
  padding: 24px 24px;
  font-size: 18px;
  font-weight: 700;
  font-family: 'Figtree', sans-serif;
  color: white !important;
  background: #042dac !important;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  letter-spacing: 0.5px;
  line-height: 1.4;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 56px;
  text-transform: uppercase;
}

.enter-chat-button:hover:not(:disabled) {
  background: #042dac !important;
  transform: translateY(-1px);
}

.enter-chat-button:disabled {
  background: #042dac !important;
  color: white !important;
  cursor: not-allowed;
}

.enter-chat-button:active:not(:disabled) {
  transform: translateY(0);
}

/* Chat Screen Styles */
.chat-screen {
  display: flex;
  flex-direction: column;
  height: 100vh;
  background: #ffffff;
}

.chat-header {
  background: #042dac;
  color: white;
  padding: 20px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  flex-shrink: 0;
}

.chat-header-title {
  font-size: 24px;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.3px;
}

.chat-header-user {
  font-size: 15px;
  font-weight: 500;
  opacity: 0.85;
  background: rgba(255, 255, 255, 0.15);
  padding: 6px 14px;
  border-radius: 20px;
  color: white;
}

.pinned-message {
  background: #000000;
  color: white;
  padding: 12px 24px;
  margin: 0;
  font-size: 13px;
  font-weight: 500;
  text-align: left;
  font-family: 'Figtree', sans-serif;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  position: relative;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.message-container {
  display: flex;
  flex-direction: column;
  max-width: 85%;
  min-width: 160px;
  animation: slideIn 0.2s ease-out;
}

.message-container.message-own {
  align-self: flex-end;
  align-items: flex-end;
}

.message-container.message-other {
  align-self: flex-start;
  align-items: flex-start;
}

.message-container.message-highlighted {
  animation: none;
}

.message-container.message-highlighted .message-bubble {
  animation: highlightPulse 2s ease-out;
  border: 2px solid #042dac;
}

.message-container.message-highlighted.message-own .message-bubble {
  animation: highlightPulseOwn 2s ease-out;
  border: 2px solid #042dac;
}

@keyframes highlightPulse {
  0% {
    background: rgba(4, 45, 172, 0.15);
    box-shadow: 0 0 0 0 rgba(4, 45, 172, 0.4);
  }
  50% {
    background: rgba(4, 45, 172, 0.25);
    box-shadow: 0 0 0 8px rgba(4, 45, 172, 0.1);
  }
  100% {
    background: #ffffff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
  }
}

@keyframes highlightPulseOwn {
  0% {
    background: rgba(4, 45, 172, 0.15);
    box-shadow: 0 0 0 0 rgba(4, 45, 172, 0.4);
  }
  50% {
    background: rgba(4, 45, 172, 0.25);
    box-shadow: 0 0 0 8px rgba(4, 45, 172, 0.1);
  }
  100% {
    background: #ffffff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
  }
}

.chat-messages::-webkit-scrollbar {
  width: 6px;
}

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

.chat-messages::-webkit-scrollbar-thumb {
  background: #d0d0d0;
  border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
  background: #999999;
}

.message-bubble {
  padding: 16px 20px;
  border-radius: 12px;
  word-wrap: break-word;
  width: fit-content;
  max-width: 100%;
  box-sizing: border-box;
  min-height: auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.message-header {
  margin-bottom: 6px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.message-user {
  font-weight: 600;
  font-size: 13px;
  color: #333333;
}

.delete-button {
  background: none;
  border: none;
  color: #ff4444;
  cursor: pointer;
  font-size: 14px;
  padding: 2px 6px;
  border-radius: 3px;
  opacity: 0.7;
  transition: all 0.2s ease;
  font-family: inherit;
}

.delete-button:hover {
  opacity: 1;
  background: rgba(255, 68, 68, 0.1);
}

.reply-preview {
  background: rgba(0, 0, 0, 0.05);
  border-left: 3px solid #042dac;
  padding: 8px 12px;
  margin-bottom: 8px;
  border-radius: 4px;
  font-size: 12px;
  transition: background 0.2s ease;
}

.reply-preview:hover {
  background: rgba(0, 0, 0, 0.08);
}

.reply-user {
  font-weight: 600;
  font-size: 11px;
  margin-bottom: 2px;
  display: block;
}

.reply-content {
  color: #666;
  font-size: 11px;
  line-height: 1.3;
}

.reply-bar {
  background: #f8f9fa;
  padding: 12px 24px;
  border-top: 1px solid #e9ecef;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
}

.reply-info {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
}

.reply-label {
  color: #666;
  font-size: 12px;
}

.reply-to-user {
  font-weight: 600;
  font-size: 12px;
}

.reply-to-content {
  color: #666;
  font-size: 12px;
  max-width: 200px;
  overflow: hidden;
}

.reply-cancel {
  background: none;
  border: none;
  color: #999;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 14px;
}

.reply-cancel:hover {
  background: rgba(0, 0, 0, 0.1);
  color: #666;
}

.context-menu {
  background: rgba(255, 255, 255, 0.98);
  border-radius: 16px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.05);
  padding: 8px;
  min-width: 160px;
  animation: contextMenuAppear 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  transform-origin: top left;
  backdrop-filter: blur(20px) saturate(150%);
  border: 1px solid rgba(255, 255, 255, 0.2);
  position: fixed;
  z-index: 1000;
}

@keyframes contextMenuAppear {
  0% {
    opacity: 0;
    transform: scale(0.85) translateY(-8px);
  }
  100% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.context-menu-item {
  width: 100%;
  background: none;
  border: none;
  padding: 12px 16px;
  text-align: left;
  cursor: pointer;
  border-radius: 10px;
  font-family: 'Figtree', sans-serif;
  font-size: 14px;
  font-weight: 500;
  color: #1a1a1a;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: all 0.15s ease;
  margin: 2px 0;
}

.context-menu-item:hover {
  background: rgba(0, 122, 255, 0.1);
  color: #007AFF;
  transform: scale(1.02);
  transition: all 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.context-menu-item:active {
  background: rgba(0, 122, 255, 0.2);
  transform: scale(0.98);
  transition: all 0.1s ease-out;
}

.context-menu-item:first-child {
  margin-top: 0;
}

.context-menu-item:last-child {
  margin-bottom: 0;
}

.copied-notification {
  background: rgba(0, 122, 255, 0.1);
  border: 1px solid rgba(0, 122, 255, 0.2);
  border-radius: 12px;
  padding: 8px 16px;
  margin: 0 20px 10px 20px;
  text-align: center;
  font-family: 'Figtree', sans-serif;
  font-size: 14px;
  color: #007AFF;
  animation: copiedNotificationAppear 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes copiedNotificationAppear {
  0% {
    opacity: 0;
    transform: translateY(10px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

.message-timestamp {
  font-size: 11px;
  color: #888888;
  font-weight: 400;
  margin-top: 4px;
  padding: 0 4px;
}

.message-content {
  font-size: 15px;
  line-height: 1.4;
  word-break: break-word;
  overflow-wrap: break-word;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.message-other .message-bubble {
  background: #ffffff;
  color: #000000;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
  border: 1px solid #e5e5e5;
}

.message-own .message-bubble {
  background: #ffffff;
  color: #000000;
  border: 1px solid #e5e5e5;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
}

.message-own .message-user {
  color: #042dac;
}

.message-content {
  font-size: 15px;
  line-height: 1.5;
  font-weight: 400;
}

.chat-input-form {
  background: white;
  padding: 16px 24px 8px 24px;
  margin-bottom: 0;
  display: flex;
  gap: 16px;
  flex-shrink: 0;
  align-items: center;
  border-top: 1px solid #e0e0e0;
  box-sizing: border-box;
}

.chat-input {
  flex: 1;
  padding: 12px 18px;
  font-size: 16px;
  font-family: 'Figtree', sans-serif;
  border: 2px solid #e0e0e0;
  border-radius: 24px;
  outline: none;
  transition: all 0.2s ease;
  box-sizing: border-box;
  background: white;
  height: 44px;
}

.chat-input:focus {
  border-color: #042dac;
  box-shadow: 0 0 0 3px rgba(4, 45, 172, 0.1);
  outline: none;
}

.chat-input::placeholder {
  color: #999;
}

.send-button {
  padding: 0;
  width: 44px;
  height: 44px;
  font-size: 13px;
  font-weight: 700;
  font-family: 'Figtree', sans-serif;
  color: white !important;
  background: #042dac;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  flex-shrink: 0;
}

.send-button svg {
  width: 24px;
  height: 24px;
  color: white;
}

.send-button:hover {
  background: #031f7d;
}

.send-button:active {
  transform: scale(0.98);
}

/* Mobile Responsive */
@media (max-width: 768px) {
  .welcome-container {
    padding: 40px 30px;
  }

  .welcome-title {
    font-size: 32px;
  }

  .welcome-subtitle {
    font-size: 18px;
  }

  .chat-header-title {
    font-size: 20px;
  }

  .message-bubble {
    max-width: 85%;
  }

  .chat-input-form {
    padding: 10px 12px;
    padding-bottom: max(10px, env(safe-area-inset-bottom));
    box-sizing: border-box;
    gap: 10px;
  }

  .chat-input {
    font-size: 16px;
    padding: 10px 16px;
    height: 40px;
  }

  .send-button {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
  }

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

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

  .pinned-message {
    text-align: left;
  }
}
