/* Prevent Inspect */
/* Note: This script is moved to login.js file */

:root.--dark-theme {
  --primary-bg: #0e1112;
  --secondary-bg: #1a1d1e;
  --message-bg: #1f2426;
  --own-message-bg: #2a3b5a;
  --text-primary: #f0f0f0;
  --text-secondary: #a0a0a0;
  --accent-color: #7c3aed;
  --accent-hover: #6d28d9;
  --border-color: #2a2f32;
  --header-bg: #1a1d1e;
  --success-color: #10b981;
  --danger-color: #ef4444;
  --warning-color: #f59e0b;
  --online-color: #10b981;
  --typing-color: #3b82f6;
  --reply-bg: rgba(124, 58, 237, 0.15);
  --date-separator: rgba(124, 58, 237, 0.2);
  --modal-bg: rgba(0, 0, 0, 0.9);
  --menu-bg: #2d3748;
  --recording-bg: #ef4444;
  --search-bg: #2a2f32;
  --search-input-bg: #3a3f42;
  --search-result-text: #f0f0f0;
  --search-result-bg: #2a2f32;
  --search-meta-text: #a0a0a0;
}

:root.--light-theme {
  --primary-bg: #f5f7fa;
  --secondary-bg: #ffffff;
  --message-bg: #f0f2f5;
  --own-message-bg: #007bff;
  --text-primary: #333333;
  --text-secondary: #666666;
  --accent-color: #007bff;
  --accent-hover: #0056cc;
  --border-color: #e0e0e0;
  --header-bg: #ffffff;
  --success-color: #28a745;
  --danger-color: #dc3545;
  --warning-color: #ffc107;
  --online-color: #28a745;
  --typing-color: #007bff;
  --reply-bg: rgba(0, 123, 255, 0.1);
  --date-separator: rgba(0, 123, 255, 0.15);
  --modal-bg: rgba(0, 0, 0, 0.7);
  --menu-bg: #ffffff;
  --recording-bg: #dc3545;
  --search-bg: #f0f2f5;
  --search-input-bg: #ffffff;
  --search-result-text: #333333; /* Light theme text */
  --search-result-bg: #ffffff; /* Light theme background */
  --search-meta-text: #666666; /* Light theme metadata */
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: 'Lato', sans-serif;
  background: url('login background 123.png') no-repeat center center/cover;
  height: 100vh;
  margin: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  touch-action: manipulation;
}

.login-container,
.verification-box {
  background: rgba(255, 255, 255, 0.2);
  padding: 30px 25px;
  border-radius: 15px;
  backdrop-filter: blur(10px);
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.2);
  width: 90%;
  max-width: 350px;
  text-align: center;
  position: relative;
  z-index: 1;
}

.verification-box {
  display: none;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  background: white;
  padding: 20px;
  border-radius: 15px;
  z-index: 1002;
}

.login-container h2 {
  color: white;
  margin-bottom: 20px;
  font-size: 24px;
}

label {
  color: white;
  display: block;
  margin-top: 10px;
  text-align: left;
  font-size: 14px;
}

input[type="text"],
input[type="password"] {
  width: 100%;
  padding: 12px 15px;
  margin-top: 5px;
  border: none;
  border-radius: 8px;
  outline: none;
  font-size: 16px;
  background: rgba(255, 255, 255, 0.9);
}

input[type="submit"] {
  width: 100%;
  padding: 14px;
  margin-top: 15px;
  background-color: #6d28d9;
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 16px;
  font-weight: bold;
}

.back-button {
  position: fixed;
  top: 15px;
  left: 15px;
  width: 45px;
  height: 45px;
  cursor: pointer;
  z-index: 1001;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  padding: 10px;
  backdrop-filter: blur(5px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.back-button img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Chat App Styles */
#chat-app {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--primary-bg);
  color: var(--text-primary);
  transition: background-color 0.3s, color 0.3s;
  z-index: 1000;
  flex-direction: column;
}

#chat {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--secondary-bg);
  overflow: hidden;
}

.chat__header {
  background: var(--header-bg);
  padding: 15px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
  position: relative;
  min-height: 60px;
}

.header__left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}

