/**
 * Main Stylesheet - End-to-End Encrypted Chat
 * Theme System with CSS Variables
 */

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

:root {
  /* Light Theme (Default) */
  --bg-primary: #f5f5f5;
  --bg-secondary: #ffffff;
  --bg-tertiary: #f9f9f9;
  --text-primary: #333333;
  --text-secondary: #666666;
  --text-tertiary: #999999;
  --border-color: #e0e0e0;
  --accent-color: #667eea;
  --accent-hover: #5568d3;
  --sidebar-bg: #ffffff;
  --sidebar-hover: #f5f5f5;
  --chat-bg: #ffffff;
  --message-sent-bg: #667eea;
  --message-sent-text: #ffffff;
  --message-received-bg: #e8e8e8;
  --message-received-text: #333333;
  --input-bg: #ffffff;
  --input-border: #e0e0e0;
  --modal-bg: #ffffff;
  --shadow: rgba(0, 0, 0, 0.1);
  --scrollbar-track: #f1f1f1;
  --scrollbar-thumb: #ccc;
  --scrollbar-thumb-hover: #999;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
    'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
    sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background: var(--bg-primary);
  color: var(--text-primary);
  height: 100vh;
  overflow: hidden;
  transition: background-color 0.3s ease, color 0.3s ease;
}

#app {
  height: 100vh;
  display: flex;
  flex-direction: column;
}

/* View Management */
.view {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.view.hidden {
  display: none !important; /* Force hide - security */
}

/* Ensure main app is completely hidden until authenticated */
#main-app-view.hidden {
  display: none !important;
  visibility: hidden;
}

/* Auth View */
#auth-view {
  justify-content: center;
  align-items: center;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.auth-container {
  background: var(--bg-secondary);
  padding: 2rem;
  border-radius: 12px;
  box-shadow: 0 10px 40px var(--shadow);
  width: 100%;
  max-width: 400px;
}

.auth-container h1 {
  text-align: center;
  margin-bottom: 2rem;
  color: var(--accent-color);
  font-size: 2rem;
}

#auth-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.tab-button {
  flex: 1;
  padding: 0.75rem;
  border: 2px solid var(--border-color);
  background: var(--bg-secondary);
  border-radius: 8px;
  cursor: pointer;
  font-size: 1rem;
  transition: all 0.2s;
  color: var(--text-primary);
}

.tab-button.active {
  background: var(--accent-color);
  color: white;
  border-color: var(--accent-color);
}

#auth-form input {
  width: 100%;
  padding: 0.75rem;
  margin-bottom: 1rem;
  border: 2px solid var(--border-color);
  border-radius: 8px;
  font-size: 1rem;
  transition: border-color 0.2s;
  background: var(--input-bg);
  color: var(--text-primary);
}

#auth-form input:focus {
  outline: none;
  border-color: var(--accent-color);
}

#submit-button {
  width: 100%;
  padding: 0.75rem;
  background: var(--accent-color);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

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

.error-message {
  background: #fee;
  color: #c33;
  padding: 0.75rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  border: 1px solid #fcc;
}

/* Header */
.header {
  background: white;
  padding: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #e0e0e0;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.header h2 {
  font-size: 1.5rem;
  color: #333;
}

.icon-button {
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0.5rem;
  color: #666;
  transition: color 0.2s;
  z-index: 10;
  position: relative;
}

.icon-button:hover {
  color: #333;
  background: rgba(0, 0, 0, 0.05);
  border-radius: 4px;
}

.icon-button:active {
  transform: scale(0.95);
}

/* Main App Layout with Sidebar */
#main-app-view {
  background: var(--bg-secondary);
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.app-layout {
  display: flex;
  height: 100%;
  width: 100%;
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  width: 320px;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

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

.sidebar-header h2 {
  font-size: 1.5rem;
  color: var(--text-primary);
  margin: 0;
}

.sidebar-search {
  padding: 1rem;
  background: var(--sidebar-bg);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  gap: 0.5rem;
}

.sidebar-search input {
  flex: 1;
  padding: 0.75rem;
  border: 2px solid var(--input-border);
  border-radius: 8px;
  font-size: 0.95rem;
  background: var(--input-bg);
  color: var(--text-primary);
}

.sidebar-search input:focus {
  outline: none;
  border-color: var(--accent-color);
}

.search-button {
  padding: 0.75rem 1.25rem;
  background: var(--accent-color);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s;
}

.search-button:hover {
  background: var(--accent-hover);
}

.sidebar-list {
  flex: 1;
  overflow-y: auto;
  background: var(--sidebar-bg);
}

/* Main Content */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Conversations View (legacy - keep for compatibility) */
#conversations-view {
  background: white;
}

