/* ==========================================================================
   COMMUNITY SECTION STYLES (WhatsApp-Style Interface)
   ========================================================================== */

/* Main Community Layout Grid */
.community-layout-container {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr) 220px;
  height: calc(100vh - 150px);
  max-height: calc(100vh - 150px);
  min-height: 440px;
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.05);
  border: 1px solid #e2e8f0;
  overflow: hidden;
  margin-top: 8px;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  min-width: 0;
}



/* --------------------------------------------------------------------------
   LEFT PANEL: CHANNELS & GROUPS
   -------------------------------------------------------------------------- */
.community-channels-panel {
  background: #f8fafc;
  border-right: 1px solid #e2e8f0;
  display: flex;
  flex-direction: column;
  height: 100%;
  min-width: 0;
  min-height: 0;
  box-sizing: border-box;
}

.channels-header {
  padding: 18px 20px;
  background: #ffffff;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.channels-header-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: 'Outfit', sans-serif;
  font-size: 1.15rem;
  font-weight: 700;
  color: #0f172a;
}

.channels-header-title i {
  color: #2563eb;
  font-size: 1.25rem;
}

.btn-new-channel {
  background: #eff6ff;
  color: #2563eb;
  border: none;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-new-channel:hover {
  background: #2563eb;
  color: #ffffff;
  transform: scale(1.05);
}

.channels-search-box {
  padding: 12px 16px;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
}

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

.search-input-wrapper i {
  position: absolute;
  left: 12px;
  color: #94a3b8;
  font-size: 0.9rem;
}

.channels-search-input {
  width: 100%;
  padding: 8px 12px 8px 36px;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 20px;
  font-size: 0.875rem;
  color: #1e293b;
  outline: none;
  transition: border-color 0.2s ease;
}

.channels-search-input:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.channels-list {
  flex: 1 1 0%;
  min-height: 0;
  overflow-y: auto;
  padding: 8px;
}

.channel-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-bottom: 4px;
}

.channel-item:hover {
  background: #f1f5f9;
}

.channel-item.active {
  background: #eff6ff;
  border-left: 4px solid #2563eb;
}

.channel-avatar {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.channel-avatar.announcement {
  background: linear-gradient(135deg, #f59e0b, #d97706);
}

.channel-avatar.homework {
  background: linear-gradient(135deg, #10b981, #059669);
}

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

.channel-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2px;
}

.channel-name {
  font-weight: 600;
  font-size: 0.925rem;
  color: #0f172a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.channel-time {
  font-size: 0.75rem;
  color: #64748b;
}

.channel-bottom-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.channel-last-msg {
  font-size: 0.8rem;
  color: #64748b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 160px;
}

.unread-badge {
  background: #2563eb;
  color: #ffffff;
  font-size: 0.725rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 10px;
}

/* --------------------------------------------------------------------------
   CENTER PANEL: ACTIVE CHAT WINDOW
   -------------------------------------------------------------------------- */
.community-chat-panel {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-height: 100%;
  min-height: 0;
  min-width: 0;
  box-sizing: border-box;
  overflow: hidden;
  background: #f8fafc;

  background-image: radial-gradient(#cbd5e1 1px, transparent 1px);
  background-size: 24px 24px;
}

.chat-header {
  padding: 14px 24px;
  background: #ffffff;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
}

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

/* Mobile Back Arrow Button in Chat Header */
.btn-chat-back-mobile {
  display: none;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #2563eb;
  font-size: 1.05rem;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.btn-chat-back-mobile:hover {
  background: #2563eb;
  color: #ffffff;
}

@media (max-width: 768px) {
  .btn-chat-back-mobile {
    display: inline-flex;
  }
}

.chat-header-avatar {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: #2563eb;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
}

.chat-header-title-text {
  font-family: 'Outfit', sans-serif;
  font-size: 1.1rem;
  font-weight: 700;
  color: #0f172a;
}

.chat-header-subtitle {
  font-size: 0.8rem;
  color: #64748b;
}

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

.btn-chat-action {
  background: transparent;
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  color: #64748b;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.btn-chat-action:hover {
  background: #f1f5f9;
  color: #0f172a;
}

/* Chat Messages Body */
.chat-messages-container {
  flex: 1 1 0%;
  min-height: 0;
  overflow-y: auto !important;
  overflow-x: hidden;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-behavior: smooth;
}

.chat-date-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 12px 0;
}

.chat-date-divider span {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  color: #64748b;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 14px;
  border-radius: 20px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.02);
}

/* WhatsApp Message Bubbles */
.message-bubble-wrapper {
  display: flex;
  flex-direction: column;
  max-width: 70%;
}

.message-bubble-wrapper.sent {
  align-self: flex-end;
}

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

.message-bubble {
  padding: 12px 16px;
  border-radius: 16px;
  position: relative;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
  line-height: 1.5;
  font-size: 0.925rem;
}

.message-bubble-wrapper.sent .message-bubble {
  background: #dbeafe;
  color: #1e3a8a;
  border-bottom-right-radius: 4px;
}

.message-bubble-wrapper.received .message-bubble {
  background: #ffffff;
  color: #0f172a;
  border: 1px solid #e2e8f0;
  border-bottom-left-radius: 4px;
}

.message-sender-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.message-sender-name {
  font-weight: 700;
  font-size: 0.825rem;
  color: #2563eb;
}

.role-badge {
  font-size: 0.675rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 6px;
  text-transform: uppercase;
}

.role-badge.mentor {
  background: #fef3c7;
  color: #b45309;
}

.role-badge.student {
  background: #e0e7ff;
  color: #4338ca;
}

.message-text {
  word-break: break-word;
}

.message-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  margin-top: 4px;
  font-size: 0.7rem;
  color: #64748b;
}

.message-meta i {
  color: #2563eb;
}

/* Image Attachment in Bubble */
.message-image-attachment {
  margin-top: 8px;
  border-radius: 10px;
  overflow: hidden;
  max-width: 320px;
  cursor: pointer;
  border: 1px solid rgba(0,0,0,0.08);
  transition: transform 0.2s ease;
}

.message-image-attachment:hover {
  transform: scale(1.02);
}

.message-image-attachment img {
  width: 100%;
  height: auto;
  display: block;
  object-fit: cover;
  max-height: 240px;
}

/* File Attachment in Bubble */
.message-file-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid #cbd5e1;
  padding: 10px 14px;
  border-radius: 10px;
  margin-top: 8px;
  min-width: 240px;
}