.chat-back-button {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 18px;
  cursor: pointer;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}

.chat-back-button:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--accent-color);
}

.chat__avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-color), #a855f7);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: bold;
  font-size: 16px;
  flex-shrink: 0;
}

.chat__title {
  flex: 1;
  min-width: 0;
}

.chat__title h2 {
  color: var(--text-primary);
  font-weight: 700;
  margin-bottom: 2px;
  font-size: 16px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat__title p {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.channel-badge {
  background: var(--accent-color);
  color: white;
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 10px;
  margin-left: 5px;
}

.online-indicator {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
}

.online-dot {
  width: 8px;
  height: 8px;
  background-color: var(--online-color);
  border-radius: 50%;
  animation: pulse 2s infinite;
  flex-shrink: 0;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.chat__actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.action-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 18px;
  cursor: pointer;
  transition: color 0.2s;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.action-btn:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--accent-color);
}

.chat__container {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.chat__sidebar {
  width: 250px;
  border-right: 1px solid var(--border-color);
  padding: 15px;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  background: var(--header-bg);
}

.sidebar__section {
  margin-bottom: 20px;
}

.sidebar__title {
  font-size: 11px;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 10px;
  letter-spacing: 1px;
}

.user-list {
  list-style: none;
}

.user-item {
  display: flex;
  align-items: center;
  padding: 10px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.2s;
  margin-bottom: 8px;
  position: relative;
}

.user-item:hover, .user-item.active {
  background: rgba(255, 255, 255, 0.05);
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #7c3aed, #a855f7);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: bold;
  margin-right: 12px;
  font-size: 14px;
  flex-shrink: 0;
}

.user-info {
  flex: 1;
  min-width: 0;
}

.user-info h4 {
  font-size: 14px;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-info p {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.admin-badge {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: var(--danger-color);
  color: white;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 10px;
  display: none;
}

.user-item.admin .admin-badge {
  display: block;
}

.admin-delete-btn {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: var(--danger-color);
  color: white;
  border: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  font-size: 10px;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
}

.admin-visible .admin-delete-btn {
  display: flex;
}

.chat__main {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  min-width: 0;
}

.chat__messages {
  flex: 1;
  padding: 10px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  -webkit-overflow-scrolling: touch;
}

.date-separator {
  text-align: center;
  margin: 15px 0;
  position: relative;
}

.date-separator span {
  background: var(--date-separator);
  color: var(--text-primary);
  padding: 6px 15px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
}

.message {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 18px;
  position: relative;
  word-wrap: break-word;
  animation: fadeIn 0.3s ease;
  overflow: visible;
}

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

.message.received {
  background: var(--message-bg);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}

.message.sent {
  background: var(--own-message-bg);
  color: white;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

.message__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.message__sender {
  font-weight: bold;
  font-size: 13px;
}

.message__time {
  font-size: 11px;
  opacity: 0.8;
  margin-left: 10px;
}

.message__content {
  line-height: 1.4;
  font-size: 15px;
  white-space: pre-wrap;
  word-break: break-word;
}

.message__content a {
  color: inherit;
  text-decoration: underline;
  word-break: break-all;
}

.sent .message__content a {
  color: #a3d4ff;
}

/* Voice Message Styles */
.voice-message {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 15px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 25px;
  margin-top: 5px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  max-width: 250px;
}

.sent .voice-message {
  background: rgba(255, 255, 255, 0.2);
}

.voice-play-btn {
  background: var(--accent-color);
  color: white;
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.2s;
}

.voice-play-btn:hover {
  background: var(--accent-hover);
}

.voice-waveform {
  flex: 1;
  height: 36px;
  position: relative;
  overflow: hidden;
}

.waveform-bar {
  position: absolute;
  bottom: 0;
  width: 3px;
  background: white;
  border-radius: 2px;
}

.voice-duration {
  font-size: 12px;
  color: var(--text-secondary);
  margin-left: 5px;
  flex-shrink: 0;
  min-width: 40px;
  text-align: center;
}

/* Link Preview Styles */
.link-preview {
  margin-top: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  overflow: hidden;
  max-width: 300px;
  background: rgba(0, 0, 0, 0.1);
  cursor: pointer;
  transition: transform 0.2s;
}

.link-preview:hover {
  transform: translateY(-2px);
}

.sent .link-preview {
  border-color: rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.05);
}

.link-preview-image {
  width: 100%;
  height: 150px;
  object-fit: cover;
  display: block;
}

.link-preview-content {
  padding: 10px 12px;
}

.link-preview-title {
  font-weight: bold;
  font-size: 14px;
  margin-bottom: 5px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.link-preview-description {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 5px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.link-preview-domain {
  font-size: 11px;
  color: var(--accent-color);
  display: flex;
  align-items: center;
  gap: 5px;
}

/* File Message Styles - UPDATED */
.file-message {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 10px;
  margin-top: 5px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  max-width: 280px;
  cursor: pointer;
  transition: transform 0.2s;
}

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

.sent .file-message {
  background: rgba(255, 255, 255, 0.1);
}

.file-icon {
  width: 40px;
  height: 40px;
  background: var(--accent-color);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 18px;
  flex-shrink: 0;
}

.file-info {
  flex: 1;
  min-width: 0;
}

.file-name {
  font-weight: bold;
  font-size: 13px;
  margin-bottom: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-size {
  font-size: 11px;
  color: var(--text-secondary);
}

.download-btn {
  background: var(--accent-color);
  color: white;
  border: none;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.2s;
  text-decoration: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

.download-btn:hover {
  background: var(--accent-hover);
}

/* Media Messages */
.media-message {
  margin-top: 8px;
  border-radius: 10px;
  overflow: hidden;
  max-width: 250px;
  cursor: pointer;
  transition: transform 0.2s;
  position: relative;
}

.media-message:hover {
  transform: scale(1.02);
}

.media-message img,
.media-message video {
  width: 100%;
  max-height: 250px;
  object-fit: cover;
  border-radius: 8px;
  display: block;
}

.media-play-btn {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.7);
  color: white;
  border: none;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  cursor: pointer;
}

.media-duration {
  position: absolute;
  bottom: 10px;
  right: 10px;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  padding: 3px 8px;
  border-radius: 10px;
  font-size: 11px;
}

.message__actions {
  position: absolute;
  top: 6px;
  right: 8px;
  display: none;
  gap: 4px;
  background: rgba(0, 0, 0, 0.6);
  border-radius: 20px;
  padding: 4px;
  backdrop-filter: blur(10px);
  z-index: 100;
  pointer-events: auto;
}

.message:hover .message__actions {
  display: flex;
}

.message-action {
  background: transparent;
  border: none;
  color: white;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s;
  font-size: 13px;
  pointer-events: auto;
  z-index: 101;
}

.message-action:active {
  background: rgba(255, 255, 255, 0.2);
}

.copy-notification {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--secondary-bg);
  color: var(--text-primary);
  padding: 12px 20px;
  border-radius: 10px;
  box-shadow: 0 5px 20px rgba(0, 0, 0, 0.3);
  z-index: 2000;
  display: none;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  animation: popIn 0.3s ease;
}

@keyframes popIn {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.8); }
  100% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

.copy-notification i {
  color: var(--success-color);
}

.reply-indicator {
  background: var(--reply-bg);
  padding: 8px 12px;
  border-radius: 10px;
  margin-bottom: 8px;
  border-left: 3px solid var(--accent-color);
  font-size: 13px;
  cursor: pointer;
}

.reply-sender {
  font-weight: bold;
  color: var(--accent-color);
  font-size: 12px;
}

.reply-text {
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 200px;
  font-size: 12px;
}

.typing-indicator {
  padding: 8px 15px;
  font-size: 13px;
  color: var(--typing-color);
  display: flex;
  align-items: center;
  gap: 5px;
}

.typing-dots {
  display: flex;
  gap: 3px;
}

.typing-dots span {
  width: 6px;
  height: 6px;
  background-color: var(--typing-color);
  border-radius: 50%;
  animation: typing 1.4s infinite ease-in-out;
}

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

@keyframes typing {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}

/* Voice Recording Styles */
.voice-recording {
  position: absolute;
  bottom: 70px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--secondary-bg);
  border: 2px solid var(--recording-bg);
  border-radius: 20px;
  padding: 15px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  z-index: 100;
  box-shadow: 0 5px 20px rgba(0, 0, 0, 0.3);
  animation: slideUp 0.3s ease;
  min-width: 280px;
}

.recording-indicator {
  width: 12px;
  height: 12px;
  background: var(--recording-bg);
  border-radius: 50%;
  animation: recordingPulse 1.5s infinite;
}

@keyframes recordingPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(1.2); }
}

.recording-time {
  font-weight: bold;
  font-size: 16px;
  color: var(--danger-color);
}

.cancel-recording {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 18px;
  cursor: pointer;
  padding: 8px;
  order: 1;
}

.cancel-recording:hover {
  color: var(--danger-color);
}

.send-recording {
  background: var(--accent-color);
  border: none;
  color: white;
  font-size: 16px;
  cursor: pointer;
  padding: 8px 16px;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  order: 2;
  margin-left: auto;
}

.send-recording:hover {
  background: var(--accent-hover);
}

.chat__input-area {
  padding: 12px;
  border-top: 1px solid var(--border-color);
  display: flex;
  gap: 8px;
  align-items: flex-end;
  background: var(--header-bg);
}

.input-wrapper {
  flex: 1;
  display: flex;
  background: var(--message-bg);
  border-radius: 25px;
  padding: 8px 15px;
  align-items: center;
  min-height: 44px;
}

#chatInput {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-size: 16px;
  padding: 0;
  outline: none;
  font-family: 'Lato', sans-serif;
  resize: none;
  min-height: 28px;
  max-height: 120px;
  overflow-y: auto;
  line-height: 1.4;
}

#chatInput::placeholder {
  color: var(--text-secondary);
}