.new-chat-button {
  margin: 1rem;
  padding: 0.75rem 1.5rem;
  background: #667eea;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.new-chat-button:hover {
  background: #5568d3;
}

.conversations-list {
  flex: 1;
  overflow-y: auto;
}

.conversation-item {
  display: flex;
  align-items: center;
  padding: 1rem;
  border-bottom: 1px solid var(--border-color);
  cursor: pointer;
  transition: background 0.2s;
  position: relative;
  background: var(--sidebar-bg);
  color: var(--text-primary);
}

.conversation-item:hover {
  background: var(--sidebar-hover);
}

.conversation-item.active {
  background: var(--sidebar-hover);
  border-left: 3px solid var(--accent-color);
}

.conversation-item.updated {
  animation: highlightUpdate 1s ease-in-out;
}

@keyframes highlightUpdate {
  0% {
    background: #fff3cd;
  }
  50% {
    background: #ffe69c;
  }
  100% {
    background: inherit;
  }
}

.conversation-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 600;
  margin-right: 1rem;
  flex-shrink: 0;
}

.unread-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  background: #667eea;
  color: white;
  border-radius: 12px;
  padding: 2px 8px;
  font-size: 0.75rem;
  font-weight: 600;
  min-width: 20px;
  text-align: center;
  display: inline-block;
  box-shadow: 0 2px 4px rgba(102, 126, 234, 0.3);
  animation: pulse 2s infinite;
}

.unread-badge.flash {
  animation: flash 0.5s ease-in-out 3;
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.8;
    transform: scale(1.05);
  }
}

@keyframes flash {
  0%, 100% {
    background: #667eea;
    transform: scale(1);
  }
  50% {
    background: #ff6b6b;
    transform: scale(1.2);
  }
}

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

.conversation-name {
  font-weight: 600;
  margin-bottom: 0.25rem;
  color: #333;
}

.conversation-preview {
  color: #666;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.empty-state {
  text-align: center;
  padding: 3rem;
  color: #999;
}

/* New Chat View */
#new-chat-view {
  background: white;
}

.new-chat-container {
  padding: 2rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.new-chat-container input {
  padding: 0.75rem;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  font-size: 1rem;
}

.new-chat-container input:focus {
  outline: none;
  border-color: #667eea;
}

.new-chat-container button {
  padding: 0.75rem;
  background: #667eea;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}

/* Chat View */
.chat-view-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.chat-placeholder {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--chat-bg);
}

.chat-placeholder.hidden {
  display: none;
}

.placeholder-content {
  text-align: center;
  color: var(--text-tertiary);
}

.placeholder-content h3 {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
  color: var(--text-secondary);
}

.placeholder-content p {
  font-size: 1rem;
  color: var(--text-tertiary);
}

.chat-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  position: relative; /* Make it a positioning context for typing indicator */
}

.chat-container.hidden {
  display: none;
}

#chat-view {
  background: white;
  display: flex;
  flex-direction: column;
}

.chat-header {
  background: var(--bg-secondary);
  padding: 1rem;
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.back-button {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.5rem;
  margin-right: 0.5rem;
  color: #666;
}

.back-button:hover {
  color: #333;
}

.chat-title {
  display: flex;
  align-items: center;
  flex: 1;
}

.chat-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 600;
  margin-right: 0.75rem;
}

.chat-title-text {
  flex: 1;
}

.chat-geoip {
  font-size: 0.75rem;
  color: var(--text-tertiary);
  margin-bottom: 0.25rem;
  line-height: 1.3;
}

.chat-name {
  font-weight: 600;
  cursor: pointer;
  color: #333;
}

.chat-name:hover {
  color: #667eea;
}

.session-status {
  font-size: 0.85rem;
  color: var(--text-secondary); /* Use theme variable instead of hardcoded grey */
  display: block;
  margin-top: 0.25rem;
}

.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  background: var(--chat-bg);
}

.loading, .error {
  text-align: center;
  padding: 2rem;
  color: var(--text-secondary);
}

.error {
  color: #c33;
}

