* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary: #00a884;
  --primary-dark: #008f6f;
  --secondary: #00b894;
  --danger: #ff7675;
  --bg-dark: #0b141a;
  --bg-medium: #111b21;
  --bg-light: #202c33;
  --text-primary: #e9edef;
  --text-secondary: #8696a0;
  --border: #2a3942;
  --message-out: #005c4b;
  --message-in: #202c33;
}

/* Light Theme */
body[data-theme="light"] {
  --primary: #00a884;
  --primary-dark: #008f6f;
  --secondary: #00b894;
  --danger: #ff7675;
  --bg-dark: #f0f2f5;
  --bg-medium: #ffffff;
  --bg-light: #f0f2f5;
  --text-primary: #111b21;
  --text-secondary: #667781;
  --border: #e9edef;
  --message-out: #d9fdd3;
  --message-in: #ffffff;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background: var(--bg-dark);
  color: var(--text-primary);
  overflow: hidden;
  position: fixed;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  font-weight: 400;
  font-size: 14.2px;
  line-height: 1.4;
}

#app {
  height: 100vh;
  height: 100dvh; /* Dynamic viewport height */
  width: 100vw;
  position: relative;
  background: var(--bg-dark);
  color: var(--text-primary);
}

/* Screens */
.screen {
  display: none;
  width: 100%;
  height: 100%;
}

.screen.active {
  display: flex;
}

/* Login Screen */
#login-screen {
  justify-content: center;
  align-items: center;
  background: linear-gradient(135deg, var(--bg-dark) 0%, var(--bg-medium) 100%);
}

.login-container {
  text-align: center;
  padding: 3rem;
  background: var(--bg-medium);
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  max-width: 400px;
  width: 90%;
}

.logo {
  font-size: 4rem;
  margin-bottom: 1rem;
}

.login-container h1 {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
  color: var(--primary);
}

.tagline {
  color: var(--text-secondary);
  margin-bottom: 2rem;
  font-size: 0.9rem;
}

.disclaimer {
  margin-top: 1.5rem;
  color: var(--text-secondary);
  font-size: 0.8rem;
}

/* Chat Screen */
#chat-screen {
  flex-direction: row;
}

.sidebar {
  width: 320px;
  background: var(--bg-medium);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

.sidebar-header {
  padding: 1.5rem;
  border-bottom: 1px solid var(--border);
}

.sidebar-header h2 {
  color: var(--primary);
  margin-bottom: 0.5rem;
}

.user-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

/* Pairing Code Display */
.pairing-info {
  position: relative;
  margin-top: 1rem;
  padding: 1rem;
  background: var(--bg-dark);
  border-radius: 8px;
  border: 1px solid var(--border);
}

.pairing-close {
  position: absolute;
  top: 8px;
  right: 8px;
  background: transparent !important;
  border: none;
  color: var(--text-secondary);
  font-size: 22px;
  cursor: pointer;
  padding: 4px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.2s;
  line-height: 1;
}

.pairing-close:hover {
  background: var(--bg-medium) !important;
  color: var(--text-primary);
}

.pairing-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

.pairing-code-box {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

#pairing-code-display {
  font-size: 1.5rem;
  font-weight: bold;
  letter-spacing: 0.3em;
  color: var(--primary);
  font-family: 'Courier New', monospace;
  flex: 1;
}

.pairing-expiry {
  font-size: 0.75rem;
  color: var(--danger);
}

.add-by-code-section {
  margin-bottom: 1.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}

.add-by-code-section h4 {
  margin-bottom: 0.5rem;
  color: var(--primary);
}

.add-by-code-section input {
  width: 100%;
  margin-bottom: 0.75rem;
}

#pairing-code-input {
  text-align: center;
  font-size: 1.2rem;
  letter-spacing: 0.3em;
  font-family: 'Courier New', monospace;
}

.contacts-section {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.section-header h3 {
  font-size: 0.9rem;
  text-transform: uppercase;
  color: var(--text-secondary);
  letter-spacing: 1px;
}

.section-actions {
  display: flex;
  gap: 4px;
}

/* Search Bar */
.search-bar {
  display: none;
  margin-bottom: 12px;
  padding: 0 1rem;
  animation: slideDown 0.2s ease-out;
}

.search-bar.active {
  display: flex;
  gap: 8px;
  align-items: center;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

#search-contacts-input {
  flex: 1;
  background: var(--bg-light);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 14.2px;
  transition: all 0.2s;
}

#search-contacts-input:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--bg-medium);
}