.input-tool {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 20px;
  cursor: pointer;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}

.input-tool:hover {
  color: var(--accent-color);
  background: rgba(255, 255, 255, 0.05);
}

.input-tool.recording {
  color: var(--recording-bg);
  background: rgba(239, 68, 68, 0.1);
  animation: pulse 1.5s infinite;
}

#sendBtn {
  background: var(--accent-color);
  border: none;
  color: white;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  font-size: 18px;
  flex-shrink: 0;
}

#sendBtn:hover {
  background: var(--accent-hover);
}

#sendBtn:active {
  transform: scale(0.95);
}

.emoji-picker {
  position: absolute;
  bottom: 70px;
  right: 12px;
  background: var(--secondary-bg);
  border: 1px solid var(--border-color);
  border-radius: 15px;
  padding: 12px;
  width: 280px;
  box-shadow: 0 5px 20px rgba(0, 0, 0, 0.2);
  z-index: 100;
  display: none;
}

.emoji-picker.show {
  display: block;
  animation: slideUp 0.2s ease;
}

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

.emoji-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-color);
}

.emoji-categories {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
  overflow-x: auto;
  padding-bottom: 5px;
}

.emoji-category {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 18px;
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  transition: all 0.2s;
  flex-shrink: 0;
}

.emoji-category:hover, .emoji-category.active {
  color: var(--accent-color);
  background: rgba(124, 58, 237, 0.1);
}

