/* YalaBobo - Premium Chat System CSS */

.chat-container {
  display: grid;
  grid-template-columns: 350px 1fr;
  height: 100%;
  width: 100%;
  overflow: hidden;
}

/* Chat Sidebar (Conversation List) */
.chat-sidebar {
  border-left: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  height: 100%;
  background: rgba(11, 17, 32, 0.6);
  backdrop-filter: var(--glass-blur);
}

.search-bar-container {
  padding: 15px;
  border-bottom: 1px solid var(--border-color);
}

.search-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.search-input-wrapper svg {
  position: absolute;
  right: 15px;
  width: 18px;
  height: 18px;
  color: var(--text-muted);
}

.search-bar {
  width: 100%;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 12px 45px 12px 15px;
  color: var(--text-main);
  font-family: var(--font-tajawal);
  outline: none;
  font-size: 14px;
  transition: var(--transition);
}

.search-bar:focus {
  border-color: var(--primary);
  background: rgba(255, 255, 255, 0.08);
}

.conversation-list {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.conversation-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 15px;
  border-radius: 20px;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  border: 1px solid transparent;
}

.conversation-item:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.05);
}

.conversation-item.active {
  background: rgba(37, 211, 102, 0.08);
  border-color: rgba(37, 211, 102, 0.15);
}

.avatar-wrapper {
  position: relative;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  overflow: hidden;
}

.avatar-wrapper svg {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-wrapper img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.status-badge {
  position: absolute;
  bottom: 2px;
  left: 2px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid var(--background);
  background-color: var(--text-muted);
}

.status-badge.online {
  background-color: var(--primary);
  box-shadow: 0 0 8px var(--primary);
}

.conv-details {
  flex: 1;
  min-width: 0;
}

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

.conv-name {
  font-weight: 600;
  font-size: 15px;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conv-time {
  font-size: 11px;
  color: var(--text-muted);
}

.conv-last-msg {
  font-size: 13px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conversation-item.unread .conv-name {
  font-weight: 700;
}

.conversation-item.unread .conv-last-msg {
  color: var(--text-main);
  font-weight: 500;
}

.unread-badge {
  background: var(--primary);
  color: #000000;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
}

/* Chat Main Workspace */
.chat-workspace {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: radial-gradient(circle at top right, rgba(18, 140, 126, 0.05) 0%, transparent 60%);
  position: relative;
}

.chat-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
  gap: 15px;
  padding: 30px;
}

.chat-empty-state svg {
  width: 80px;
  height: 80px;
  color: rgba(255, 255, 255, 0.1);
}

.chat-workspace-header {
  height: 70px;
  padding: 0 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
  background: rgba(11, 17, 32, 0.4);
  backdrop-filter: var(--glass-blur);
}

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

.chat-user-name {
  font-weight: 700;
  font-size: 16px;
}

.chat-user-status {
  font-size: 12px;
  color: var(--text-muted);
}

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

/* Messages Area */
.messages-scroller {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.message-bubble-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  max-width: 70%;
}

.message-bubble-wrapper.outgoing {
  align-self: flex-end;
  flex-direction: row-reverse;
}

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

.message-bubble {
  padding: 12px 18px;
  border-radius: var(--radius);
  font-size: 14px;
  line-height: 1.5;
  position: relative;
  box-shadow: var(--shadow-main);
}

.message-bubble-wrapper.outgoing .message-bubble {
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  color: #FFFFFF;
  border-bottom-right-radius: 4px;
}

.message-bubble-wrapper.incoming .message-bubble {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  border-bottom-left-radius: 4px;
}

.message-meta {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 5px;
  font-size: 10px;
  color: rgba(255, 255, 255, 0.5);
  margin-top: 5px;
}

.message-bubble img {
  max-width: 100%;
  border-radius: 12px;
  margin-bottom: 5px;
}

/* Chat Input Bar */
.chat-input-bar {
  padding: 15px 20px;
  border-top: 1px solid var(--border-color);
  background: rgba(11, 17, 32, 0.4);
  backdrop-filter: var(--glass-blur);
  display: flex;
  align-items: center;
  gap: 12px;
}

.chat-input-wrapper {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
}

.chat-input-field {
  width: 100%;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  border-radius: 24px;
  padding: 14px 20px 14px 50px;
  color: var(--text-main);
  font-family: var(--font-tajawal);
  outline: none;
  font-size: 14px;
  resize: none;
  height: 48px;
  max-height: 120px;
  line-height: 1.4;
  overflow-y: auto;
}

.chat-input-field:focus {
  border-color: var(--primary);
  background: rgba(255, 255, 255, 0.08);
}

.chat-input-actions {
  position: absolute;
  left: 10px;
  display: flex;
  gap: 5px;
}

.chat-action-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.chat-action-btn:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.08);
}