.close-search {
  flex-shrink: 0;
  font-size: 20px;
  padding: 8px;
}

.contacts-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.contact-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--bg-light);
  border-radius: 0;
  cursor: pointer;
  transition: background 0.2s;
  border: none;
  border-bottom: 1px solid var(--border);
}

.contact-item:hover {
  background: var(--bg-medium);
}

.contact-item.active {
  background: var(--bg-medium);
}

.contact-avatar {
  width: 49px;
  height: 49px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 500;
  flex-shrink: 0;
}

.contact-info {
  flex: 1;
  min-width: 0;
}

.contact-name {
  font-size: 16px;
  font-weight: 400;
  color: var(--text-primary);
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.contact-status {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 400;
}

.contact-status.online {
  color: var(--primary);
}

.contact-actions {
  display: flex;
  gap: 8px;
  opacity: 0;
  transition: opacity 0.2s;
}

.contact-item:hover .contact-actions {
  opacity: 1;
}

.contact-item.active .status {
  color: rgba(255, 255, 255, 0.8);
}

.contact-item .status.connected {
  color: var(--secondary);
}

/* Chat Area */
.chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-dark);
}

.chat-header {
  display: flex;
  align-items: center;
  padding: 0.75rem 1rem;
  background: var(--bg-medium);
  border-bottom: 1px solid var(--border);
  min-height: 60px;
}

.header-actions {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

.header-call-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 20px;
  cursor: pointer;
  padding: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.2s;
  width: 40px;
  height: 40px;
}

.header-call-btn:hover {
  background: var(--bg-light);
  color: var(--primary);
  transform: scale(1.05);
}

.header-call-btn:active {
  transform: scale(0.95);
}

.chat-info .contact-name {
  font-size: 1.05rem;
  font-weight: 400;
}

.connection-status {
  display: block;
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 2px;
  font-weight: 400;
}

.connection-status.connected {
  color: var(--primary);
}

/* Chat Tabs */
.chat-tabs {
  display: flex;
  background: var(--bg-dark);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  gap: 0;
  padding: 0 0.5rem;
}

.chat-tab {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background: var(--bg-medium);
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: 8px 8px 0 0;
  margin-top: 0.5rem;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
  position: relative;
  max-width: 200px;
}

.chat-tab:hover {
  background: var(--bg-light);
}

.chat-tab.active {
  background: var(--bg-medium);
  border-bottom: 2px solid var(--primary);
  margin-top: 0;
  padding-bottom: calc(0.75rem + 1px);
}

.chat-tab-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 0.9rem;
}

.chat-tab-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-secondary);
  flex-shrink: 0;
}

.chat-tab-indicator.unread {
  background: white;
  box-shadow: 0 0 4px white;
  animation: pulse 2s infinite;
}

.chat-tab-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  flex-shrink: 0;
}

.chat-tab-close:hover {
  background: var(--danger);
  color: white;
}

/* Tab Call Buttons */
.tab-call-buttons {
  display: flex;
  gap: 4px;
  margin-left: 8px;
  flex-shrink: 0;
}

.tab-call-btn {
  background: var(--bg-light);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-size: 0.9rem;
  cursor: pointer;
  padding: 4px 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: all 0.2s;
  width: 28px;
  height: 28px;
}

.tab-call-btn:hover {
  background: var(--primary);
  transform: scale(1.1);
  border-color: var(--primary);
}

.tab-call-btn:active {
  transform: scale(0.95);
}

.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.welcome-message {
  text-align: center;
  margin: auto;
  max-width: 500px;
}

.logo-large {
  font-size: 5rem;
  margin-bottom: 1rem;
}

.welcome-message h2 {
  margin-bottom: 0.5rem;
}

.welcome-message p {
  color: var(--text-secondary);
  margin-bottom: 2rem;
}

.features {
  list-style: none;
  text-align: left;
  display: inline-block;
  color: var(--text-secondary);
}

.features li {
  padding: 0.5rem 0;
}