.emoji-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 6px;
  max-height: 180px;
  overflow-y: auto;
  padding: 4px;
}

.emoji-grid::-webkit-scrollbar {
  width: 6px;
}

.emoji-grid::-webkit-scrollbar-track {
  background: transparent;
}

.emoji-grid::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 3px;
}

.emoji-item {
  font-size: 22px;
  text-align: center;
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  transition: background 0.2s;
  aspect-ratio: 1/1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.emoji-item:hover {
  background: rgba(255, 255, 255, 0.05);
}

.theme-switch {
  position: relative;
  display: inline-block;
  width: 56px;
  height: 30px;
  flex-shrink: 0;
}

.theme-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.theme-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #4b5563;
  transition: .4s;
  border-radius: 30px;
}

.theme-slider:before {
  position: absolute;
  content: "";
  height: 22px;
  width: 22px;
  left: 4px;
  bottom: 4px;
  background-color: white;
  transition: .4s;
  border-radius: 50%;
}

input:checked + .theme-slider {
  background-color: var(--accent-color);
}

input:checked + .theme-slider:before {
  transform: translateX(26px);
}

.theme-icons {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px;
  pointer-events: none;
}

.theme-icons i {
  font-size: 12px;
  color: white;
}

.notification {
  position: absolute;
  top: 80px;
  right: 20px;
  background: var(--secondary-bg);
  border-left: 4px solid var(--accent-color);
  padding: 12px 16px;
  border-radius: 10px;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 1000;
  animation: slideIn 0.3s ease;
  max-width: 250px;
}

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.notification-icon {
  color: var(--accent-color);
  font-size: 18px;
}

