/* Inbox / Atendimento Styles - Cyber Glass Premium */

.inbox-container {
  display: flex;
  height: calc(100vh - 160px);
  overflow: hidden;
  padding: 0;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-glass);
  background: var(--bg-card);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  box-shadow: var(--shadow-glass);
  position: relative;
}

.inbox-container::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--neon-purple), var(--neon-cyan), transparent);
  opacity: 0.6;
}

/* SIDEBAR - CONVERSATION LIST */
.inbox-sidebar {
  width: 320px;
  border-right: 1px solid var(--border-glass);
  display: flex;
  flex-direction: column;
  background: var(--bg-sidebar);
}

.inbox-header {
  padding: 24px 20px 16px;
  background: transparent;
}

.inbox-filters {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.inbox-filters select {
  appearance: none;
  background: var(--surface2);
  border: 1px solid var(--border-glass);
  font-size: 12px;
  font-weight: 500;
  padding: 8px 14px;
  border-radius: 99px;
  color: var(--text);
  cursor: pointer;
  outline: none;
  transition: all var(--transition-fast);
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239B97C8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 14px;
}

.inbox-filters select:hover,
.inbox-filters select:focus {
  background: var(--surface);
  border-color: var(--neon-cyan);
  box-shadow: 0 0 0 2px rgba(0, 245, 255, 0.1);
}

.inbox-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 12px 12px 12px;
}

/* Scrollbar handled by style.css globally, but we can refine here if needed */

.inbox-item {
  padding: 12px 14px;
  margin-bottom: 4px;
  border-radius: var(--radius);
  cursor: pointer;
  display: flex;
  gap: 12px;
  transition: all var(--transition-fast);
  background: transparent;
  border: 1px solid transparent;
  position: relative;
  overflow: hidden;
}

.inbox-item:hover {
  background: var(--surface2);
  border-color: rgba(155, 77, 255, 0.2);
  box-shadow: var(--shadow-sm);
}

.inbox-item.active {
  background: linear-gradient(90deg, rgba(155, 77, 255, 0.15), rgba(0, 245, 255, 0.05));
  border-color: var(--border-glass);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.inbox-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: linear-gradient(180deg, var(--neon-purple), var(--neon-cyan));
  border-radius: 0 3px 3px 0;
}

.inbox-item-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--neon-purple), var(--neon-cyan));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 15px;
  flex-shrink: 0;
  object-fit: cover;
  box-shadow: var(--glow-purple);
}

.inbox-item-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

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

.inbox-item-header strong {
  font-size: 14px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 600;
}

.inbox-item-header small {
  font-size: 11px;
  color: var(--neon-cyan);
}

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

/* MAIN CHAT AREA */
.inbox-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: transparent;
  /* inherits .inbox-container bg-card */
  position: relative;
}

.inbox-chat-header {
  padding: 20px 30px;
  border-bottom: 1px solid var(--border-glass);
  background: var(--surface2);
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 10;
}

.inbox-chat-messages {
  flex: 1;
  padding: 30px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
  background: rgba(3, 0, 20, 0.4);
}

.msg-row {
  display: flex;
  width: 100%;
}

.msg-row.left {
  justify-content: flex-start;
}

.msg-row.right {
  justify-content: flex-end;
}

.msg-bubble {
  max-width: 60%;
  padding: 14px 18px;
  border-radius: 20px;
  position: relative;
  font-size: 14px;
  line-height: 1.5;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-glass);
  backdrop-filter: blur(8px);
}

/* Client messages (left) */
.msg-in {
  background: var(--surface2);
  color: var(--text);
  border-bottom-left-radius: 4px;
}

/* Bot messages (right) */
.msg-bot {
  background: rgba(155, 77, 255, 0.15);
  color: var(--text);
  border-bottom-right-radius: 4px;
  border-color: rgba(155, 77, 255, 0.3);
}

/* Operator messages (right) */
.msg-op {
  background: linear-gradient(135deg, var(--neon-purple), #5B10C8);
  color: #fff;
  border-bottom-right-radius: 4px;
  border-color: transparent;
  box-shadow: var(--glow-purple);
}

.msg-op .msg-time,
.msg-op .msg-sender {
  color: rgba(255, 255, 255, 0.7);
}

.msg-sender {
  display: none;
}

.msg-text {
  word-wrap: break-word;
  white-space: pre-wrap;
}

.msg-time {
  font-size: 10px;
  color: var(--text-muted);
  text-align: right;
  margin-top: 6px;
  opacity: 0.8;
}

.msg-op .msg-time {
  color: rgba(255, 255, 255, 0.8);
}

/* Chat avatar beside bubbles */
.msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--surface2), rgba(155, 77, 255, 0.2));
  margin-right: 12px;
  align-self: flex-end;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: var(--text2);
  border: 1px solid var(--border-glass);
}

.msg-row.right .msg-avatar {
  margin-right: 0;
  margin-left: 12px;
}

.msg-sys {
  text-align: center;
  margin: 16px 0;
}

