/* ========================================
   All For You Messenger - Global Styles
   ======================================== */

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

:root {
  --bg-primary: #1e1e2e;
  --bg-secondary: #2a2a3a;
  --bg-tertiary: #3a3a4a;
  --text-primary: #ffffff;
  --text-secondary: #8e8e98;
  --accent: #667eea;
  --accent-secondary: #764ba2;
  --message-incoming: #2a2a3a;
  --message-outgoing: #667eea;
  --success: #48bb78;
  --error: #f56565;
  --warning: #ed8936;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
}

  /* ========================================
     Auth Pages (Login / Register)
     ======================================== */

.auth-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: linear-gradient(135deg, #1e1e2e 0%, #2a2a3a 100%);
}

.auth-card {
  background: var(--bg-secondary);
  border-radius: 24px;
  padding: 40px 32px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  transition: transform 0.3s ease;
}

.auth-card:hover {
  transform: translateY(-4px);
}

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

.logo-icon {
  font-size: 64px;
  margin-bottom: 16px;
  animation: pulse 2s ease-in-out infinite;
}

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

  50% {
    transform: scale(1.05);
  }
}

.auth-logo h1 {
  font-size: 32px;
  background: linear-gradient(135deg, var(--accent), var(--accent-secondary));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  margin-bottom: 8px;
}

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

.auth-input {
  background: var(--bg-tertiary);
  border: 1px solid var(--bg-tertiary);
  border-radius: 12px;
  padding: 14px 16px;
  width: 100%;
  margin-bottom: 16px;
  color: var(--text-primary);
  font-size: 16px;
  transition: all 0.3s ease;
}

.auth-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.2);
}

.auth-btn {
  background: linear-gradient(135deg, var(--accent), var(--accent-secondary));
  color: white;
  border: none;
  border-radius: 12px;
  padding: 14px;
  width: 100%;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
}

.auth-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.auth-footer {
  text-align: center;
  margin-top: 24px;
  color: var(--text-secondary);
}

.auth-footer a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.3s ease;
}

.auth-footer a:hover {
  color: var(--accent-secondary);
  text-decoration: underline;
}

.error-message {
  background: rgba(245, 101, 101, 0.1);
  border: 1px solid var(--error);
  border-radius: 12px;
  padding: 12px;
  color: var(--error);
  margin-bottom: 16px;
  font-size: 14px;
}

.success-message {
  background: rgba(72, 187, 120, 0.1);
  border: 1px solid var(--success);
  border-radius: 12px;
  padding: 12px;
  color: var(--success);
  margin-bottom: 16px;
  font-size: 14px;
}

  /* Форма регистрации */
.register-form .helptext {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: -12px;
  margin-bottom: 12px;
}

.register-form ul {
  list-style: none;
  margin-bottom: 16px;
  padding: 8px 12px;
  background: var(--bg-tertiary);
  border-radius: 8px;
  font-size: 12px;
  color: var(--text-secondary);
}

.register-form li {
  margin-bottom: 4px;
}

  /* ========================================
     Chat Interface
     ======================================== */

.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-width: 500px;
  margin: 0 auto;
  background: var(--bg-primary);
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--bg-tertiary);
}

.header-left .user-avatar {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--accent), var(--accent-secondary));
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 18px;
}

.header-center h1 {
  font-size: 18px;
  font-weight: 600;
}

.icon-btn {
  background: var(--bg-tertiary);
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  cursor: pointer;
  font-size: 20px;
  transition: all 0.3s ease;
}

.icon-btn:hover {
  background: var(--accent);
  transform: scale(1.05);
}

.search-bar {
  padding: 12px 16px;
}

.search-input {
  width: 100%;
  background: var(--bg-secondary);
  border: none;
  border-radius: 24px;
  padding: 12px 16px;
  color: var(--text-primary);
  font-size: 14px;
}

.search-input:focus {
  outline: none;
  box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.2);
}

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

.room-item {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  gap: 12px;
  border-bottom: 1px solid var(--bg-tertiary);
  text-decoration: none;
  transition: background 0.3s ease;
}

.room-item:hover {
  background: var(--bg-tertiary);
}