.notification-content p {
  font-size: 14px;
}

/* Search GUI - FIXED TEXT VISIBILITY */
.search-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--modal-bg);
  z-index: 2000;
  display: none;
  animation: fadeIn 0.3s ease;
}

.search-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  background: var(--header-bg);
  z-index: 2001;
  padding: 15px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
  transform: translateY(-100%);
  transition: transform 0.3s ease;
}

.search-container.show {
  transform: translateY(0);
}

.search-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 15px;
}

.search-back {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 20px;
  cursor: pointer;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.search-back:hover {
  background: rgba(255, 255, 255, 0.05);
}

.search-input-wrapper {
  flex: 1;
  display: flex;
  align-items: center;
  background: var(--search-input-bg);
  border-radius: 20px;
  padding: 0 15px;
  height: 40px;
  border: 1px solid var(--border-color);
}

/* Ensure search inputs are readable in both themes */
.search-input {
  background: var(--search-input-bg) !important;
  color: var(--text-primary) !important;
  caret-color: var(--accent-color) !important;
  border: 1px solid var(--border-color) !important;
  outline: none !important;
  font-size: 14px !important;
  padding: 8px !important;
  font-weight: normal !important;
  letter-spacing: normal !important;
}

input[type="search"],
.chat-search input,
#chat input[type="search"] {
  background: var(--search-input-bg);
  color: var(--text-primary);
  caret-color: var(--accent-color);
  border: 1px solid var(--border-color);
  outline: none;
  font-size: 14px;
  padding: 8px;
}

/* Placeholder visibility */
.search-input::placeholder {
  color: var(--text-secondary) !important;
  opacity: 1 !important;
}

input[type="search"]::placeholder,
.chat-search input::placeholder {
  color: var(--text-secondary);
  opacity: 1;
}

.search-clear {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.search-results {
  max-height: 60vh;
  overflow-y: auto;
  padding: 10px 0;
  background: var(--secondary-bg);
}

.search-result-item {
  padding: 12px 15px;
  border-bottom: 1px solid var(--border-color);
  cursor: pointer;
  transition: background 0.2s;
  background: var(--secondary-bg);
}

.search-result-item:hover {
  background: var(--message-bg);
}

.search-result-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 5px;
  font-size: 12px;
  color: var(--text-secondary);
}

.search-result-text {
  font-size: 14px;
  line-height: 1.4;
  color: var(--text-primary);
}

.search-highlight {
  background: rgba(124, 58, 237, 0.3);
  padding: 2px 4px;
  border-radius: 4px;
  color: var(--text-primary);
}

/* Media Viewer Modal - UPDATED WITH BACK BUTTON */
.media-viewer {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--modal-bg);
  z-index: 3000;
  display: none;
  justify-content: center;
  align-items: center;
  animation: fadeIn 0.3s ease;
  flex-direction: column;
}

.media-viewer-header {
  width: 100%;
  padding: 15px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(0, 0, 0, 0.8);
  position: absolute;
  top: 0;
  left: 0;
  z-index: 3001;
}

.media-viewer-back-btn {
  background: rgba(255, 255, 255, 0.2);
  color: white;
  border: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.media-viewer-back-btn:hover {
  background: rgba(255, 255, 255, 0.3);
}

.media-viewer-title {
  color: white;
  font-size: 16px;
  font-weight: bold;
  flex: 1;
  text-align: center;
  padding: 0 20px;
}

.media-viewer-actions {
  display: flex;
  gap: 10px;
}

.media-viewer-action-btn {
  background: rgba(255, 255, 255, 0.2);
  color: white;
  border: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.media-viewer-action-btn:hover {
  background: rgba(255, 255, 255, 0.3);
}

.media-viewer-content {
  max-width: 90%;
  max-height: 80%;
  position: relative;
  margin-top: 70px;
  margin-bottom: 20px;
}

.media-viewer-content img,
.media-viewer-content video {
  max-width: 100%;
  max-height: 70vh;
  object-fit: contain;
  border-radius: 10px;
}

/* Image Editor Modal */
.image-editor-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--modal-bg);
  z-index: 4000;
  display: none;
  flex-direction: column;
  animation: fadeIn 0.3s ease;
}