.msg-sys span {
  display: inline-block;
  background: rgba(0, 245, 255, 0.08);
  color: var(--neon-cyan);
  font-size: 11px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 99px;
  border: 1px solid rgba(0, 245, 255, 0.2);
  box-shadow: 0 0 10px rgba(0, 245, 255, 0.1);
}

/* CHAT COMPOSER */
.inbox-chat-composer {
  padding: 20px 30px;
  background: var(--surface2);
  border-top: 1px solid var(--border-glass);
  display: flex;
  gap: 12px;
  align-items: center;
}

.inbox-chat-composer input {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border-glass);
  padding: 14px 20px;
  border-radius: 99px;
  color: var(--text);
  font-size: 14px;
  transition: all var(--transition-fast);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.inbox-chat-composer input:focus {
  border-color: var(--neon-cyan);
  background: var(--surface2);
  outline: none;
  box-shadow: 0 0 0 2px rgba(0, 245, 255, 0.1), var(--glow-cyan);
}

.inbox-chat-composer input::placeholder {
  color: var(--text-muted);
}

.inbox-chat-composer input:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Send Button styled as icon pill */
.inbox-chat-composer button {
  border-radius: 99px;
  padding: 0 24px;
  height: 48px;
  font-weight: 600;
  background: linear-gradient(135deg, var(--neon-purple), var(--neon-cyan));
  background-size: 200% 200%;
  animation: bgPulse 4s ease infinite;
  color: white;
  border: none;
  cursor: pointer;
  transition: all var(--transition-fast);
  box-shadow: var(--glow-purple);
}

.inbox-chat-composer button:hover {
  transform: translateY(-2px);
  box-shadow: var(--glow-cyan), var(--glow-purple);
}

.inbox-chat-composer button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  animation: none;
  background: var(--surface3);
  box-shadow: none;
}

/* ── MEDIA MESSAGES ─────────────────────────────────────────────────────── */

/* Shared media wrapper */
.msg-media {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 100%;
}

/* Inline image */
.msg-img {
  max-width: 260px;
  max-height: 260px;
  width: 100%;
  border-radius: 12px;
  object-fit: cover;
  cursor: zoom-in;
  display: block;
  transition: opacity var(--transition-fast);
  border: 1px solid var(--border-glass);
}

.msg-img:hover {
  opacity: 0.88;
  border-color: var(--neon-cyan);
}

/* Video */
.msg-video {
  max-width: 280px;
  border-radius: 12px;
  display: block;
  border: 1px solid var(--border-glass);
}

/* Caption below image / video */
.msg-caption {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

.msg-op .msg-caption {
  color: rgba(255, 255, 255, 0.9);
}

/* Audio player */
.msg-audio {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
}

.msg-audio-icon {
  flex-shrink: 0;
  color: var(--neon-cyan);
}

.msg-op .msg-audio-icon {
  color: white;
}

.msg-audio-player {
  height: 36px;
  min-width: 180px;
  max-width: 240px;
  border-radius: 99px;
  accent-color: var(--neon-cyan);
  outline: none;
}

/* Document link */
.msg-document {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.msg-document svg {
  flex-shrink: 0;
  color: var(--neon-purple);
}

.msg-op .msg-document svg {
  color: white;
}

.msg-doc-link {
  color: var(--neon-cyan);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  word-break: break-all;
}

.msg-op .msg-doc-link {
  color: white;
  text-decoration: underline;
}

.msg-doc-link:hover {
  text-decoration: underline;
}

/* Placeholder when media url is missing */
.msg-media-placeholder {
  opacity: 0.65;
  font-style: italic;
  color: var(--text-muted);
}

/* ── LIGHTBOX ─────────────────────────────────────────────────────────────── */
.media-lightbox {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(3, 0, 20, 0.85);
  backdrop-filter: blur(12px);
  cursor: zoom-out;
}

.lightbox-img {
  position: relative;
  max-width: 90vw;
  max-height: 90vh;
  border-radius: 16px;
  object-fit: contain;
  box-shadow: var(--shadow-md), var(--glow-purple);
  z-index: 1;
  border: 1px solid var(--border-glass);
}

.lightbox-close {
  position: absolute;
  top: 20px;
  right: 24px;
  background: var(--surface2);
  border: 1px solid var(--border-glass);
  color: var(--text);
  font-size: 28px;
  line-height: 1;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  transition: all var(--transition-fast);
}

.lightbox-close:hover {
  background: rgba(255, 51, 102, 0.15);
  color: var(--red);
  border-color: rgba(255, 51, 102, 0.3);
  box-shadow: 0 0 15px rgba(255, 51, 102, 0.3);
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .inbox-sidebar {
    width: 100%;
    border-right: none;
  }

  .inbox-main {
    display: none;
  }

  /* On mobile, main is hidden until a chat is opened, controlled by JS if implemented */
}

.msg-feedback-btn {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 4px;
}

.msg-feedback-btn:hover {
  background: var(--neon-purple);
  border-color: var(--neon-purple);
  box-shadow: 0 0 10px var(--neon-purple);
}