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

body {
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

#app {
  width: 100%;
  height: 100%;
}

/* AUTH SCREEN */
.auth-screen {
  display: none;
  width: 100%;
  height: 100%;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.auth-screen.active {
  display: flex;
}

.auth-container {
  width: 420px;
  background: white;
  padding: 50px;
  border-radius: 15px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  text-align: center;
  animation: slideUp 0.5s ease-out;
}

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

.auth-header h1 {
  font-size: 48px;
  margin-bottom: 10px;
  color: #667eea;
}

.auth-header .subtitle {
  color: #999;
  margin-bottom: 30px;
  font-size: 14px;
}

.auth-form {
  display: none;
}

.auth-form.active {
  display: block;
}

.auth-form h2 {
  margin-bottom: 25px;
  color: #333;
  font-size: 24px;
}

.input-field {
  width: 100%;
  padding: 12px 15px;
  margin-bottom: 15px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 14px;
  transition: border-color 0.3s;
}

.input-field:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 5px rgba(102, 126, 234, 0.1);
}

.btn-primary {
  width: 100%;
  padding: 12px;
  margin-top: 10px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 20px rgba(102, 126, 234, 0.3);
}

.btn-secondary {
  width: 100%;
  padding: 12px;
  margin-top: 20px;
  background: #f0f0f0;
  color: #667eea;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.3s;
}

.btn-secondary:hover {
  background: #e8e8e8;
}

.error-msg {
  color: #e74c3c;
  font-size: 13px;
  margin-top: 10px;
  min-height: 20px;
  pointer-events: none;
}

/* CHAT SCREEN */
.chat-screen {
  display: none;
  width: 100%;
  height: 100%;
  background: #f5f5f5;
}

.chat-screen.active {
  display: flex;
}

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

/* SIDEBAR */
.sidebar {
  width: 280px;
  background: white;
  border-right: 1px solid #ddd;
  display: flex;
  flex-direction: column;
  box-shadow: 2px 0 5px rgba(0, 0, 0, 0.05);
}

.sidebar-header {
  padding: 20px;
  border-bottom: 1px solid #eee;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.sidebar-header h2 {
  color: #667eea;
  font-size: 20px;
}

.btn-logout {
  padding: 8px 15px;
  background: #f0f0f0;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  transition: background 0.3s;
}

.btn-logout:hover {
  background: #e0e0e0;
}

/* SIDEBAR TABS */
.sidebar-tabs {
  display: flex;
  border-bottom: 1px solid #eee;
  background: #f9f9f9;
}

.tab-btn {
  flex: 1;
  padding: 12px;
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  color: #999;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
}

.tab-btn:hover {
  color: #667eea;
}

.tab-btn.active {
  color: #667eea;
  border-bottom-color: #667eea;
}

.tab-content {
  display: none;
  flex: 1;
  overflow-y: auto;
  padding: 10px 0;
}

.tab-content.active {
  display: flex;
  flex-direction: column;
}

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

.conversation-item {
  padding: 15px 20px;
  border-left: 3px solid transparent;
  cursor: pointer;
  transition: background 0.2s;
  border-bottom: 1px solid #f0f0f0;
}

.conversation-item:hover {
  background: #f9f9f9;
}

.conversation-item.active {
  background: #f0f4ff;
  border-left-color: #667eea;
}

.conversation-item-name {
  font-weight: 600;
  color: #333;
  margin-bottom: 5px;
}

.conversation-item-preview {
  font-size: 13px;
  color: #999;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-footer {
  padding: 15px 20px;
  border-top: 1px solid #eee;
}

.btn-new-chat {
  width: 100%;
  padding: 10px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  transition: transform 0.2s;
}

.btn-new-chat:hover {
  transform: scale(1.02);
}

/* FRIENDS SECTION */
.friends-section {
  padding: 15px 20px;
}

.friends-section h3 {
  font-size: 12px;
  color: #667eea;
  font-weight: 600;
  margin-bottom: 10px;
  text-transform: uppercase;
}

.friends-list,
.friend-requests-list,
.search-results {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.friend-item,
.friend-request-item,
.search-result-item {
  padding: 10px;
  background: #f9f9f9;
  border-radius: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.2s;
}

.friend-item:hover,
.friend-request-item:hover,
.search-result-item:hover {
  background: #f0f0f0;
}

.friend-name,
.user-name {
  font-weight: 600;
  color: #333;
}

.friend-actions,
.request-actions,
.search-actions {
  display: flex;
  gap: 8px;
}

.btn-small {
  padding: 6px 12px;
  background: #667eea;
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 11px;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-small:hover {
  background: #764ba2;
}

.btn-small.btn-accept {
  background: #27ae60;
}

.btn-small.btn-accept:hover {
  background: #229954;
}

.btn-small.btn-decline,
.btn-small.btn-cancel {
  background: #e74c3c;
}

.btn-small.btn-decline:hover,
.btn-small.btn-cancel:hover {
  background: #c0392b;
}

/* SEARCH INPUT */
.find-friends-section {
  padding: 15px;
  display: flex;
  flex-direction: column;
  gap: 15px;
  flex: 1;
  overflow-y: auto;
}

.search-input {
  width: 100%;
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 13px;
}

.search-input:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 5px rgba(102, 126, 234, 0.1);
}

/* MAIN CHAT AREA */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: white;
}

.chat-header {
  padding: 20px;
  border-bottom: 1px solid #eee;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: white;
}

.chat-title {
  font-size: 18px;
  font-weight: 600;
  color: #333;
}

.chat-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.status-online {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #27ae60;
}

.status-online::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  background: #27ae60;
  border-radius: 50%;
}

.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.message {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 10px;
}

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

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

.message-sender {
  font-size: 12px;
  font-weight: 600;
  color: #667eea;
  padding: 0 16px;
}

.message.own .message-sender {
  color: #764ba2;
}

.message-bubble {
  max-width: 60%;
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 14px;
  word-wrap: break-word;
}

.message.other .message-bubble {
  background: #f0f0f0;
  color: #333;
  border-radius: 12px 12px 12px 0;
}

.message.own .message-bubble {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border-radius: 12px 12px 0 12px;
}

.message-timestamp {
  font-size: 11px;
  color: #999;
  padding: 0 16px;
}

/* MESSAGE INPUT AREA */
.message-input-area {
  padding: 20px;
  border-top: 1px solid #eee;
  background: white;
}

.input-wrapper {
  display: flex;
  gap: 10px;
}

.message-input {
  flex: 1;
  padding: 12px 15px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  resize: none;
  max-height: 120px;
  transition: border-color 0.3s;
}

.message-input:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 5px rgba(102, 126, 234, 0.1);
}

.btn-send {
  padding: 12px 25px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  transition: transform 0.2s;
}

.btn-send:hover {
  transform: translateY(-2px);
}

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

::-webkit-scrollbar-track {
  background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: #999;
}