.editor-header {
  padding: 15px;
  background: var(--header-bg);
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
}

.editor-canvas-container {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
  overflow: auto;
}

#editorCanvas {
  max-width: 100%;
  max-height: 100%;
  box-shadow: 0 5px 20px rgba(0, 0, 0, 0.3);
  border-radius: 10px;
  background: white;
}

.editor-tools {
  padding: 15px;
  background: var(--header-bg);
  border-top: 1px solid var(--border-color);
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
}

.editor-tool-btn {
  background: var(--message-bg);
  border: none;
  color: var(--text-primary);
  padding: 10px 15px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s;
}

.editor-tool-btn:hover {
  background: var(--accent-color);
  color: white;
}

.editor-tool-btn.active {
  background: var(--accent-color);
  color: white;
}

.color-picker {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  padding: 0;
  border: 2px solid var(--border-color);
}

.brush-size {
  width: 100px;
  cursor: pointer;
}

.brush-size-label {
  font-size: 12px;
  color: var(--text-secondary);
  margin-right: 10px;
}

/* Video Editor Modal */
.video-editor-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--modal-bg);
  z-index: 4000;
  display: none;
  flex-direction: column;
  animation: fadeIn 0.3s ease;
}

.video-editor-player {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
}

.video-trim-controls {
  padding: 15px;
  background: var(--header-bg);
  border-top: 1px solid var(--border-color);
}

.trim-range {
  width: 100%;
  margin: 10px 0;
}

.trim-times {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 5px;
}

/* WhatsApp Style Menu */
.menu-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--modal-bg);
  z-index: 2000;
  display: none;
  animation: fadeIn 0.3s ease;
}

.menu-container {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  background: var(--menu-bg);
  border-radius: 20px 20px 0 0;
  z-index: 2001;
  transform: translateY(100%);
  transition: transform 0.3s ease;
  max-height: 80vh;
  overflow-y: auto;
}

.menu-container.show {
  transform: translateY(0);
}

.menu-header {
  padding: 20px 15px 10px;
  text-align: center;
  font-weight: bold;
  font-size: 18px;
  border-bottom: 1px solid var(--border-color);
  position: relative;
}

.menu-close {
  position: absolute;
  right: 15px;
  top: 20px;
  background: none;
  border: none;
  font-size: 20px;
  color: var(--text-secondary);
  cursor: pointer;
}

.menu-item {
  padding: 15px 20px;
  display: flex;
  align-items: center;
  gap: 15px;
  cursor: pointer;
  transition: background 0.2s;
  border-bottom: 1px solid var(--border-color);
}

.menu-item:last-child {
  border-bottom: none;
}

.menu-item:hover {
  background: rgba(255, 255, 255, 0.05);
}

.menu-item i {
  width: 24px;
  text-align: center;
  font-size: 18px;
  color: var(--accent-color);
}

.menu-item.danger i {
  color: var(--danger-color);
}

.menu-item.danger {
  color: var(--danger-color);
}

/* Export Options Menu */
.export-options {
  display: flex;
  flex-direction: column;
  padding: 10px 0;
}

.export-option {
  padding: 15px 20px;
  display: flex;
  align-items: center;
  gap: 15px;
  cursor: pointer;
  transition: background 0.2s;
}

.export-option:hover {
  background: rgba(255, 255, 255, 0.05);
}

/* Modal Styles */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--modal-bg);
  z-index: 3000;
  display: none;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.3s ease;
}

.modal {
  background: var(--secondary-bg);
  border-radius: 15px;
  padding: 25px;
  width: 90%;
  max-width: 400px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
  animation: popIn 0.3s ease;
}