.message {
  max-width: 65%;
  padding: 6px 10px 8px 10px;
  border-radius: 7.5px;
  word-wrap: break-word;
  font-size: 14.2px;
  line-height: 19px;
  position: relative;
}

.message.sent {
  align-self: flex-end;
  background: var(--message-out);
  margin-left: auto;
  color: #e9edef;
}

/* Light mode text color override */
body[data-theme="light"] .message.sent {
  color: #111b21;
}

body[data-theme="light"] .message.received {
  color: #111b21;
  border: 1px solid var(--border);
}

body[data-theme="light"] .message .timestamp {
  color: rgba(17, 27, 33, 0.5);
}

.message.received {
  align-self: flex-start;
  background: var(--message-in);
  color: #e9edef;
}

.message .timestamp {
  font-size: 11px;
  color: rgba(233, 237, 239, 0.6);
  margin-top: 2px;
  margin-left: 4px;
  display: inline-block;
  float: right;
}

.message .delivery-status {
  font-size: 11px;
  color: rgba(233, 237, 239, 0.6);
  margin-right: 4px;
  display: inline-block;
  float: right;
}

.message .delivery-status.read {
  color: #53bdeb; /* Blue checkmarks for read */
}

body[data-theme="light"] .message .delivery-status {
  color: rgba(17, 27, 33, 0.5);
}

body[data-theme="light"] .message .delivery-status.read {
  color: #0088cc; /* Darker blue for light mode */
}

.message.file {
  cursor: pointer;
}

.message.file:hover {
  opacity: 0.8;
}

.message img {
  max-width: 280px;
  max-height: 280px;
  border-radius: 8px;
  margin-top: 4px;
  display: block;
  object-fit: cover;
}

.system-message {
  text-align: center;
  color: var(--text-secondary);
  font-size: 12.5px;
  padding: 8px 12px;
  margin: 8px auto;
  max-width: 80%;
  background: rgba(11, 20, 26, 0.6);
  border-radius: 7.5px;
  font-weight: 400;
}

.chat-input-area {
  padding: 1rem 1.5rem;
  background: var(--bg-medium);
  border-top: 1px solid var(--border);
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

/* Form Elements */
input[type="text"] {
  background: var(--bg-light);
  border: 2px solid var(--border);
  color: var(--text-primary);
  padding: 0.75rem 1rem;
  border-radius: 10px;
  font-size: 1rem;
  transition: all 0.2s;
  width: 100%;
}

input[type="text"]:focus {
  outline: none;
  border-color: var(--primary);
}

#message-input {
  flex: 1;
}

#username-input {
  margin-bottom: 1rem;
}

/* Buttons */
.btn-primary {
  background: var(--primary);
  color: white;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  background: var(--bg-light);
  color: white;
  border: 2px solid var(--border);
  padding: 0.75rem 1.5rem;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-secondary:hover {
  background: var(--bg-dark);
  border-color: var(--primary);
}

#login-btn {
  width: 100%;
}

.btn-icon {
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 8px;
  transition: all 0.2s;
}

.btn-icon:hover {
  background: var(--bg-light);
}

.menu-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 1.5rem;
  cursor: pointer;
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  transition: background 0.2s;
}

.menu-toggle:active {
  background: var(--bg-light);
}

.back-btn {
  display: none;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 1.5rem;
  cursor: pointer;
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  transition: background 0.2s;
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
}

.back-btn:active {
  background: var(--bg-light);
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.modal.active {
  display: flex;
}

.modal-content {
  background: var(--bg-medium);
  border-radius: 15px;
  max-width: 500px;
  width: 90%;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}

.modal-header {
  padding: 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  margin: 0;
}

.close-modal {
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 5px;
  transition: background 0.2s;
}

.close-modal:hover {
  background: var(--bg-light);
}

.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

.connection-request-text {
  font-size: 1.1rem;
  text-align: center;
  margin: 1rem 0;
}

.modal-description {
  color: var(--text-secondary);
  margin-bottom: 1rem;
}

.available-users-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.user-item {
  padding: 1rem;
  background: var(--bg-light);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.user-item:hover {
  background: var(--bg-dark);
  border-color: var(--primary);
}

.empty-state {
  text-align: center;
  color: var(--text-secondary);
  padding: 2rem;
}

/* Connecting Overlay */
.connecting-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(26, 26, 46, 0.95);
  z-index: 2000;
  justify-content: center;
  align-items: center;
}

.connecting-overlay.active {
  display: flex;
}

.connecting-content {
  text-align: center;
}

.spinner {
  width: 60px;
  height: 60px;
  border: 4px solid var(--border);
  border-top: 4px solid var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 1.5rem;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.connecting-message {
  color: var(--text-primary);
  font-size: 1.1rem;
  margin-top: 1rem;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-dark);
}

::-webkit-scrollbar-thumb {
  background: var(--bg-light);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--primary);
}

