/* Chat Application Styles */
:root {
  --brand: #D4A93B;
  --brand-dark: #173B73;
  --text-primary: #1a1a1a;
  --text-secondary: #666;
  --text-light: #999;
  --bg-primary: #ffffff;
  --bg-secondary: #f5f5f5;
  --bg-input: #efefef;
  --border-color: #e0e0e0;
  --msg-sent: #D4A93B;
  --msg-received: #f0f0f0;
  --online-status: #31a24c;
  --offline-status: #a0a0a0;
  --accent: #173B73;
}

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

body {
  font-family: 'Assistant', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-secondary);
  color: var(--text-primary);
  overflow: hidden;
}

/* Main Chat App Container */
.chat-app {
  display: flex;
  height: 100vh;
  background: white;
}

/* Sidebar */
.chat-sidebar {
  width: 360px;
  background: var(--bg-primary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

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

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 18px;
  font-weight: 700;
  color: var(--brand);
}

.logo svg {
  width: 32px;
  height: 32px;
}

.auth-buttons {
  display: flex;
  gap: 8px;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}

.username {
  color: var(--text-secondary);
  font-weight: 500;
}

.btn-icon {
  width: 32px;
  height: 32px;
  border: none;
  background: var(--bg-secondary);
  border-radius: 50%;
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

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

/* Sidebar Search */
.sidebar-search {
  padding: 8px 16px;
  flex-shrink: 0;
}

.search-box {
  width: 100%;
  padding: 10px 16px;
  border: none;
  border-radius: 24px;
  background: var(--bg-input);
  font-size: 14px;
  font-family: inherit;
  color: var(--text-primary);
  direction: rtl;
}

.search-box::placeholder {
  color: var(--text-light);
}

.search-box:focus {
  outline: none;
  background: #e0e0e0;
}

/* Chats List */
.chats-list {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}

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

.chat-item:hover {
  background: var(--bg-secondary);
}

.chat-item.active {
  background: #e8eaf6;
}

.chat-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand), var(--accent));
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 14px;
  flex-shrink: 0;
}

.chat-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.chat-name {
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 14px;
}

.chat-preview {
  font-size: 12px;
  color: var(--text-light);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-unread {
  background: var(--brand);
  color: white;
  border-radius: 12px;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  flex-shrink: 0;
}

#online-users-list .chat-item {
  padding: 12px 16px;
}

/* Sidebar Footer */
.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border-color);
  flex-shrink: 0;
}

.online-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--online-status);
}

/* Chat Main Area */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: white;
  overflow: hidden;
}

/* Chat Header */
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
  background: white;
}

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

.chat-header-title h2 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.subtitle {
  font-size: 12px;
  color: var(--text-light);
  display: block;
  margin-top: 2px;
}

.chat-header-actions {
  display: flex;
  gap: 8px;
}

/* Messages Container */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px;
  display: flex;
  flex-direction: column;
  background: white;
}

.messages-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-light);
  text-align: center;
}

.messages-empty div {
  font-size: 48px;
  margin-bottom: 12px;
}

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

/* Message Bubble */
.message {
  display: flex;
  margin-bottom: 8px;
  animation: messageIn 0.3s ease-out;
}

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

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

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

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

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

.message.received .message-content {
  background: var(--msg-received);
  color: var(--text-primary);
  border-bottom-left-radius: 4px;
}

.message-time {
  font-size: 11px;
  color: var(--text-light);
  margin-top: 2px;
  display: block;
}

.message.sent .message-time {
  color: rgba(255, 255, 255, 0.7);
}

.message-receipt {
  font-size: 11px;
  margin-top: 4px;
  color: rgba(255, 255, 255, 0.7);
}

/* Typing Indicator */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 14px;
  background: var(--msg-received);
  border-radius: 12px;
  width: fit-content;
}

.typing-indicator span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-light);
  animation: typing 1.4s infinite;
}

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

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

@keyframes typing {
  0%, 60%, 100% {
    opacity: 0.3;
    transform: translateY(0);
  }
  30% {
    opacity: 1;
    transform: translateY(-8px);
  }
}

/* Message Input Area */
.chat-input-area {
  padding: 12px 16px 16px;
  background: white;
  border-top: 1px solid var(--border-color);
  flex-shrink: 0;
}

.input-wrapper {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.message-input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--border-color);
  border-radius: 20px;
  font-size: 14px;
  font-family: inherit;
  resize: none;
  max-height: 100px;
  color: var(--text-primary);
  direction: rtl;
  background: var(--bg-input);
}

.message-input::placeholder {
  color: var(--text-light);
}

.message-input:focus {
  outline: none;
  border-color: var(--brand);
  background: white;
}

.btn-send {
  width: 40px;
  height: 40px;
  border: none;
  background: var(--brand);
  border-radius: 50%;
  cursor: pointer;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, transform 0.1s;
  flex-shrink: 0;
}

.btn-send:hover {
  background: #c49a2e;
}

.btn-send:active {
  transform: scale(0.95);
}

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

.modal-overlay.open {
  display: flex;
}

.modal {
  background: white;
  border-radius: 16px;
  padding: 28px;
  max-width: 360px;
  width: 90%;
  position: relative;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.16);
  animation: modalSlideUp 0.3s ease-out;
}

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

.modal-close {
  position: absolute;
  top: 12px;
  left: 12px;
  width: 32px;
  height: 32px;
  border: none;
  background: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--text-light);
}

.modal h2 {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 20px;
  text-align: center;
  color: var(--text-primary);
}

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

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--text-primary);
}

.form-group input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text-primary);
  direction: rtl;
  text-align: right;
}

.form-group input:focus {
  outline: none;
  border-color: var(--brand);
  background: #fafafa;
}

.btn-primary {
  width: 100%;
  padding: 12px;
  background: var(--brand);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-primary:hover {
  background: #c49a2e;
}

.btn-primary:active {
  background: #b88a26;
}

.modal p {
  text-align: center;
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 16px;
}

.modal a {
  color: var(--brand);
  text-decoration: none;
  font-weight: 600;
  cursor: pointer;
}

.modal a:hover {
  text-decoration: underline;
}

/* Scrollbar Styling */
.chats-list::-webkit-scrollbar,
.chat-messages::-webkit-scrollbar {
  width: 6px;
}

.chats-list::-webkit-scrollbar-track,
.chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

.chats-list::-webkit-scrollbar-thumb,
.chat-messages::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 3px;
}

.chats-list::-webkit-scrollbar-thumb:hover,
.chat-messages::-webkit-scrollbar-thumb:hover {
  background: #999;
}

/* Responsive */
@media (max-width: 768px) {
  .chat-sidebar {
    width: 280px;
  }

  .message-content {
    max-width: 85%;
  }
}

@media (max-width: 480px) {
  .chat-app {
    flex-direction: column-reverse;
  }

  .chat-sidebar {
    width: 100%;
    max-height: 200px;
    border-right: none;
    border-top: 1px solid var(--border-color);
  }

  .chat-main {
    flex: 1;
  }

  .message-content {
    max-width: 90%;
  }
}