.modal-header {
  font-size: 20px;
  font-weight: bold;
  margin-bottom: 15px;
  text-align: center;
}

.modal-body {
  margin-bottom: 20px;
}

.modal-input {
  width: 100%;
  padding: 12px 15px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: var(--message-bg);
  color: var(--text-primary);
  font-size: 16px;
  margin-bottom: 15px;
}

.modal-buttons {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.modal-btn {
  padding: 10px 20px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-weight: bold;
  transition: all 0.2s;
}

.modal-btn.primary {
  background: var(--accent-color);
  color: white;
}

.modal-btn.secondary {
  background: var(--message-bg);
  color: var(--text-primary);
}

.modal-btn:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

/* Upload Progress */
.upload-progress {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--secondary-bg);
  padding: 20px;
  border-radius: 15px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
  z-index: 3000;
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 15px;
  min-width: 250px;
}

.progress-bar {
  width: 100%;
  height: 6px;
  background: var(--message-bg);
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--accent-color);
  width: 0%;
  transition: width 0.3s ease;
}

.progress-text {
  font-size: 14px;
  color: var(--text-secondary);
}

/* Channel List Styles (Admin only) */
.channel-list {
  list-style: none;
  margin-top: 10px;
  display: none;
}

.channel-item {
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.channel-item:hover {
  background: rgba(255, 255, 255, 0.05);
}

.channel-item.active {
  background: var(--accent-color);
  color: white;
}

.channel-user-count {
  font-size: 11px;
  background: rgba(255, 255, 255, 0.1);
  padding: 2px 6px;
  border-radius: 10px;
}

/* Admin Channel Controls (Hidden by default) */
.admin-channel-controls {
  margin-top: 15px;
  padding-top: 15px;
  border-top: 1px solid var(--border-color);
  display: none;
}

.join-channel-btn {
  width: 100%;
  padding: 8px;
  background: var(--accent-color);
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  margin-top: 10px;
}

.join-channel-btn:hover {
  background: var(--accent-hover);
}

/* Link Preview Input */
.link-preview-input {
  position: absolute;
  bottom: 80px;
  left: 12px;
  right: 12px;
  background: var(--secondary-bg);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 10px;
  margin-top: 5px;
  display: none;
  animation: slideUp 0.2s ease;
  z-index: 99;
}

.link-preview-input.show {
  display: block;
}

.link-preview-input-content {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.link-preview-input-image {
  width: 100%;
  height: 120px;
  object-fit: cover;
  border-radius: 8px;
}

.link-preview-input-title {
  font-weight: bold;
  font-size: 14px;
  color: var(--text-primary);
}

.link-preview-input-description {
  font-size: 12px;
  color: var(--text-secondary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.link-preview-input-domain {
  font-size: 11px;
  color: var(--accent-color);
  display: flex;
  align-items: center;
  gap: 5px;
}

.remove-preview-btn {
  position: absolute;
  top: 5px;
  right: 5px;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  border: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Mobile Responsive Styles */
@media (max-width: 1024px) {
  .chat__sidebar {
    width: 220px;
  }
}

@media (max-width: 768px) {
  .chat__sidebar {
    display: none;
  }
  
  .message {
    max-width: 85%;
    padding: 12px 15px;
  }
  
  .emoji-picker {
    width: calc(100% - 24px);
    right: 12px;
    bottom: 75px;
  }
  
  .emoji-grid {
    grid-template-columns: repeat(7, 1fr);
  }
  
  .chat__header {
    padding: 12px 15px;
  }
  
  .chat__actions {
    gap: 5px;
  }
  
  .action-btn {
    width: 36px;
    height: 36px;
  }
  
  .theme-switch {
    width: 50px;
    height: 26px;
  }
  
  .theme-slider:before {
    height: 18px;
    width: 18px;
  }
  
  input:checked + .theme-slider:before {
    transform: translateX(24px);
  }
  
  .link-preview {
    max-width: 250px;
  }
  
  .media-message {
    max-width: 200px;
  }
  
  .editor-tools {
    overflow-x: auto;
    justify-content: flex-start;
  }
  
  .editor-tool-btn {
    flex-shrink: 0;
  }
  
  .media-viewer-content {
    max-height: 60%;
    margin-top: 60px;
  }
  
  .media-viewer-header {
    padding: 10px 15px;
  }
}

@media (max-width: 480px) {
  .login-container {
    padding: 25px 20px;
    width: 95%;
  }
  
  .login-container h2 {
    font-size: 22px;
  }
  
  .back-button {
    width: 40px;
    height: 40px;
    top: 12px;
    left: 12px;
  }
  
  .chat__messages {
    padding: 8px;
    gap: 8px;
  }
  
  .message {
    max-width: 90%;
    padding: 10px 12px;
    border-radius: 15px;
  }
  
  .message__content {
    font-size: 14px;
  }
  
  .message__sender {
    font-size: 12px;
  }
  
  .message__time {
    font-size: 10px;
  }
  
  .message__actions {
    top: 4px;
    right: 6px;
    padding: 3px;
    gap: 3px;
  }
  
  .message-action {
    width: 26px;
    height: 26px;
    font-size: 12px;
  }
  
  .chat__input-area {
    padding: 10px;
  }
  
  .input-wrapper {
    padding: 6px 12px;
    min-height: 40px;
    border-radius: 20px;
  }
  
  #chatInput {
    font-size: 15px;
    min-height: 24px;
  }
  
  .input-tool {
    width: 36px;
    height: 36px;
    font-size: 18px;
  }
  
  #sendBtn {
    width: 42px;
    height: 42px;
    font-size: 16px;
  }
  
  .emoji-picker {
    width: calc(100% - 20px);
    right: 10px;
  }
  
  .emoji-grid {
    grid-template-columns: repeat(6, 1fr);
  }
  
  .emoji-item {
    font-size: 20px;
    padding: 4px;
  }
  
  .notification {
    top: 70px;
    right: 10px;
    left: 10px;
    max-width: none;
    font-size: 13px;
  }
  
  .copy-notification {
    width: 90%;
    text-align: center;
    font-size: 13px;
  }
  
  .link-preview {
    max-width: 220px;
  }
  
  .link-preview-image {
    height: 120px;
  }
  
  .media-message {
    max-width: 180px;
  }
  
  .modal {
    width: 95%;
    padding: 20px;
  }
  
  .voice-recording {
    min-width: 180px;
    padding: 12px 15px;
  }
  
  .media-viewer-content {
    max-height: 50%;
  }
}

@media (max-width: 360px) {
  .chat__title h2 {
    font-size: 15px;
  }
  
  .chat__title p {
    font-size: 11px;
  }
  
  .emoji-grid {
    grid-template-columns: repeat(5, 1fr);
  }
  
  .message {
    max-width: 95%;
  }
  
  .link-preview {
    max-width: 200px;
  }
  
  .voice-recording {
    min-width: 160px;
  }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
  .message__actions {
    display: flex !important;
    opacity: 0.7;
  }
  
  .action-btn:active,
  .input-tool:active,
  .message-action:active {
    background: rgba(255, 255, 255, 0.1);
    transform: scale(0.95);
  }
  
  .user-item:active {
    background: rgba(255, 255, 255, 0.05);
  }
}

/* Sidebar toggle for mobile - FIXED POSITION TO AVOID OVERLAPPING */
.sidebar-toggle {
  display: none;
  position: fixed;
  bottom: 90px;
  right: 20px;
  width: 50px;
  height: 50px;
  background: var(--accent-color);
  color: white;
  border-radius: 50%;
  border: none;
  font-size: 20px;
  cursor: pointer;
  z-index: 100;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* Additional padding for mobile to accommodate sidebar toggle button */
@media (max-width: 768px) {
  .chat__messages {
    padding-bottom: 70px;
  }
  
  .sidebar-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
  }
  
  .chat__sidebar.mobile-open {
    display: flex;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 99;
    background: var(--primary-bg);
  }
}

/* Extra small devices adjustment */
@media (max-width: 360px) {
  .sidebar-toggle {
    bottom: 85px;
    right: 15px;
    width: 45px;
    height: 45px;
    font-size: 18px;
  }
  
  .chat__messages {
    padding-bottom: 65px;
  }
}
