/* ============================================================
   RESET & BASE STYLES
   ============================================================ */

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

body {
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
    Arial, sans-serif;
  background-color: #0f0f0f;
  color: #e8e8e8;
  height: 100vh;
  overflow: hidden;
}

a {
  color: #7c8dff;
  text-decoration: none;
  cursor: pointer;
}

a:hover {
  text-decoration: underline;
}

/* ============================================================
   SCREEN MANAGEMENT
   ============================================================ */

.screen {
  display: none;
  height: 100vh;
  width: 100%;
}

.screen.active {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ============================================================
   UTILITY CLASSES
   ============================================================ */

.hidden {
  display: none !important;
}

/* ============================================================
   BUTTONS
   ============================================================ */

.btn {
  padding: 12px 20px;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-logout {
  font-size: 14px;
  font-weight: 400;
}

.btn-primary {
  background-color: #7c8dff;
  color: #ffffff;
  width: 100%;
}

.btn-primary:hover {
  background-color: #6b7de0;
  transform: translateY(-1px);
}

.btn-primary:disabled {
  background-color: #3a3f5c;
  color: #7a7f9a;
  cursor: not-allowed;
  transform: none;
}

.btn-icon {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: background-color 0.2s;
  color: #a0a0a0;
}

.btn-icon:hover {
  background-color: #2a2a2a;
}

/* ============================================================
   AUTH SCREEN
   ============================================================ */

.auth-container {
  background: #1a1a1a;
  border-radius: 16px;
  border: 1px solid #2a2a2a;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  padding: 40px;
  width: 100%;
  max-width: 420px;
}

.auth-header {
  text-align: center;
  margin-bottom: 32px;
}

.auth-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

.auth-header h1 {
  font-size: 28px;
  font-weight: 700;
  color: #ffffff;
  margin-bottom: 4px;
}

.auth-subtitle {
  font-size: 14px;
  color: #8a8a8a;
}

.auth-form h2 {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 20px;
  text-align: center;
  color: #e0e0e0;
}

.input-group {
  margin-bottom: 16px;
}

.input-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #a0a0a0;
  margin-bottom: 6px;
}

.input-group input {
  width: 100%;
  padding: 12px 14px;
  background: #242424;
  border: 1.5px solid #333333;
  border-radius: 8px;
  font-size: 15px;
  color: #e8e8e8;
  transition: border-color 0.2s ease;
  outline: none;
}

.input-group input::placeholder {
  color: #666666;
}

.input-group input:focus {
  border-color: #7c8dff;
}

.auth-switch {
  text-align: center;
  margin-top: 20px;
  font-size: 14px;
  color: #8a8a8a;
}

/* ============================================================
   CHAT SCREEN
   ============================================================ */

.chat-container {
  display: flex;
  height: 100vh;
  width: 100%;
}

/* ============================================================
   SIDEBAR
   ============================================================ */

.sidebar {
  width: 340px;
  min-width: 340px;
  background: #1a1a1a;
  border-right: 1px solid #2a2a2a;
  display: flex;
  flex-direction: column;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid #2a2a2a;
  background: #1e1e1e;
}

.current-user {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-avatar {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, #7c8dff, #a78bfa);
  color: #ffffff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
}

.user-name {
  font-weight: 600;
  font-size: 15px;
  color: #e8e8e8;
}

.search-container {
  padding: 12px 16px;
  border-bottom: 1px solid #2a2a2a;
  position: relative;
}

.search-container input {
  width: 100%;
  padding: 10px 14px;
  background: #242424;
  border: 1.5px solid #333333;
  border-radius: 20px;
  font-size: 14px;
  color: #e8e8e8;
  outline: none;
  transition: border-color 0.2s;
}

.search-container input::placeholder {
  color: #666666;
}

.search-container input:focus {
  border-color: #7c8dff;
}

.search-results {
  position: absolute;
  top: 100%;
  left: 16px;
  right: 16px;
  background: #242424;
  border: 1px solid #333333;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  z-index: 10;
  max-height: 300px;
  overflow-y: auto;
}

.search-result-item {
  padding: 12px 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: background-color 0.2s;
  color: #e8e8e8;
}

.search-result-item:hover {
  background-color: #2e2e2e;
}

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

.conversation-item {
  padding: 14px 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: background-color 0.2s;
  border-bottom: 1px solid #222222;
}

.conversation-item:hover {
  background-color: #242424;
}

.conversation-item.active {
  background-color: #2a2d3e;
  border-left: 3px solid #7c8dff;
}

.conversation-avatar {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, #3a3f5c, #4a4f6c);
  color: #b0b8ff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 18px;
  flex-shrink: 0;
}

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

.conversation-name {
  font-weight: 600;
  font-size: 15px;
  color: #e0e0e0;
}

.conversation-username {
  font-size: 13px;
  color: #7a7a7a;
}

/* ============================================================
   MAIN CHAT AREA
   ============================================================ */

.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  background-color: #0f0f0f;
}

.chat-header {
  padding: 16px 20px;
  background: #1a1a1a;
  border-bottom: 1px solid #2a2a2a;
  display: flex;
  align-items: center;
}

.chat-header-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.chat-header-name {
  font-weight: 600;
  font-size: 16px;
  color: #e8e8e8;
}

.encryption-badge {
  font-size: 12px;
  color: #6eccaf;
}

.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

.no-chat-selected {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #6a6a6a;
  text-align: center;
}

.no-chat-icon {
  font-size: 64px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.no-chat-selected h3 {
  font-size: 20px;
  color: #a0a0a0;
  margin-bottom: 8px;
}

.no-chat-selected p {
  font-size: 14px;
  color: #6a6a6a;
}

.message-input-container {
  padding: 16px 20px;
  background: #1a1a1a;
  border-top: 1px solid #2a2a2a;
}

.message-input-container form {
  display: flex;
  gap: 10px;
}

.message-input-container input {
  flex: 1;
  padding: 12px 16px;
  background: #242424;
  border: 1.5px solid #333333;
  border-radius: 20px;
  font-size: 14px;
  color: #e8e8e8;
  outline: none;
  transition: border-color 0.2s;
}

.message-input-container input::placeholder {
  color: #666666;
}

.message-input-container input:focus {
  border-color: #7c8dff;
}

.message-input-container .btn {
  width: auto;
  border-radius: 20px;
  padding: 10px 24px;
}

/* ============================================================
   MESSAGE BUBBLES
   ============================================================ */

.message {
  display: flex;
  margin-bottom: 8px;
}

.message.sent {
  justify-content: flex-end;
}

.message.received {
  justify-content: flex-start;
}

.message-bubble {
  max-width: 70%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.4;
  word-wrap: break-word;
}

.message.sent .message-bubble {
  background: linear-gradient(135deg, #5b6fe0, #7c8dff);
  color: #ffffff;
  border-bottom-right-radius: 4px;
}

.message.received .message-bubble {
  background-color: #242424;
  color: #e0e0e0;
  border: 1px solid #2e2e2e;
  border-bottom-left-radius: 4px;
}

/* ============================================================
   FORM VALIDATION — Error Messages
   ============================================================ */

.error-message {
  display: block;
  color: #ff6b6b;
  font-size: 12px;
  margin-top: 4px;
  min-height: 0;
  line-height: 1.3;
}

input.error {
  border-color: #ff6b6b !important;
  background-color: #2a1f1f !important;
}

input.error:focus {
  border-color: #ff6b6b !important;
  box-shadow: 0 0 0 2px rgba(255, 107, 107, 0.2);
}

/* Unread message badge */
.unread-badge {
  color: #7c8dff;
  font-size: 18px;
  flex-shrink: 0;
  animation: pulse 2s infinite;
}

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

/* ============================================================
   RESPONSIVE DESIGN
   ============================================================ */

@media (max-width: 768px) {
  .auth-container {
    margin: 16px;
    padding: 24px;
  }

  .sidebar {
    width: 260px;
    min-width: 260px;
  }
}

@media (max-width: 480px) {
  .sidebar {
    width: 100%;
    min-width: 100%;
  }
}
