/* Reset and Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  background: #0a0a0a;
  color: #ffffff;
  height: 100vh;
  overflow: hidden;
}

/* Accent Color */
.accent-text {
  color: #2c6bed;
}

/* Chat Container */
.chat-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-width: 1200px;
  margin: 0 auto;
  background: #0a0a0a;
  border: 1px solid #1a1a1a;
}

/* Header */
.chat-header {
  background: #0a0a0a;
  color: #ffffff;
  padding: 1.5rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #1a1a1a;
}

.chat-header h1 {
  font-size: 1.5rem;
  font-weight: 500;
  color: #ffffff;
  letter-spacing: -0.02em;
}

.user-count {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: #1a1a1a;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  font-size: 0.875rem;
  color: #888888;
  border: 1px solid #2a2a2a;
}

/* Modal Styles */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.9);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.modal-content {
  background: #0a0a0a;
  padding: 2.5rem;
  border-radius: 8px;
  text-align: center;
  border: 1px solid #1a1a1a;
  max-width: 400px;
  width: 90%;
}

.modal-content h2 {
  color: #ffffff;
  margin-bottom: 0.5rem;
  font-size: 1.5rem;
  font-weight: 500;
  letter-spacing: -0.02em;
}

.modal-content p {
  color: #888888;
  margin-bottom: 2rem;
  font-size: 0.875rem;
}

.modal-content input {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid #2a2a2a;
  border-radius: 6px;
  font-size: 0.875rem;
  margin-bottom: 1.5rem;
  background: #1a1a1a;
  color: #ffffff;
  transition: border-color 0.2s;
}

.modal-content input:focus {
  outline: none;
  border-color: #2c6bed;
}

.modal-content input::placeholder {
  color: #666666;
}

.join-button {
  background: #2c6bed;
  color: #ffffff;
  border: none;
  padding: 0.75rem 2rem;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0 auto;
}

.join-button:hover {
  background: #1e5bb8;
  transform: translateY(-1px);
}

.join-button .material-icons {
  font-size: 18px;
}

/* Chat Interface */
.chat-interface {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  width: 280px;
  background: #0a0a0a;
  border-right: 1px solid #1a1a1a;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.sidebar-section {
  margin-bottom: 1.5rem;
}

.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem 0.5rem;
  border-bottom: 1px solid #1a1a1a;
}

.sidebar-header h3 {
  color: #ffffff;
  font-size: 0.875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.add-btn {
  background: transparent;
  border: none;
  color: #888888;
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 4px;
  transition: all 0.2s;
}

.add-btn:hover {
  background: #1a1a1a;
  color: #ffffff;
}

.add-btn .material-icons {
  font-size: 18px;
}

/* Channels */
.channels-list {
  padding: 0.5rem 0;
}

.channel-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  cursor: pointer;
  transition: background 0.2s;
  color: #888888;
}

.channel-item:hover {
  background: #1a1a1a;
  color: #ffffff;
}

.channel-item.active {
  background: #2c6bed;
  color: #ffffff;
}

.channel-item .material-icons {
  font-size: 16px;
}

/* Main Chat Area */
.main-chat {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-main-header {
  background: #0a0a0a;
  border-bottom: 1px solid #1a1a1a;
  padding: 1rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.current-channel {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

#currentChannelName {
  font-size: 1.1rem;
  font-weight: 600;
  color: #ffffff;
}

#currentChannelDescription {
  font-size: 0.875rem;
  color: #888888;
}

.chat-actions {
  display: flex;
  gap: 0.5rem;
}

.action-btn {
  background: transparent;
  border: 1px solid #2a2a2a;
  color: #888888;
  padding: 0.5rem;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}

.action-btn:hover {
  background: #1a1a1a;
  color: #ffffff;
}

.action-btn .material-icons {
  font-size: 18px;
}

/* Users Panel */
.users-panel {
  width: 250px;
  background: #0a0a0a;
  border-right: 1px solid #1a1a1a;
  padding: 1rem;
  overflow-y: auto;
}

.users-panel h3 {
  color: #ffffff;
  margin-bottom: 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.users-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.user-item {
  background: #1a1a1a;
  padding: 0.5rem 0.8rem;
  border-radius: 6px;
  border-left: 3px solid #2c6bed;
  border: 1px solid #2a2a2a;
  font-size: 0.875rem;
  color: #ffffff;
}

/* Messages Container */
.messages-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.messages {
  flex: 1;
  padding: 1rem;
  overflow-y: auto;
  background: #0a0a0a;
}

.message {
  margin-bottom: 1rem;
  display: flex;
  flex-direction: column;
  animation: slideIn 0.3s ease-out;
}

.message.own {
  align-items: flex-end;
}

.message.other {
  align-items: flex-start;
}

.message-content {
  max-width: 70%;
  padding: 0.8rem 1rem;
  border-radius: 15px;
  word-wrap: break-word;
  position: relative;
}

.message.own .message-content {
  background: #ffffff;
  color: #0a0a0a;
  border-bottom-right-radius: 5px;
}

.message.other .message-content {
  background: #1a1a1a;
  color: #ffffff;
  border: 1px solid #2a2a2a;
  border-bottom-left-radius: 5px;
}

.message-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.3rem;
  font-size: 0.75rem;
  color: #888888;
  gap: 0.5rem;
}

.message.own .message-info {
  color: #666666;
}

.message-text {
  line-height: 1.4;
}

.message-image {
  max-width: 100%;
  max-height: 300px;
  border-radius: 8px;
  margin-top: 0.3rem;
  cursor: pointer;
  transition: transform 0.2s;
}

.message-image:hover {
  transform: scale(1.02);
}

.image-caption {
  font-size: 0.8rem;
  color: #888888;
  margin-top: 0.3rem;
  font-style: italic;
}

.message-file {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem;
  background: #1a1a1a;
  border-radius: 6px;
  margin-top: 0.3rem;
  cursor: pointer;
  transition: background 0.2s;
}

.message-file:hover {
  background: #2a2a2a;
}

.file-icon {
  font-size: 1.2rem;
  color: #2c6bed;
}

.file-info {
  flex: 1;
}

.file-name {
  font-weight: 500;
  color: #ffffff;
  font-size: 0.9rem;
}

.file-size {
  font-size: 0.8rem;
  color: #888888;
}

.modal-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}