.message {
  margin-bottom: 1rem;
  display: flex;
  flex-direction: column;
  max-width: 70%;
  animation: fadeIn 0.2s;
}

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

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

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

.message-content {
  padding: 0.75rem 1rem;
  border-radius: 12px;
  word-wrap: break-word;
}

.own-message .message-content {
  background: var(--message-sent-bg);
  color: var(--message-sent-text);
  border-bottom-right-radius: 4px;
}

.other-message .message-content {
  background: var(--message-received-bg);
  color: var(--message-received-text);
  border: 1px solid var(--border-color);
  border-bottom-left-radius: 4px;
}

.message.pending .message-content {
  opacity: 0.6;
}

.message-time {
  font-size: 0.75rem;
  color: var(--text-tertiary);
  margin-top: 0.25rem;
  padding: 0 0.5rem;
}

.message-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.25rem;
  margin-top: 0.25rem;
  padding: 0 0.5rem;
}

.own-message .message-footer {
  justify-content: flex-end;
}

.other-message .message-footer {
  justify-content: flex-start;
}

/* Status icons ONLY for own messages (right side) */
/* Simple status display - always visible when rendered */
.own-message .message-status {
  font-size: 1.2rem;
  font-weight: bold;
  line-height: 1;
  display: inline-block !important;
  visibility: visible !important;
  opacity: 1 !important;
  vertical-align: middle;
  margin-left: 0.5rem;
  color: #666; /* Default grey color - will be overridden by .read class */
}

/* Ensure read status overrides default color */
.own-message .message-status.read {
  color: #6ba3d8 !important; /* Muted blue for read receipts - matches theme accent hover */
}

/* Ensure NO status icons on other messages (left side) */
.other-message .message-status {
  display: none !important;
}

/* Sent status - grey tick */
.own-message .message-status.sent {
  color: #666 !important;
}

/* Delivered status - grey tick + text */
.own-message .message-status.delivered {
  color: #666 !important;
}

.own-message .message-status.delivered .delivered-text {
  font-size: 0.75rem;
  font-weight: normal;
  margin-left: 2px;
  color: #666 !important;
}

/* Read status - blue ticks + text (duplicate removed - defined above) */

.own-message .message-status.read .read-text {
  font-size: 0.75rem;
  font-weight: normal;
  margin-left: 2px;
  color: #6ba3d8 !important;
}

/* Typing Indicator Container */
.typing-indicator-container {
  position: absolute;
  bottom: 76px; /* Position above input container (input-container height ~76px with padding) */
  left: 0;
  right: 0;
  padding: 0.75rem 1rem;
  min-height: 48px;
  display: flex;
  align-items: center;
  transition: opacity 0.2s ease-in-out, visibility 0.2s ease-in-out, transform 0.2s ease-in-out;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  border-bottom: 1px solid var(--border-color);
  visibility: hidden;
  opacity: 0;
  transform: translateY(10px); /* Start slightly below, slide up when visible */
  z-index: 10;
  pointer-events: none; /* Don't block clicks on input */
  box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.1); /* Subtle shadow above */
}

.typing-indicator-container.visible {
  visibility: visible;
  opacity: 1;
  transform: translateY(0); /* Slide up to show */
  pointer-events: auto;
}

/* Typing Indicator */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
}

.typing-avatar {
  flex-shrink: 0;
}

.typing-avatar-placeholder {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent-color);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  font-weight: 600;
}

.typing-content {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1;
}

.typing-dots {
  display: flex;
  gap: 0.3rem;
  align-items: center;
  padding: 0.5rem 0.75rem;
  background: var(--message-received-bg);
  border-radius: 18px;
  min-width: 50px;
  justify-content: center;
}

.typing-dots span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-secondary);
  animation: typingDot 1.4s infinite ease-in-out;
  display: inline-block;
}

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

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

.typing-dots span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typingDot {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: 0.4;
  }
  30% {
    transform: translateY(-10px);
    opacity: 1;
  }
}

.typing-text {
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-style: italic;
}

/* Decryption Warning */
.decrypt-warning {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem;
  margin: 0.5rem 0;
  background: #fff3cd;
  border: 2px solid #ffc107;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.decrypt-warning:hover {
  background: #ffe69c;
  border-color: #ff9800;
}

.warning-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
}

.warning-text {
  flex: 1;
  color: #856404;
  font-size: 0.9rem;
  line-height: 1.4;
}

