/* === CHAT PAGE === */

/* When chat is active: compact layout, no scroll */
body.chat-page-active .main-content {
  overflow: hidden !important;
  padding: 12px 20px !important;
}

/* Chat page as flex column to fill height */
#page-chat.active {
  display: flex !important;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* Chat page header — dark glass panel */
#page-chat .section-header {
  padding: 16px 20px;
  margin-bottom: 8px;
  background: rgba(0, 0, 0, 0.2) !important;
  backdrop-filter: blur(10px) !important;
  -webkit-backdrop-filter: blur(10px) !important;
  border-color: rgba(255, 255, 255, 0.15) !important;
  border-radius: 18px !important;
}
#page-chat .section-header h1 {
  font-size: 28px;
  margin-bottom: 6px;
}
#page-chat .section-header p {
  font-size: 15px;
  font-family: var(--font-small);
  line-height: 1.55;
}

.chat-layout {
  display: flex;
  gap: 11px;
  flex: 1;
  min-height: 0;
  height: 0;
}

/* Contacts panel — dark glass */
.chat-contacts {
  width: 280px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  padding: 10px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.35) !important;
  backdrop-filter: blur(20px) !important;
  -webkit-backdrop-filter: blur(20px) !important;
  border: 1px solid rgba(255, 255, 255, 0.12) !important;
  border-radius: 16px !important;
}
.contacts-search {
  margin-bottom: 12px;
}
.contacts-search-input {
  width: 100%;
  padding: 8px 12px;
  background: rgba(217, 217, 217, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  color: var(--text-primary);
  font-size: 13px;
  font-family: var(--font-small);
}
.contacts-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Contact items — bigger like mockup */
.contact-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 16px;
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: var(--transition);
}
.contact-item:hover { background: var(--bg-glass-hover); }
.contact-item.active { background: var(--bg-glass-active); }

.contact-avatar-wrapper {
  position: relative;
  flex-shrink: 0;
}
.contact-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  object-fit: cover;
}
.contact-online-dot {
  position: absolute;
  bottom: 3px; right: 3px;
  width: 14px; height: 14px;
  background: var(--online-color);
  border-radius: 50%;
  border: 2.5px solid var(--bg-primary);
}
.contact-info { flex: 1; min-width: 0; }
.contact-name {
  font-size: 17px;
  font-weight: 400;
  margin-bottom: 3px;
  font-family: var(--font-main);
}
/* Figma: 12.368px Montserrat */
.contact-last-msg {
  font-size: 14px;
  font-family: var(--font-small);
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Chat Window — dark glass */
.chat-window {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.35) !important;
  backdrop-filter: blur(20px) !important;
  -webkit-backdrop-filter: blur(20px) !important;
  border: 1px solid rgba(255, 255, 255, 0.12) !important;
  border-radius: 16px !important;
}
.chat-window-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 16px;
}
.chat-header-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}
.chat-header-name {
  font-size: 18px;
  font-weight: 400;
  font-family: var(--font-main);
}
.chat-header-status {
  font-size: 14px;
  font-family: var(--font-small);
}
.chat-placeholder-text {
  color: var(--text-muted);
  font-size: 16px;
  font-family: var(--font-small);
}
.chat-window .chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
}
/* Figma: input bar bg rgba(217,217,217,0.48), border white, rounded 26px, h 52px */
.chat-window .chat-input-bar {
  padding: 10px 16px;
  border-top: none;
}
.chat-window .chat-input-bar .chat-input {
  background: rgba(217, 217, 217, 0.3);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 20px;
  height: 40px;
  padding: 0 14px;
  font-size: 13px;
  font-family: var(--font-small);
  color: #ffffff;
}

/* Typing indicator */
.typing-indicator {
  font-size: 12px;
  font-family: var(--font-small);
  color: var(--text-muted);
  font-style: italic;
  padding: 4px 0;
}

/* Clickable images in chat */
.chat-msg-image img {
  cursor: pointer;
  transition: opacity 0.2s;
}
.chat-msg-image img:hover {
  opacity: 0.85;
}

/* === Image Lightbox === */
.chat-lightbox {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.lightbox-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.lightbox-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  max-height: 95vh;
}
#chat-lightbox .lightbox-content img#lightbox-img {
  max-width: 85vw !important;
  max-height: 75vh !important;
  min-width: 250px !important;
  object-fit: contain !important;
  border-radius: 12px !important;
  box-shadow: 0 20px 80px rgba(0, 0, 0, 0.6) !important;
  width: auto !important;
  height: auto !important;
  min-height: auto !important;
}
#chat-lightbox .lightbox-close {
  position: static !important;
  width: 36px !important;
  height: 36px !important;
  border-radius: 50% !important;
  background: rgba(255, 255, 255, 0.15) !important;
  border: 1px solid rgba(255, 255, 255, 0.2) !important;
  color: #fff !important;
  font-size: 22px !important;
  cursor: pointer;
  display: flex !important;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  backdrop-filter: blur(8px);
  z-index: 10001 !important;
  align-self: flex-end;
  margin-bottom: -10px;
}
#chat-lightbox .lightbox-close:hover {
  background: rgba(255, 255, 255, 0.3) !important;
  transform: scale(1.1);
}
#chat-lightbox .lightbox-download {
  padding: 10px 24px;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  transition: all 0.2s;
  backdrop-filter: blur(8px);
  z-index: 10001;
  position: static !important;
  transform: none !important;
}
#chat-lightbox .lightbox-download:hover {
  background: rgba(255, 255, 255, 0.25);
}

/* === Light theme: force white text in chat === */
[data-theme="light"] #page-chat .section-header h1,
[data-theme="light"] #page-chat .section-header p {
  color: #fff !important;
}
[data-theme="light"] .contacts-search-input {
  color: #fff !important;
}
[data-theme="light"] .contacts-search-input::placeholder {
  color: rgba(255, 255, 255, 0.5) !important;
}
[data-theme="light"] .contact-name {
  color: #fff !important;
}
[data-theme="light"] .contact-last-msg {
  color: rgba(255, 255, 255, 0.55) !important;
}
[data-theme="light"] .chat-placeholder-text {
  color: rgba(255, 255, 255, 0.5) !important;
}
[data-theme="light"] .chat-header-name {
  color: #fff !important;
}
[data-theme="light"] .chat-header-status {
  color: rgba(255, 255, 255, 0.6) !important;
}
[data-theme="light"] .chat-window .chat-input-bar .chat-input {
  color: #fff !important;
}
[data-theme="light"] .chat-window .chat-input-bar .chat-input::placeholder {
  color: rgba(255, 255, 255, 0.45) !important;
}
[data-theme="light"] #page-chat .chat-msg-text {
  color: #fff !important;
}
[data-theme="light"] #page-chat .chat-msg-name {
  color: rgba(255, 255, 255, 0.7) !important;
}
[data-theme="light"] #page-chat .chat-msg-time {
  color: rgba(255, 255, 255, 0.45) !important;
}

@media (max-width: 768px) {
  .chat-layout { flex-direction: column; height: auto; }
  .chat-contacts { width: 100%; max-height: 250px; }
}