.cancel-button {
  background: #2a2a2a;
  color: #ffffff;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s;
}

.cancel-button:hover {
  background: #3a3a3a;
}

textarea {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid #2a2a2a;
  border-radius: 6px;
  background: #1a1a1a;
  color: #ffffff;
  font-family: inherit;
  resize: vertical;
  margin-bottom: 1rem;
}

textarea:focus {
  outline: none;
  border-color: #2c6bed;
}

/* Commands Help */
.help-modal {
  max-width: 700px;
  max-height: 85vh;
  overflow-y: auto;
}

.help-section {
  margin-bottom: 2rem;
}

.help-section h3 {
  color: #2c6bed;
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 1rem;
  border-bottom: 1px solid #2a2a2a;
  padding-bottom: 0.5rem;
}

.commands-list {
  max-height: 300px;
  overflow-y: auto;
}

.command-item {
  background: #1a1a1a;
  border: 1px solid #2a2a2a;
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1rem;
  transition: all 0.2s;
}

.command-item:hover {
  border-color: #2c6bed;
}

.command-name {
  color: #2c6bed;
  font-weight: 600;
  font-size: 1rem;
  margin-bottom: 0.5rem;
  font-family: monospace;
}

.command-description {
  color: #ffffff;
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
}

.command-example {
  color: #888888;
  font-size: 0.8rem;
  font-style: italic;
}

/* Formatting Help Styles */
.formatting-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.formatting-item {
  background: #1a1a1a;
  border: 1px solid #2a2a2a;
  border-radius: 8px;
  padding: 1rem;
  transition: all 0.2s;
}

.formatting-item:hover {
  border-color: #2c6bed;
}

.formatting-syntax {
  color: #2c6bed;
  font-family: monospace;
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  background: #0a0a0a;
  padding: 0.5rem;
  border-radius: 4px;
  border: 1px solid #2a2a2a;
}

.formatting-result {
  color: #ffffff;
  font-size: 0.9rem;
  padding: 0.5rem;
  background: #0a0a0a;
  border-radius: 4px;
  border: 1px solid #2a2a2a;
}

/* Code Help Styles */
.code-help {
  background: #1a1a1a;
  border: 1px solid #2a2a2a;
  border-radius: 8px;
  padding: 1rem;
}

.code-example {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.code-syntax {
  color: #2c6bed;
  font-family: monospace;
  font-size: 0.9rem;
  background: #0a0a0a;
  padding: 1rem;
  border-radius: 4px;
  border: 1px solid #2a2a2a;
  white-space: pre-line;
}

.code-description {
  color: #ffffff;
  font-size: 0.9rem;
  line-height: 1.5;
}

/* Command Autocomplete */
.input-wrapper {
  position: relative;
  flex: 1;
}

.command-autocomplete {
  position: absolute;
  bottom: 100%;
  left: 0;
  right: 0;
  background: #1a1a1a;
  border: 1px solid #2a2a2a;
  border-radius: 8px 8px 0 0;
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.3);
  z-index: 1000;
  max-height: 200px;
  overflow-y: auto;
}

.autocomplete-header {
  padding: 0.75rem 1rem 0.5rem;
  color: #2c6bed;
  font-weight: 600;
  font-size: 0.9rem;
  border-bottom: 1px solid #2a2a2a;
}