.warning-link {
  color: #667eea;
  font-weight: 600;
  text-decoration: underline;
}

.warning-link:hover {
  color: #5568d3;
}

.input-container {
  display: flex;
  padding: 1rem;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  gap: 0.5rem;
  position: relative; /* Make it a positioning context */
  z-index: 5; /* Ensure input is above typing indicator when it slides up */
}

#message-input {
  flex: 1;
  padding: 0.75rem;
  border: 2px solid var(--input-border);
  border-radius: 20px;
  font-size: 1rem;
  background: var(--input-bg);
  color: var(--text-primary);
}

#message-input:focus {
  outline: none;
  border-color: var(--accent-color);
}

#message-input:disabled {
  background: var(--bg-tertiary);
  cursor: not-allowed;
}

#send-button {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #667eea;
  color: white;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  transition: background 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

#send-button:hover:not(:disabled) {
  background: #5568d3;
}

#send-button:disabled {
  background: #ccc;
  cursor: not-allowed;
}

/* Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: var(--modal-bg);
  border-radius: 12px;
  max-width: 500px;
  width: 90%;
  max-height: 80vh;
  color: var(--text-primary);
  overflow-y: auto;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

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

.modal-header h2 {
  margin: 0;
  color: var(--text-primary);
}

.close-button {
  background: none;
  border: none;
  font-size: 2rem;
  cursor: pointer;
  color: #999;
  line-height: 1;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.close-button:hover {
  color: #333;
}

.modal-body {
  padding: 1.5rem;
}

.security-section {
  margin-bottom: 1.5rem;
}

.security-section h4 {
  margin-bottom: 1rem;
  color: #333;
}

.security-description {
  margin-bottom: 1.5rem;
  color: #666;
  line-height: 1.6;
}

.security-item {
  margin-bottom: 1.5rem;
}

.security-label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: #333;
}

.fingerprint-container,
.public-key-container {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.fingerprint-code,
.public-key {
  flex: 1;
  font-family: 'Courier New', monospace;
  font-size: 0.9rem;
  background: #f5f5f5;
  padding: 0.75rem;
  border-radius: 8px;
  word-break: break-all;
}

.copy-button {
  padding: 0.5rem 1rem;
  background: #667eea;
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  white-space: nowrap;
}

.copy-button:hover {
  background: #5568d3;
}

.security-hint {
  font-size: 0.85rem;
  color: #666;
  margin-top: 0.5rem;
  line-height: 1.5;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: var(--scrollbar-track);
}

::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--scrollbar-thumb-hover);
}

/* Theme Classes */
body[data-theme="light"] {
  --bg-primary: #f5f5f5;
  --bg-secondary: #ffffff;
  --bg-tertiary: #f9f9f9;
  --text-primary: #333333;
  --text-secondary: #666666;
  --text-tertiary: #999999;
  --border-color: #e0e0e0;
  --accent-color: #667eea;
  --accent-hover: #5568d3;
  --sidebar-bg: #ffffff;
  --sidebar-hover: #f5f5f5;
  --chat-bg: #ffffff;
  --message-sent-bg: #667eea;
  --message-sent-text: #ffffff;
  --message-received-bg: #e8e8e8;
  --message-received-text: #333333;
  --input-bg: #ffffff;
  --input-border: #e0e0e0;
  --modal-bg: #ffffff;
  --shadow: rgba(0, 0, 0, 0.1);
  --scrollbar-track: #f1f1f1;
  --scrollbar-thumb: #ccc;
  --scrollbar-thumb-hover: #999;
}

body[data-theme="dark"] {
  --bg-primary: #000000;
  --bg-secondary: #0a0a0a;
  --bg-tertiary: #050505;
  --text-primary: #f0f0f0;
  --text-secondary: #c0c0c0;
  --text-tertiary: #909090;
  --border-color: #1a1a1a;
  --accent-color: #667eea;
  --accent-hover: #7a8ef5;
  --sidebar-bg: #0a0a0a;
  --sidebar-hover: #151515;
  --chat-bg: #000000;
  --message-sent-bg: #667eea;
  --message-sent-text: #ffffff;
  --message-received-bg: #0f0f0f;
  --message-received-text: #f0f0f0;
  --input-bg: #0a0a0a;
  --input-border: #1a1a1a;
  --modal-bg: #0a0a0a;
  --shadow: rgba(0, 0, 0, 0.8);
  --scrollbar-track: #000000;
  --scrollbar-thumb: #2a2a2a;
  --scrollbar-thumb-hover: #3a3a3a;
}