.chat-send-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--primary);
  border: none;
  color: #000000;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: 0 4px 15px rgba(37, 211, 102, 0.3);
}

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

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

/* Typing Indicator Avatar Popup */
.typing-avatar-bubble {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-color);
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 12px;
  color: var(--text-muted);
  align-self: flex-start;
  margin-left: 20px;
  animation: fadeIn 0.3s forwards;
}

.typing-dots {
  display: flex;
  gap: 4px;
}

.typing-dots span {
  width: 6px;
  height: 6px;
  background-color: var(--primary);
  border-radius: 50%;
  animation: bounceDot 1.4s infinite ease-in-out both;
}

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

@keyframes bounceDot {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}

/* Responsive Mobile Chat Layout */
@media (max-width: 768px) {
  .chat-container {
    grid-template-columns: 1fr;
    position: relative;
  }
  .chat-sidebar {
    width: 100%;
  }
  .chat-workspace {
    position: fixed;
    top: 0;
    right: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 500;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: var(--background);
  }
  .chat-workspace.active {
    transform: translateX(0);
  }
  .back-chat-btn {
    display: flex !important;
  }
}

/* Snapchat-style Stories Tray */
.stories-tray {
  display: flex;
  gap: 15px;
  padding: 15px;
  overflow-x: auto;
  border-bottom: 1px solid var(--border-color);
  background: rgba(11, 17, 32, 0.3);
  scrollbar-width: none;
}

.stories-tray::-webkit-scrollbar {
  display: none;
}

.story-circle {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  flex-shrink: 0;
  width: 70px;
}

.story-ring {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  padding: 3px;
  background: linear-gradient(45deg, var(--primary), var(--accent));
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.story-circle.viewed .story-ring {
  background: var(--border-color);
}

.story-avatar-inner {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: var(--background);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--background);
}

.story-username {
  font-size: 11px;
  color: var(--text-muted);
  width: 100%;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Stories Viewer Fullscreen Overlay */
.story-viewer-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: #000;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  opacity: 0;
  visibility: hidden;
  transition: var(--transition);
}

.story-viewer-overlay.active {
  opacity: 1;
  visibility: visible;
}

.story-progress-bar-container {
  display: flex;
  gap: 5px;
  padding: 15px 20px;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  z-index: 10;
}

.story-progress-bg {
  flex: 1;
  height: 4px;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 2px;
  overflow: hidden;
}

.story-progress-fill {
  height: 100%;
  width: 0%;
  background: #FFFFFF;
  border-radius: 2px;
}

.story-viewer-header {
  position: absolute;
  top: 25px;
  left: 0;
  width: 100%;
  padding: 10px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 10;
  background: linear-gradient(to bottom, rgba(0,0,0,0.6), transparent);
}

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

.story-viewer-close {
  background: transparent;
  border: none;
  color: #FFFFFF;
  font-size: 20px;
  cursor: pointer;
}

.story-viewer-content {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.story-content-item {
  max-width: 100%;
  max-height: 100vh;
  object-fit: contain;
}

.story-text-container {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px;
  font-size: 24px;
  font-weight: 700;
  color: #FFFFFF;
}