.autocomplete-list {
  padding: 0.5rem 0;
}

.autocomplete-item {
  display: flex;
  flex-direction: column;
  padding: 0.75rem 1rem;
  cursor: pointer;
  transition: background 0.2s;
  border-bottom: 1px solid #2a2a2a;
}

.autocomplete-item:last-child {
  border-bottom: none;
}

.autocomplete-item:hover,
.autocomplete-item.selected {
  background: #2c6bed;
}

.autocomplete-item .command-name {
  color: #ffffff;
  font-weight: 600;
  font-size: 0.9rem;
  font-family: monospace;
  margin-bottom: 0.25rem;
}

.autocomplete-item .command-desc {
  color: #cccccc;
  font-size: 0.8rem;
}

.autocomplete-item:hover .command-name,
.autocomplete-item.selected .command-name {
  color: #ffffff;
}

.autocomplete-item:hover .command-desc,
.autocomplete-item.selected .command-desc {
  color: #ffffff;
}

/* Message Formatting Styles */
.message-text strong {
  font-weight: 600;
  color: inherit;
}

.message-text em {
  font-style: italic;
  color: inherit;
}

.message-text del {
  text-decoration: line-through;
  opacity: 0.7;
}

.message-text a {
  color: #2c6bed;
  text-decoration: underline;
  transition: color 0.2s;
}

.message-text a:hover {
  color: #1e5bb8;
}

.inline-code {
  background: #1a1a1a;
  border: 1px solid #2a2a2a;
  border-radius: 4px;
  padding: 0.2rem 0.4rem;
  font-family: "Courier New", Courier, monospace;
  font-size: 0.85em;
  color: #e6e6e6;
}

.message.own .inline-code {
  background: #f0f0f0;
  border-color: #d0d0d0;
  color: #333;
}

/* Code Block Styles */
.code-block {
  background: #1a1a1a;
  border: 1px solid #2a2a2a;
  border-radius: 8px;
  margin: 0.5rem 0;
  overflow: hidden;
  font-family: "Courier New", Courier, monospace;
}

.message.own .code-block {
  background: #f8f8f8;
  border-color: #e0e0e0;
}

.code-header {
  background: #2a2a2a;
  padding: 0.5rem 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #3a3a3a;
}

.message.own .code-header {
  background: #e8e8e8;
  border-bottom-color: #d0d0d0;
}

.code-language {
  font-size: 0.8rem;
  font-weight: 600;
  color: #888888;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.message.own .code-language {
  color: #666666;
}