body[data-theme="dark-blue"] {
  --bg-primary: #0e1621;
  --bg-secondary: #17212b;
  --bg-tertiary: #1e2a35;
  --text-primary: #e4e6eb;
  --text-secondary: #ffffff; /* Changed from grey to white */
  --text-tertiary: #ffffff; /* Changed from grey to white */
  --border-color: #6ba3d8; /* Changed to muted blue that matches theme */
  --accent-color: #5288c1;
  --accent-hover: #6ba3d8;
  --sidebar-bg: #17212b;
  --sidebar-hover: #1e2a35;
  --chat-bg: #0e1621;
  --message-sent-bg: #5288c1;
  --message-sent-text: #ffffff;
  --message-received-bg: #1e2a35;
  --message-received-text: #e4e6eb;
  --input-bg: #17212b;
  --input-border: #6ba3d8; /* Changed to muted blue that matches theme */
  --modal-bg: #17212b;
  --shadow: rgba(0, 0, 0, 0.4);
  --scrollbar-track: #0e1621;
  --scrollbar-thumb: #3a4a5a;
  --scrollbar-thumb-hover: #4a5a6a;
}

/* Dark-blue theme specific overrides - NO GREY TEXT OR BORDERS - ALL WHITE/BLUE */
body[data-theme="dark-blue"] {
  /* Force all text to be white or primary color */
  --text-secondary: #ffffff !important;
  --text-tertiary: #ffffff !important;
  --border-color: #6ba3d8 !important; /* Muted blue for all borders */
}

/* All grey text elements → White */
body[data-theme="dark-blue"] .conversation-preview,
body[data-theme="dark-blue"] .conversation-name,
body[data-theme="dark-blue"] .session-status,
body[data-theme="dark-blue"] .icon-button,
body[data-theme="dark-blue"] .back-button,
body[data-theme="dark-blue"] .empty-state,
body[data-theme="dark-blue"] .loading,
body[data-theme="dark-blue"] .error,
body[data-theme="dark-blue"] .message-time,
body[data-theme="dark-blue"] .message-status.sent,
body[data-theme="dark-blue"] .message-status.delivered,
body[data-theme="dark-blue"] .message-status.delivered .delivered-text,
body[data-theme="dark-blue"] .security-description,
body[data-theme="dark-blue"] .security-hint,
body[data-theme="dark-blue"] .security-label,
body[data-theme="dark-blue"] .security-section h4,
body[data-theme="dark-blue"] .close-button,
body[data-theme="dark-blue"] .header h2,
body[data-theme="dark-blue"] .chat-name,
body[data-theme="dark-blue"] .typing-text {
  color: #ffffff !important;
}

/* All borders → Blue tick color */
body[data-theme="dark-blue"] .conversation-item,
body[data-theme="dark-blue"] .sidebar-header,
body[data-theme="dark-blue"] .sidebar-search,
body[data-theme="dark-blue"] .chat-header,
body[data-theme="dark-blue"] .modal-header,
body[data-theme="dark-blue"] .input-container,
body[data-theme="dark-blue"] .message,
body[data-theme="dark-blue"] .other-message .message-content,
body[data-theme="dark-blue"] .typing-indicator-container,
body[data-theme="dark-blue"] .decrypt-warning {
  border-color: #6ba3d8 !important;
}

/* Specific border overrides */
body[data-theme="dark-blue"] .conversation-item {
  border-bottom-color: #6ba3d8 !important;
}

body[data-theme="dark-blue"] .conversation-item.active {
  border-left-color: #6ba3d8 !important;
}

body[data-theme="dark-blue"] .sidebar-header,
body[data-theme="dark-blue"] .sidebar-search {
  border-bottom-color: #6ba3d8 !important;
}

body[data-theme="dark-blue"] .chat-header {
  border-bottom-color: #6ba3d8 !important;
}

body[data-theme="dark-blue"] .modal-header {
  border-bottom-color: #6ba3d8 !important;
}

body[data-theme="dark-blue"] .typing-indicator-container {
  border-top-color: #6ba3d8 !important;
  border-bottom-color: #6ba3d8 !important;
}