/* Responsive */
@media (max-width: 768px) {
  /* Show tabs on mobile with better spacing */
  .chat-tabs {
    display: flex !important;
    overflow-x: auto;
    padding: 8px;
    gap: 8px;
  }
  
  .chat-tab {
    min-width: 120px;
    max-width: 200px;
  }
  
  .tab-call-buttons {
    display: flex !important;
    gap: 4px;
  }
  
  .tab-call-btn {
    display: flex !important;
    font-size: 1rem;
  }
  
  .sidebar {
    width: 100%;
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 100;
    transform: translateX(-100%);
    transition: transform 0.3s;
  }

  .sidebar.show {
    transform: translateX(0);
  }

  .chat-area {
    width: 100%;
  }

  .chat-header {
    display: block !important; /* Show header on mobile */
    position: relative;
  }

  .menu-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: var(--bg-light);
    border: none;
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 1.5rem;
    cursor: pointer;
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
  }

  .back-btn {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .chat-info {
    text-align: center;
    width: 100%;
    padding: 0 60px;
  }

  .header-actions {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    margin-left: 0;
  }

  .message {
    max-width: 85%;
  }

  .chat-input-area {
    padding: 0.8rem 1rem;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: var(--bg-medium);
    border-top: 1px solid var(--border);
    /* Android Chrome keyboard fix */
    padding-bottom: max(0.8rem, env(safe-area-inset-bottom, 0px));
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.3);
  }

  .messages-container {
    height: calc(100vh - 130px);
    height: calc(100dvh - 130px); /* Dynamic viewport for Android */
    padding-bottom: 80px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .login-container {
    padding: 2rem;
    width: 95%;
  }

  .modal-content {
    width: 95%;
    max-height: 90vh;
  }

  /* Overlay for sidebar */
  .sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
  }

  .sidebar-overlay.active {
    display: block;
  }
}

/* File Menu */
.file-menu {
  position: absolute;
  bottom: 60px;
  left: 10px;
  background: var(--bg-light);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  z-index: 1000;
  min-width: 220px;
}

.file-menu-item {
  padding: 12px 16px;
  cursor: pointer;
  border-radius: 8px;
  transition: background 0.2s;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.file-menu-item:hover {
  background: var(--bg-medium);
}

.file-menu-item:active {
  background: var(--primary-dark);
}

@media (max-width: 768px) {
  .file-menu {
    left: 50%;
    transform: translateX(-50%);
    min-width: calc(100% - 2rem);
    max-width: calc(100% - 2rem);
  }
}

/* File Preview Popup */
.file-preview-popup {
  position: absolute;
  bottom: 60px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-light);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  z-index: 1001;
  min-width: 350px;
  max-width: 450px;
  display: none;
}

.file-preview-popup.show {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.file-preview-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.file-preview-header h4 {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.file-preview-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.3rem;
  cursor: pointer;
  padding: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
}

.file-preview-close:hover {
  background: var(--danger);
  color: white;
}

.file-preview-content {
  display: flex;
  gap: 1rem;
  align-items: center;
}

.file-preview-thumbnail {
  width: 60px;
  height: 60px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--bg-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  flex-shrink: 0;
}

.file-preview-info {
  flex: 1;
  min-width: 0;
}

.file-preview-name {
  font-weight: 500;
  margin-bottom: 0.25rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-preview-size {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.file-preview-actions {
  display: flex;
  gap: 0.5rem;
}

@media (max-width: 768px) {
  .file-preview-popup {
    min-width: calc(100% - 2rem);
    max-width: calc(100% - 2rem);
  }
}

/* Voice Recording Overlay */
.voice-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.9);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.voice-recording {
  text-align: center;
  color: var(--text-primary);
}

.voice-animation {
  font-size: 5rem;
  animation: pulse 1s infinite;
}

@keyframes pulse {
  0%, 100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.1);
    opacity: 0.8;
  }
}