.room-avatar {
  width: 56px;
  height: 56px;
  background: var(--bg-tertiary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
}

.room-info {
  flex: 1;
}

.room-name {
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.room-preview {
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.room-meta {
  text-align: right;
}

.room-time {
  font-size: 11px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.unread-badge {
  background: var(--accent);
  border-radius: 12px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: bold;
}

.empty-state {
  text-align: center;
  padding: 60px 20px;
}

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

.empty-state p {
  color: var(--text-secondary);
  margin-bottom: 20px;
}

  /* ========================================
     Chat Room
     ======================================== */

.chat-room-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-width: 500px;
  margin: 0 auto;
  background: var(--bg-primary);
}

.chat-room-header {
  display: flex;
  align-items: center;
  padding: 12px;
  background: var(--bg-secondary);
  gap: 12px;
  border-bottom: 1px solid var(--bg-tertiary);
}

.back-btn {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--text-primary);
  padding: 8px;
  border-radius: 50%;
  transition: background 0.3s ease;
}

.back-btn:hover {
  background: var(--bg-tertiary);
}

.room-info {
  flex: 1;
}

.room-status {
  font-size: 12px;
  color: var(--text-secondary);
}

.menu-btn {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--text-primary);
  padding: 8px;
  border-radius: 50%;
}

.messages-area {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--bg-primary);
}

.message {
  max-width: 80%;
  display: flex;
  flex-direction: column;
}

.message.incoming {
  align-self: flex-start;
}

.message.outgoing {
  align-self: flex-end;
}

.message-sender {
  font-size: 11px;
  color: var(--text-secondary);
  margin-bottom: 2px;
  margin-left: 12px;
}

.message-content {
  padding: 10px 14px;
  border-radius: 20px;
  font-size: 14px;
  word-wrap: break-word;
}

.message.incoming .message-content {
  background: var(--message-incoming);
  border-bottom-left-radius: 4px;
}

.message.outgoing .message-content {
  background: var(--message-outgoing);
  border-bottom-right-radius: 4px;
}

.message-text {
  line-height: 1.4;
}

.message-meta {
  display: flex;
  justify-content: flex-end;
  gap: 4px;
  margin-top: 4px;
  font-size: 10px;
  opacity: 0.7;
}

.empty-messages {
  text-align: center;
  padding: 40px;
  color: var(--text-secondary);
}

.typing-indicator {
  padding: 8px 16px;
  font-size: 12px;
  color: var(--text-secondary);
  background: var(--bg-secondary);
  border-radius: 20px;
  margin: 0 16px;
  width: fit-content;
}

.typing-dots {
  animation: blink 1.4s infinite;
}

@keyframes blink {
  0%, 100% {
    opacity: 0.2;
  }

  50% {
    opacity: 1;
  }
}

  /* ========================================
     Input Area
     ======================================== */

.input-area {
  background: var(--bg-secondary);
  padding: 12px 16px;
  display: flex;
  gap: 12px;
  border-top: 1px solid var(--bg-tertiary);
}

.message-input {
  flex: 1;
  background: var(--bg-tertiary);
  border: none;
  border-radius: 24px;
  padding: 12px 16px;
  color: var(--text-primary);
  font-size: 14px;
}

.message-input:focus {
  outline: none;
  box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.2);
}

.send-btn, .attach-btn {
  background: var(--bg-tertiary);
  border: none;
  border-radius: 50%;
  width: 44px;
  height: 44px;
  cursor: pointer;
  font-size: 18px;
  transition: all 0.3s ease;
}

.send-btn:hover, .attach-btn:hover {
  transform: scale(1.05);
}

.send-btn {
  background: linear-gradient(135deg, var(--accent), var(--accent-secondary));
  color: white;
}

  /* ========================================
     Modal
     ======================================== */

.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal.active {
  display: flex;
}

.modal-content {
  background: var(--bg-secondary);
  border-radius: 24px;
  width: 90%;
  max-width: 340px;
  padding: 24px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.modal-header h3 {
  font-size: 20px;
}

.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--text-secondary);
}

  /* ========================================
     Responsive
     ======================================== */

@media (min-width: 768px) {
  body {
    background: #0a0a0a;
    display: flex;
    justify-content: center;
    align-items: center;
  }

  .app-container, .chat-room-container {
    max-width: 500px;
    height: 90vh;
    border-radius: 24px;
    overflow: hidden;
    margin: 20px auto;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  }

  .auth-card {
    max-width: 420px;
  }
}



/* Мобильные оптимизации */
@media (max-width: 768px) {
  .chat-room-container {
    height: 100vh;
    display: flex;
    flex-direction: column;
  }

  .messages-area {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
  }

  .input-area {
    flex-shrink: 0;
    padding: 10px 12px;
  }

  .message-input {
    font-size: 16px;
    padding: 10px 14px;
  }

  .send-btn {
    width: 44px;
    height: 44px;
  }

  /* Прячем кнопку выхода на мобильных в чате */
  .logout-btn {
    opacity: 0.7;
    font-size: 10px !important;
    padding: 4px 10px !important;
  }
}