/* Input borders */
body[data-theme="dark-blue"] input,
body[data-theme="dark-blue"] #message-input,
body[data-theme="dark-blue"] #search-username,
body[data-theme="dark-blue"] .new-chat-container input {
  border-color: #6ba3d8 !important;
}

body[data-theme="dark-blue"] input:focus,
body[data-theme="dark-blue"] #message-input:focus,
body[data-theme="dark-blue"] #search-username:focus {
  border-color: #6ba3d8 !important;
  outline-color: #6ba3d8 !important;
}

/* Hover states */
body[data-theme="dark-blue"] .icon-button:hover,
body[data-theme="dark-blue"] .back-button:hover,
body[data-theme="dark-blue"] .chat-name:hover {
  color: #6ba3d8 !important;
}

body[data-theme="dark-blue"] .close-button:hover {
  color: #ffffff !important;
}

/* Additional elements that might have grey */
body[data-theme="dark-blue"] .placeholder-content h3,
body[data-theme="dark-blue"] .placeholder-content p {
  color: #ffffff !important;
}

/* Ensure message status default is white (not grey) */
body[data-theme="dark-blue"] .message-status {
  color: #ffffff !important;
}

/* Override borders on elements that should have borders */
body[data-theme="dark-blue"] [class*="border"],
body[data-theme="dark-blue"] [style*="border"] {
  border-color: #6ba3d8 !important;
}

/* Specific elements that shouldn't have blue borders (keep transparent or original) */
body[data-theme="dark-blue"] .message-content,
body[data-theme="dark-blue"] .own-message .message-content,
body[data-theme="dark-blue"] .conversation-avatar,
body[data-theme="dark-blue"] .chat-avatar,
body[data-theme="dark-blue"] .unread-badge,
body[data-theme="dark-blue"] button:not(.search-button):not(.new-chat-button) {
  border-color: transparent !important;
}

/* Keep read status blue */
body[data-theme="dark-blue"] .own-message .message-status.read,
body[data-theme="dark-blue"] .own-message .message-status.read .read-text {
  color: #6ba3d8 !important;
}

body[data-theme="green"] {
  --bg-primary: #e5ddd5;
  --bg-secondary: #ffffff;
  --bg-tertiary: #f0f0f0;
  --text-primary: #303030;
  --text-secondary: #65676b;
  --text-tertiary: #8a8d91;
  --border-color: #d4d4d4;
  --accent-color: #25d366;
  --accent-hover: #20ba5a;
  --sidebar-bg: #ffffff;
  --sidebar-hover: #f5f5f5;
  --chat-bg: #efeae2;
  --message-sent-bg: #dcf8c6;
  --message-sent-text: #303030;
  --message-received-bg: #ffffff;
  --message-received-text: #303030;
  --input-bg: #ffffff;
  --input-border: #d4d4d4;
  --modal-bg: #ffffff;
  --shadow: rgba(0, 0, 0, 0.1);
  --scrollbar-track: #e5ddd5;
  --scrollbar-thumb: #b0b0b0;
  --scrollbar-thumb-hover: #909090;
}

/* Settings Modal Styles */
.settings-section {
  margin-bottom: 2rem;
}

.settings-section h3 {
  margin-bottom: 0.5rem;
  color: var(--text-primary);
  font-size: 1.2rem;
}

.theme-selector {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  margin-top: 1rem;
}

.theme-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 1rem;
  border: 2px solid var(--border-color);
  background: var(--bg-secondary);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 0.9rem;
  color: var(--text-primary);
}

.theme-option:hover {
  border-color: var(--accent-color);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px var(--shadow);
}

.theme-option.active {
  border-color: var(--accent-color);
  background: var(--accent-color);
  color: white;
}

.theme-preview {
  width: 60px;
  height: 40px;
  border-radius: 6px;
  border: 2px solid var(--border-color);
  position: relative;
  overflow: hidden;
}

.light-preview {
  background: linear-gradient(135deg, #f5f5f5 0%, #ffffff 50%, #e8e8e8 100%);
}

.dark-preview {
  background: linear-gradient(135deg, #1e1e1e 0%, #2d2d2d 50%, #3a3a3a 100%);
}

.dark-blue-preview {
  background: linear-gradient(135deg, #0e1621 0%, #17212b 50%, #1e2a35 100%);
}

.green-preview {
  background: linear-gradient(135deg, #e5ddd5 0%, #dcf8c6 50%, #ffffff 100%);
}