.code-copy-btn,
.code-expand-btn {
  background: transparent;
  border: none;
  color: #888888;
  padding: 0.25rem;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.code-copy-btn:hover,
.code-expand-btn:hover {
  background: #3a3a3a;
  color: #ffffff;
}

.message.own .code-copy-btn:hover,
.message.own .code-expand-btn:hover {
  background: #d0d0d0;
  color: #333333;
}

.code-copy-btn .material-icons,
.code-expand-btn .material-icons {
  font-size: 16px;
}

.code-block pre {
  margin: 0;
  padding: 1rem;
  overflow-x: auto;
  background: transparent;
}

.code-block code {
  background: transparent;
  border: none;
  padding: 0;
  font-size: 0.9rem;
  line-height: 1.4;
  color: #e6e6e6;
}

.message.own .code-block code {
  color: #333333;
}

/* Code Modal Styles */
.code-modal-content {
  background: #0a0a0a;
  border: 1px solid #1a1a1a;
  border-radius: 8px;
  max-width: 90vw;
  max-height: 90vh;
  width: 800px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.code-modal-header {
  background: #1a1a1a;
  border-bottom: 1px solid #2a2a2a;
  padding: 1rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.code-modal-header h3 {
  color: #ffffff;
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0;
}

.code-modal-actions {
  display: flex;
  gap: 0.5rem;
}

.code-modal-copy,
.code-modal-close {
  background: transparent;
  border: 1px solid #2a2a2a;
  color: #888888;
  padding: 0.5rem;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.code-modal-copy:hover,
.code-modal-close:hover {
  background: #2a2a2a;
  color: #ffffff;
}

.code-modal-copy .material-icons,
.code-modal-close .material-icons {
  font-size: 18px;
}

.code-modal-body {
  flex: 1;
  overflow: auto;
  padding: 0;
}

.code-modal-body pre {
  margin: 0;
  padding: 1.5rem;
  background: #0a0a0a;
  overflow-x: auto;
  font-family: "Courier New", Courier, monospace;
  font-size: 0.9rem;
  line-height: 1.5;
}

.code-modal-body code {
  background: transparent;
  border: none;
  padding: 0;
  color: #e6e6e6;
}

.message:hover .message-actions {
  display: flex;
  opacity: 1;
  transform: translateY(0);
}

.message-actions {
  position: absolute;
  top: -10px;
  right: -10px;
  background: #1a1a1a;
  border: 1px solid #2a2a2a;
  border-radius: 6px;
  padding: 0.25rem;
  display: none;
  gap: 0.25rem;
  opacity: 0;
  transform: translateY(-5px);
  transition: all 0.2s ease;
}

.message-action-btn {
  background: transparent;
  border: none;
  color: #888888;
  padding: 0.25rem;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
}

.message-action-btn:hover {
  background: #2a2a2a;
  color: #ffffff;
}

.message-action-btn.delete:hover {
  background: #ff6b6b;
  color: #ffffff;
}

/* Enhanced User Interface */
.enhanced-message {
  position: relative;
}

.enhanced-message:hover {
  background: rgba(44, 107, 237, 0.05);
}

/* Message highlighting for replies and mentions */
.message.highlighted {
  background: rgba(44, 107, 237, 0.1) !important;
  border: 2px solid #2c6bed !important;
  border-radius: 8px !important;
  animation: highlightPulse 0.5s ease-in-out;
}

.message.mentioned {
  background: rgba(255, 193, 7, 0.1) !important;
  border: 2px solid #ffc107 !important;
  border-radius: 8px !important;
  animation: mentionGlow 0.5s ease-in-out;
}

@keyframes highlightPulse {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.02);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes mentionGlow {
  0% {
    box-shadow: 0 0 0 rgba(255, 193, 7, 0.4);
  }
  50% {
    box-shadow: 0 0 20px rgba(255, 193, 7, 0.6);
  }
  100% {
    box-shadow: 0 0 0 rgba(255, 193, 7, 0.4);
  }
}

/* Notification System */
.notification {
  position: fixed;
  top: 20px;
  right: 20px;
  background: #1a1a1a;
  border: 1px solid #2a2a2a;
  border-radius: 6px;
  padding: 1rem;
  color: #ffffff;
  z-index: 10000;
  max-width: 300px;
  display: none;
}

.notification.success {
  border-color: #51cf66;
}

.notification.error {
  border-color: #ff6b6b;
}

.notification.warning {
  border-color: #ffd43b;
}

/* Keyboard Shortcuts */
.shortcuts-help {
  position: fixed;
  bottom: 20px;
  left: 20px;
  background: #1a1a1a;
  border: 1px solid #2a2a2a;
  border-radius: 6px;
  padding: 1rem;
  color: #888888;
  font-size: 0.8rem;
  display: none;
  z-index: 1000;
}

.shortcuts-help h4 {
  color: #ffffff;
  margin-bottom: 0.5rem;
}

.shortcut {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.25rem;
}

.shortcut-key {
  background: #2a2a2a;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-family: monospace;
}

.message-time {
  font-size: 0.7rem;
  opacity: 0.7;
  margin-top: 0.3rem;
}

/* Typing Indicator */
.typing-indicator {
  padding: 0.5rem 1rem;
  font-style: italic;
  color: #888888;
  font-size: 0.875rem;
  min-height: 1.5rem;
  display: none;
  animation: fadeIn 0.3s ease-in;
}

.typing-content {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.typing-text {
  color: #888888;
  font-size: 0.8rem;
}

.typing-dots {
  display: flex;
  gap: 0.2rem;
  align-items: center;
}

.typing-dots .dot {
  width: 4px;
  height: 4px;
  background-color: #888888;
  border-radius: 50%;
  animation: typingDots 1.4s infinite ease-in-out;
}

.typing-dots .dot:nth-child(1) {
  animation-delay: -0.32s;
}

.typing-dots .dot:nth-child(2) {
  animation-delay: -0.16s;
}

.typing-dots .dot:nth-child(3) {
  animation-delay: 0s;
}

@keyframes typingDots {
  0%,
  80%,
  100% {
    transform: scale(0.8);
    opacity: 0.5;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Message Input */
.message-input-container {
  padding: 1rem;
  background: #0a0a0a;
  border-top: 1px solid #1a1a1a;
}

.input-group {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

#messageInput {
  flex: 1;
  padding: 0.75rem 1rem;
  border: 1px solid #2a2a2a;
  border-radius: 6px;
  font-size: 0.875rem;
  outline: none;
  background: #1a1a1a;
  color: #ffffff;
  transition: border-color 0.2s;
}

#messageInput:focus {
  border-color: #2c6bed;
}

#messageInput::placeholder {
  color: #666666;
}

.image-button {
  background: #1a1a1a;
  color: #ffffff;
  border: 1px solid #2a2a2a;
  width: 40px;
  height: 40px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.image-button:hover {
  background: #2a2a2a;
  transform: scale(1.05);
}

.image-button .material-icons {
  font-size: 20px;
}

.file-button {
  background: #1a1a1a;
  color: #ffffff;
  border: 1px solid #2a2a2a;
  width: 40px;
  height: 40px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.file-button:hover {
  background: #2a2a2a;
  transform: scale(1.05);
}

.file-button .material-icons {
  font-size: 20px;
}

.send-button {
  background: #2c6bed;
  color: #ffffff;
  border: none;
  width: 40px;
  height: 40px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.send-button:hover {
  background: #1e5bb8;
  transform: scale(1.05);
}

.send-button .material-icons {
  font-size: 18px;
}

.send-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* Animations */
@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes typing {
  0%,
  60%,
  100% {
    transform: translateY(0);
  }
  30% {
    transform: translateY(-10px);
  }
}

/* PWA and Mobile Optimizations */
body {
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  position: fixed;
  width: 100%;
  height: 100%;
}

/* Safe area support for mobile devices */
.chat-container {
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

/* Mobile-First Responsive Design */
@media (max-width: 1024px) {
  .chat-container {
    max-width: 100%;
    height: 100vh;
    height: 100dvh; /* Dynamic viewport height */
  }

  .users-panel {
    width: 200px;
  }
}

@media (max-width: 768px) {
  .chat-interface {
    flex-direction: column;
    height: 100vh;
    height: 100dvh; /* Dynamic viewport height for mobile */
  }

  /* Improve mobile scrolling */
  .messages {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }

  /* Better touch targets */
  .channel-item,
  .user-item,
  .message-action-btn {
    min-height: 44px;
    min-width: 44px;
  }

  /* Prevent zoom on input focus */
  input,
  textarea,
  select {
    font-size: 16px;
  }

  .sidebar {
    width: 100%;
    max-height: 120px;
    border-right: none;
    border-bottom: 1px solid #1a1a1a;
    flex-direction: row;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 0.5rem 0;
    -webkit-overflow-scrolling: touch;
  }

  .sidebar-section {
    margin-bottom: 0;
    margin-right: 1rem;
    min-width: 180px;
    flex-shrink: 0;
  }

  .sidebar-header {
    padding: 0.25rem 0.5rem;
    border-bottom: none;
    margin-bottom: 0.25rem;
  }

  .sidebar-header h3 {
    font-size: 0.7rem;
    margin-bottom: 0;
  }

  .channels-list {
    display: flex;
    flex-direction: row;
    gap: 0.25rem;
    padding: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .channel-item {
    white-space: nowrap;
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    border-radius: 4px;
    flex-shrink: 0;
    min-width: fit-content;
  }

  .users-list {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 0.25rem;
    padding: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .user-item {
    font-size: 0.7rem;
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    flex-shrink: 0;
    white-space: nowrap;
    min-width: fit-content;
  }

  .message-content {
    max-width: 85%;
    padding: 0.6rem 0.8rem;
  }

  .chat-header {
    padding: 0.75rem 1rem;
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .chat-header h1 {
    font-size: 1.2rem;
  }

  .user-count {
    font-size: 0.8rem;
    padding: 0.4rem 0.8rem;
  }

  .message-input-container {
    padding: 0.75rem;
  }

  #messageInput {
    font-size: 16px; /* Prevents zoom on iOS */
    padding: 0.6rem 0.8rem;
  }

  .file-button {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
  }

  .file-button .material-icons {
    font-size: 18px;
  }

  .send-button {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
  }

  .send-button .material-icons {
    font-size: 16px;
  }

  .input-group {
    gap: 0.4rem;
  }

  .typing-indicator {
    padding: 0.4rem 0.75rem;
    font-size: 0.8rem;
  }

  .typing-text {
    font-size: 0.75rem;
  }

  .typing-dots .dot {
    width: 3px;
    height: 3px;
  }

  /* Mobile formatting styles */
  .inline-code {
    font-size: 0.8em;
    padding: 0.15rem 0.3rem;
  }

  .code-block {
    margin: 0.3rem 0;
    border-radius: 6px;
  }

  .code-header {
    padding: 0.4rem 0.8rem;
  }

  .code-language {
    font-size: 0.7rem;
  }

  .code-copy-btn,
  .code-expand-btn {
    padding: 0.2rem;
  }

  .code-copy-btn .material-icons,
  .code-expand-btn .material-icons {
    font-size: 14px;
  }

  .code-block pre {
    padding: 0.8rem;
    font-size: 0.8rem;
  }

  .code-modal-content {
    max-width: 95vw;
    max-height: 95vh;
    width: 100%;
    margin: 1rem;
  }

  .code-modal-header {
    padding: 0.8rem 1rem;
  }

  .code-modal-header h3 {
    font-size: 1rem;
  }

  .code-modal-copy,
  .code-modal-close {
    padding: 0.4rem;
  }

  .code-modal-copy .material-icons,
  .code-modal-close .material-icons {
    font-size: 16px;
  }

  .code-modal-body pre {
    padding: 1rem;
    font-size: 0.8rem;
  }

  /* Mobile help modal styles */
  .help-modal {
    max-width: 95vw;
    max-height: 95vh;
    margin: 0.5rem;
  }

  .help-section {
    margin-bottom: 1.5rem;
  }

  .help-section h3 {
    font-size: 1rem;
  }

  .command-item,
  .formatting-item {
    padding: 0.8rem;
  }

  .command-name,
  .formatting-syntax {
    font-size: 0.9rem;
  }

  .command-description,
  .formatting-result {
    font-size: 0.85rem;
  }

  .code-syntax {
    font-size: 0.8rem;
    padding: 0.8rem;
  }

  .code-description {
    font-size: 0.85rem;
  }

  /* Mobile badge and call styles */
  .user-badge {
    font-size: 0.6rem;
    padding: 0.05rem 0.2rem;
  }

  .user-item {
    padding: 0.4rem 0.6rem;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .user-info {
    width: 100%;
  }

  .user-actions {
    opacity: 1;
    align-self: flex-end;
  }

  .call-btn {
    min-width: 28px;
    min-height: 28px;
  }

  .call-btn .material-icons {
    font-size: 14px;
  }

  .call-modal {
    padding: 1rem;
  }

  .call-container {
    max-height: 95vh;
  }

  .call-header {
    padding: 0.8rem 1rem;
  }

  .call-header h3 {
    font-size: 1rem;
  }

  .call-info {
    flex-direction: column;
    gap: 0.25rem;
  }

  .call-video-container {
    min-height: 200px;
  }

  .local-video {
    width: 80px;
    height: 60px;
    top: 0.5rem;
    right: 0.5rem;
  }

  .call-controls {
    padding: 0.8rem 1rem;
    gap: 0.5rem;
  }

  .call-control-btn {
    min-width: 40px;
    min-height: 40px;
    padding: 0.5rem;
  }

  .call-control-btn .material-icons {
    font-size: 20px;
  }

  .call-notification {
    top: 10px;
    right: 10px;
    left: 10px;
    max-width: none;
    padding: 0.8rem;
  }
}

@media (max-width: 480px) {
  .modal-content {
    margin: 0.5rem;
    padding: 1.25rem;
    max-width: 95%;
  }

  .modal-content h2 {
    font-size: 1.25rem;
  }

  .modal-content input {
    font-size: 16px; /* Prevents zoom on iOS */
    padding: 0.6rem 0.8rem;
  }

  .join-button {
    padding: 0.6rem 1.5rem;
    font-size: 0.8rem;
  }

  .sidebar {
    max-height: 100px;
    padding: 0.25rem 0;
  }

  .sidebar-section {
    min-width: 150px;
    margin-right: 0.75rem;
  }

  .sidebar-header h3 {
    font-size: 0.65rem;
  }

  .channel-item {
    font-size: 0.7rem;
    padding: 0.2rem 0.4rem;
  }

  .user-item {
    font-size: 0.65rem;
    padding: 0.15rem 0.3rem;
  }

  .message-content {
    max-width: 90%;
    padding: 0.5rem 0.7rem;
  }

  .message-info {
    font-size: 0.7rem;
  }

  .message-text {
    font-size: 0.9rem;
  }

  .chat-header {
    padding: 0.5rem 0.75rem;
  }

  .chat-header h1 {
    font-size: 1.1rem;
  }

  .user-count {
    font-size: 0.75rem;
    padding: 0.3rem 0.6rem;
  }

  .message-input-container {
    padding: 0.5rem;
  }

  #messageInput {
    padding: 0.5rem 0.7rem;
    font-size: 16px;
  }

  .file-button {
    width: 32px;
    height: 32px;
  }

  .file-button .material-icons {
    font-size: 16px;
  }

  .send-button {
    width: 32px;
    height: 32px;
  }

  .send-button .material-icons {
    font-size: 14px;
  }

  .input-group {
    gap: 0.3rem;
  }

  .chat-main-header {
    padding: 0.75rem 1rem;
  }

  .current-channel {
    gap: 0.1rem;
  }

  #currentChannelName {
    font-size: 1rem;
  }

  #currentChannelDescription {
    font-size: 0.8rem;
  }

  .chat-actions {
    gap: 0.25rem;
  }

  .action-btn {
    padding: 0.4rem;
  }

  .action-btn .material-icons {
    font-size: 16px;
  }

  .typing-indicator {
    padding: 0.3rem 0.5rem;
    font-size: 0.75rem;
  }

  .typing-text {
    font-size: 0.7rem;
  }

  .typing-dots .dot {
    width: 3px;
    height: 3px;
  }

  /* Small mobile formatting styles */
  .inline-code {
    font-size: 0.75em;
    padding: 0.1rem 0.25rem;
  }

  .code-block {
    margin: 0.25rem 0;
    border-radius: 4px;
  }

  .code-header {
    padding: 0.3rem 0.6rem;
  }

  .code-language {
    font-size: 0.65rem;
  }

  .code-copy-btn,
  .code-expand-btn {
    padding: 0.15rem;
  }

  .code-copy-btn .material-icons,
  .code-expand-btn .material-icons {
    font-size: 12px;
  }

  .code-block pre {
    padding: 0.6rem;
    font-size: 0.75rem;
  }

  .code-modal-content {
    max-width: 98vw;
    max-height: 98vh;
    margin: 0.5rem;
  }

  .code-modal-header {
    padding: 0.6rem 0.8rem;
  }

  .code-modal-header h3 {
    font-size: 0.9rem;
  }

  .code-modal-copy,
  .code-modal-close {
    padding: 0.3rem;
  }

  .code-modal-copy .material-icons,
  .code-modal-close .material-icons {
    font-size: 14px;
  }

  .code-modal-body pre {
    padding: 0.8rem;
    font-size: 0.75rem;
  }

  /* Small mobile help modal styles */
  .help-modal {
    max-width: 98vw;
    max-height: 98vh;
    margin: 0.25rem;
  }

  .help-section {
    margin-bottom: 1rem;
  }

  .help-section h3 {
    font-size: 0.9rem;
  }

  .command-item,
  .formatting-item {
    padding: 0.6rem;
  }

  .command-name,
  .formatting-syntax {
    font-size: 0.8rem;
  }

  .command-description,
  .formatting-result {
    font-size: 0.8rem;
  }

  .code-syntax {
    font-size: 0.75rem;
    padding: 0.6rem;
  }

  .code-description {
    font-size: 0.8rem;
  }

  /* Small mobile badge and call styles */
  .user-badge {
    font-size: 0.55rem;
    padding: 0.05rem 0.15rem;
  }

  .user-item {
    padding: 0.3rem 0.5rem;
  }

  .call-btn {
    min-width: 24px;
    min-height: 24px;
  }

  .call-btn .material-icons {
    font-size: 12px;
  }

  .call-modal {
    padding: 0.5rem;
  }

  .call-container {
    max-height: 98vh;
  }

  .call-header {
    padding: 0.6rem 0.8rem;
  }

  .call-header h3 {
    font-size: 0.9rem;
  }

  .call-video-container {
    min-height: 150px;
  }

  .local-video {
    width: 60px;
    height: 45px;
    top: 0.25rem;
    right: 0.25rem;
  }

  .call-controls {
    padding: 0.6rem 0.8rem;
    gap: 0.25rem;
  }

  .call-control-btn {
    min-width: 36px;
    min-height: 36px;
    padding: 0.4rem;
  }

  .call-control-btn .material-icons {
    font-size: 18px;
  }

  .call-notification {
    padding: 0.6rem;
  }

  .call-notification-btn {
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
  }
}

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {
  .join-button:hover,
  .send-button:hover,
  .file-button:hover,
  .action-btn:hover,
  .add-btn:hover {
    transform: none;
  }

  .join-button:active,
  .send-button:active,
  .file-button:active,
  .action-btn:active,
  .add-btn:active {
    transform: scale(0.95);
  }

  .channel-item:active,
  .user-item:active {
    transform: scale(0.98);
  }

  .user-item {
    padding: 0.4rem 0.6rem;
    margin: 0.1rem;
    min-height: 44px; /* iOS touch target minimum */
    display: flex;
    align-items: center;
  }

  .channel-item {
    min-height: 44px; /* iOS touch target minimum */
    display: flex;
    align-items: center;
  }

  .message-content {
    padding: 0.7rem 1rem;
  }

  .add-btn {
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .action-btn {
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .file-button,
  .send-button {
    min-width: 44px;
    min-height: 44px;
  }

  .code-copy-btn,
  .code-expand-btn {
    min-width: 44px;
    min-height: 44px;
  }

  .code-modal-copy,
  .code-modal-close {
    min-width: 44px;
    min-height: 44px;
  }

  /* Improve touch scrolling */
  .messages,
  .sidebar,
  .channels-list,
  .users-list {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }
}

/* Landscape mobile optimization */
@media (max-width: 768px) and (orientation: landscape) {
  .sidebar {
    max-height: 80px;
  }

  .sidebar-section {
    min-width: 160px;
  }

  .channels-list,
  .users-list {
    flex-direction: row;
    flex-wrap: nowrap;
    overflow-x: auto;
  }

  .channel-item,
  .user-item {
    flex-shrink: 0;
    white-space: nowrap;
  }

  .message-input-container {
    padding: 0.5rem;
  }

  .chat-main-header {
    padding: 0.5rem 1rem;
  }
}

/* Scrollbar Styling */
.messages::-webkit-scrollbar,
.sidebar::-webkit-scrollbar,
.channels-list::-webkit-scrollbar,
.users-list::-webkit-scrollbar {
  width: 6px;
}

.messages::-webkit-scrollbar-track,
.sidebar::-webkit-scrollbar-track,
.channels-list::-webkit-scrollbar-track,
.users-list::-webkit-scrollbar-track {
  background: #0a0a0a;
}

.messages::-webkit-scrollbar-thumb,
.sidebar::-webkit-scrollbar-thumb,
.channels-list::-webkit-scrollbar-thumb,
.users-list::-webkit-scrollbar-thumb {
  background: #2a2a2a;
  border-radius: 3px;
}

.messages::-webkit-scrollbar-thumb:hover,
.sidebar::-webkit-scrollbar-thumb:hover,
.channels-list::-webkit-scrollbar-thumb:hover,
.users-list::-webkit-scrollbar-thumb:hover {
  background: #3a3a3a;
}

/* User Badge Styles */
.user-badge {
  display: inline-block;
  margin-left: 0.25rem;
  padding: 0.1rem 0.3rem;
  border-radius: 12px;
  font-size: 0.7rem;
  font-weight: 600;
  color: #ffffff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  vertical-align: middle;
}

.message-username {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

/* User List Styles */
.user-item {
  background: #1a1a1a;
  padding: 0.5rem 0.8rem;
  border-radius: 6px;
  border-left: 3px solid #2c6bed;
  border: 1px solid #2a2a2a;
  font-size: 0.875rem;
  color: #ffffff;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: all 0.2s;
}

.user-item:hover {
  background: #2a2a2a;
  border-color: #2c6bed;
}

.user-info {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  flex: 1;
}

.user-name {
  font-weight: 500;
  color: #ffffff;
}

.user-badges {
  display: flex;
  gap: 0.2rem;
  flex-wrap: wrap;
}

.user-actions {
  display: flex;
  gap: 0.25rem;
  opacity: 0;
  transition: opacity 0.2s;
}

.user-item:hover .user-actions {
  opacity: 1;
}

/* Call button styles removed */

/* Call interface styles removed */

/* Call container removed */

/* Call header styles removed */

.call-video-container {
  flex: 1;
  display: flex;
  position: relative;
  background: #0a0a0a;
  min-height: 300px;
}

.local-video {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 120px;
  height: 90px;
  border-radius: 8px;
  overflow: hidden;
  border: 2px solid #2a2a2a;
  z-index: 2;
}

.local-video video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.remote-video {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.remote-video video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.no-video-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #888888;
  font-size: 1.2rem;
  gap: 0.5rem;
}

.no-video-placeholder .material-icons {
  font-size: 4rem;
  opacity: 0.5;
}

.call-controls {
  background: #1a1a1a;
  border-top: 1px solid #2a2a2a;
  padding: 1rem 1.5rem;
  display: flex;
  justify-content: center;
  gap: 1rem;
}

.call-control-btn {
  background: #2a2a2a;
  border: 1px solid #3a3a3a;
  color: #ffffff;
  padding: 0.75rem;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 50px;
  min-height: 50px;
}

.call-control-btn:hover {
  background: #3a3a3a;
  transform: scale(1.05);
}

.call-control-btn.end-call {
  background: #ff6b6b;
  border-color: #ff6b6b;
}

.call-control-btn.end-call:hover {
  background: #ff5252;
}

.call-control-btn.accept-call {
  background: #51cf66;
  border-color: #51cf66;
}

.call-control-btn.accept-call:hover {
  background: #40c057;
}

.call-control-btn .material-icons {
  font-size: 24px;
}

/* Call Notification Styles */
.call-notification {
  position: fixed;
  top: 20px;
  right: 20px;
  background: #1a1a1a;
  border: 1px solid #2a2a2a;
  border-radius: 8px;
  padding: 1rem;
  color: #ffffff;
  z-index: 10001;
  max-width: 300px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  animation: slideInRight 0.3s ease-out;
}

.call-notification-content {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.call-notification-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: #2c6bed;
  font-weight: 600;
}

.call-notification-body {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.caller-name {
  font-size: 1.1rem;
  font-weight: 500;
}

.call-notification-actions {
  display: flex;
  gap: 0.5rem;
}

.call-notification-btn {
  flex: 1;
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.2s;
}

.call-notification-btn.accept {
  background: #51cf66;
  color: #ffffff;
}

.call-notification-btn.accept:hover {
  background: #40c057;
}

.call-notification-btn.decline {
  background: #ff6b6b;
  color: #ffffff;
}

.call-notification-btn.decline:hover {
  background: #ff5252;
}

@keyframes slideInRight {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}