.file-icon-box {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: #eff6ff;
  color: #2563eb;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}

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

.file-name {
  font-weight: 600;
  font-size: 0.85rem;
  color: #0f172a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-size {
  font-size: 0.725rem;
  color: #64748b;
}

.btn-file-download {
  color: #2563eb;
  background: #ffffff;
  border: 1px solid #bfdbfe;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s ease;
}

.btn-file-download:hover {
  background: #2563eb;
  color: #ffffff;
}

/* Chat Input Bar */
.chat-input-bar {
  padding: 14px 20px;
  background: #ffffff;
  border-top: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  gap: 12px;
  position: relative;
}

.input-actions-left {
  display: flex;
  align-items: center;
  gap: 4px;
}

.btn-attachment-toggle {
  background: transparent;
  border: none;
  color: #64748b;
  font-size: 1.25rem;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.btn-attachment-toggle:hover {
  background: #f1f5f9;
  color: #2563eb;
}

.attachment-menu-popup {
  position: absolute;
  bottom: 65px;
  left: 20px;
  background: #ffffff;
  border-radius: 14px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
  border: 1px solid #e2e8f0;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 20;
  min-width: 180px;
}

.attachment-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 8px;
  background: transparent;
  border: none;
  color: #1e293b;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s ease;
  width: 100%;
  text-align: left;
}

.attachment-menu-item:hover {
  background: #f1f5f9;
}

.attachment-menu-item i {
  font-size: 1.1rem;
}

.attachment-menu-item i.fa-image { color: #3b82f6; }
.attachment-menu-item i.fa-file-lines { color: #10b981; }

.chat-text-input {
  flex: 1;
  padding: 10px 16px;
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: 24px;
  font-size: 0.925rem;
  color: #0f172a;
  outline: none;
  transition: all 0.2s ease;
}

.chat-text-input:focus {
  background: #ffffff;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.btn-send-message {
  background: #2563eb;
  color: #ffffff;
  border: none;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}

.btn-send-message:hover {
  background: #1d4ed8;
  transform: scale(1.05);
}

/* Preview Bar for Upload */
.attachment-preview-bar {
  padding: 10px 16px;
  background: #eff6ff;
  border-top: 1px solid #bfdbfe;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.preview-file-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  color: #1e40af;
}

.btn-remove-preview {
  background: transparent;
  border: none;
  color: #ef4444;
  cursor: pointer;
  font-size: 1rem;
}

/* --------------------------------------------------------------------------
   RIGHT PANEL: MEDIA GALLERY & GROUP INFO
   -------------------------------------------------------------------------- */
.community-info-panel {
  background: #ffffff;
  border-left: 1px solid #e2e8f0;
  display: flex;
  flex-direction: column;
  height: 100%;
  max-height: 100%;
  min-height: 0;
  min-width: 0;
  box-sizing: border-box;
  overflow-y: auto;
}

/* Custom Scrollbars */
.chat-messages-container::-webkit-scrollbar,
.channels-list::-webkit-scrollbar,
.community-info-panel::-webkit-scrollbar {
  width: 6px;
}
.chat-messages-container::-webkit-scrollbar-track,
.channels-list::-webkit-scrollbar-track,
.community-info-panel::-webkit-scrollbar-track {
  background: transparent;
}
.chat-messages-container::-webkit-scrollbar-thumb,
.channels-list::-webkit-scrollbar-thumb,
.community-info-panel::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 10px;
}
.chat-messages-container::-webkit-scrollbar-thumb:hover,
.channels-list::-webkit-scrollbar-thumb:hover,
.community-info-panel::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

.info-panel-header {
  padding: 24px 20px 16px;
  text-align: center;
  border-bottom: 1px solid #f1f5f9;
}

.info-panel-avatar {
  width: 64px;
  height: 64px;
  border-radius: 18px;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.75rem;
  margin: 0 auto 12px;
  box-shadow: 0 8px 16px rgba(37, 99, 235, 0.2);
}

.info-panel-title {
  font-family: 'Outfit', sans-serif;
  font-size: 1.15rem;
  font-weight: 700;
  color: #0f172a;
}

.info-panel-desc {
  font-size: 0.825rem;
  color: #64748b;
  margin-top: 4px;
  line-height: 1.4;
}

.info-section {
  padding: 18px 20px;
  border-bottom: 1px solid #f1f5f9;
}

.info-section-title {
  font-size: 0.8rem;
  font-weight: 700;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.media-thumbs-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.media-thumb-item {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  border: 1px solid #e2e8f0;
}

.media-thumb-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.2s ease;
}

.media-thumb-item:hover img {
  transform: scale(1.1);
}

.members-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.member-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.member-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #cbd5e1;
  color: #1e293b;
  font-weight: 700;
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.member-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: #0f172a;
  flex: 1;
}

/* Lightbox Modal */
.community-lightbox-modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(8px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.lightbox-content {
  max-width: 90vw;
  max-height: 90vh;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 20px 50px rgba(0,0,0,0.5);
  position: relative;
}

.lightbox-content img {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 85vh;
  display: block;
}

.btn-close-lightbox {
  position: absolute;
  top: 16px;
  right: 16px;
  background: rgba(255, 255, 255, 0.2);
  color: #ffffff;
  border: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 1.25rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease;
}

.btn-close-lightbox:hover {
  background: rgba(255, 255, 255, 0.4);
}

/* ==========================================================================
   RESPONSIVE MEDIA QUERIES (OVERRIDE ALL BASELINE PANEL STYLES)
   ========================================================================== */
@media (max-width: 1360px) {
  .community-layout-container {
    grid-template-columns: 240px minmax(0, 1fr);
  }
  .community-info-panel {
    display: none !important;
  }
}

@media (max-width: 768px) {
  .community-layout-container {
    grid-template-columns: 1fr !important;
    height: calc(100vh - 120px) !important;
    max-height: calc(100vh - 120px) !important;
    position: relative !important;
  }

  .community-channels-panel {
    display: flex !important;
    width: 100% !important;
    height: 100% !important;
  }

  /* CRITICAL FIX: Hide chat panel completely unless active-mobile is added */
  .community-chat-panel:not(.active-mobile) {
    display: none !important;
  }

  .community-chat-panel.active-mobile {
    display: flex !important;
    position: absolute !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    z-index: 50 !important;
    background: #ffffff !important;
    animation: mobileSlideIn 0.22s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  }
}

@keyframes mobileSlideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