#voice-timer {
  font-size: 2rem;
  margin: 1rem 0;
  font-family: monospace;
}

.voice-hint {
  color: var(--text-secondary);
  margin-bottom: 2rem;
}

#voice-cancel {
  padding: 12px 32px;
  font-size: 1rem;
}

/* File upload progress */
.file-progress {
  margin: 8px 0;
  padding: 12px;
  background: var(--bg-light);
  border-radius: 8px;
  border: 1px solid var(--border);
}

.file-progress-bar {
  height: 6px;
  background: var(--bg-medium);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 8px;
}

.file-progress-fill {
  height: 100%;
  background: var(--primary);
  transition: width 0.3s;
}

/* Enhanced send button */
#send-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 100px;
  justify-content: center;
}

/* File attachment styles */
.file-attachment {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: var(--bg-light);
  border: 1px solid var(--border);
  border-radius: 8px;
  text-decoration: none;
  color: var(--text-primary);
  transition: all 0.2s;
  max-width: 300px;
}

.file-attachment:hover {
  background: var(--bg-medium);
  transform: translateY(-2px);
}

.file-attachment span {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-attachment small {
  color: var(--text-secondary);
  font-size: 0.85rem;
}

.audio-message {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  background: var(--bg-light);
  border-radius: 8px;
}

.audio-message audio {
  height: 32px;
}

/* Image message styles */
.message img {
  max-width: 300px;
  border-radius: 8px;
  cursor: pointer;
  transition: transform 0.2s;
}

.message img:hover {
  transform: scale(1.02);
}

/* ============ VOICE & VIDEO CALLS ============ */

/* Call buttons in header */
.call-buttons {
  position: absolute;
  right: 1rem;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  gap: 0.5rem;
}

.call-btn {
  background: var(--bg-light);
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  font-size: 1.2rem;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.call-btn:hover {
  background: var(--primary);
  transform: scale(1.1);
}

.call-btn:active {
  transform: scale(0.95);
}

/* Call Overlay */
.call-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.95);
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.call-container {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  position: relative;
}

.call-header {
  padding: 1.5rem;
  text-align: center;
  background: rgba(0, 0, 0, 0.5);
  z-index: 3001;
}

.call-header h3 {
  margin: 0 0 0.5rem 0;
  font-size: 1.5rem;
  color: var(--text-primary);
}

#call-status {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.video-container {
  flex: 1;
  position: relative;
  background: #000;
}

.remote-video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

.local-video {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 150px;
  height: 200px;
  object-fit: cover;
  border-radius: 12px;
  border: 2px solid var(--primary);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  background: #000;
}

.call-timer {
  position: absolute;
  top: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.7);
  padding: 0.5rem 1rem;
  border-radius: 20px;
  font-family: monospace;
  font-size: 1.2rem;
  color: var(--text-primary);
  z-index: 3001;
}

.call-controls {
  padding: 2rem;
  display: flex;
  gap: 1.5rem;
  justify-content: center;
  background: rgba(0, 0, 0, 0.5);
  z-index: 3001;
}

.control-btn {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--bg-light);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
}

.control-btn:hover {
  transform: scale(1.1);
  background: var(--primary);
}

.control-btn:active {
  transform: scale(0.95);
}

.control-btn.muted {
  background: #dc3545;
}

.control-btn.video-off {
  background: #6c757d;
}

.end-call-btn {
  background: #dc3545;
}

.end-call-btn:hover {
  background: #c82333;
}

/* Mobile adjustments for calls */
@media (max-width: 768px) {
  .local-video {
    width: 100px;
    height: 133px;
    top: 0.5rem;
    right: 0.5rem;
  }
  
  .call-controls {
    padding: 1.5rem;
    gap: 1rem;
  }
  
  .control-btn {
    width: 50px;
    height: 50px;
    font-size: 1.2rem;
  }
  
  .call-buttons {
    right: 0.5rem;
  }
  
  .call-btn {
    width: 35px;
    height: 35px;
    font-size: 1rem;
  }
}

