/* ============================================================
   SUPPORT & REQUESTS PAGE STYLES
   Premium split-pane messaging UI
   ============================================================ */

/* Page Level Resets for Support Layout */
.support-page-content {
  padding: 0;
  height: calc(100vh - var(--topbar-height));
  display: flex;
  overflow: hidden;
  background: var(--bg);
}

/* ── Split Pane Layout ── */
.support-sidebar {
  width: 380px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  z-index: 10;
}

.support-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-alt);
  min-width: 0;
}

/* ── Left Pane: Header & Search ── */
.support-sidebar-header {
  padding: var(--sp-5) var(--sp-6) var(--sp-4);
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}

.support-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.support-title {
  font-size: 20px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.5px;
}

.new-request-btn {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  background: var(--primary);
  color: white;
  padding: 8px 14px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-fast);
}

.new-request-btn:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

/* Tabs */
.support-tabs {
  display: flex;
  background: var(--bg-alt);
  padding: 4px;
  border-radius: var(--radius-md);
  gap: 4px;
}

.support-tab {
  flex: 1;
  text-align: center;
  padding: 6px 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.support-tab.active {
  background: var(--surface);
  color: var(--text-primary);
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

/* ── Left Pane: Thread List ── */
.thread-list {
  flex: 1;
  overflow-y: auto;
  padding: var(--sp-2);
}

.thread-item {
  display: flex;
  gap: var(--sp-3);
  padding: var(--sp-3);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  margin-bottom: 2px;
  position: relative;
}

.thread-item:hover {
  background: var(--bg-alt);
}

.thread-item.active {
  background: var(--primary-subtle);
}

.thread-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 10px;
  bottom: 10px;
  width: 3px;
  background: var(--primary);
  border-radius: 0 4px 4px 0;
}

.thread-avatar {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--border-strong), var(--border));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-secondary);
  flex-shrink: 0;
  border: 2px solid var(--surface);
  box-shadow: var(--shadow-xs);
  position: relative;
}

.thread-avatar.admin {
  background: linear-gradient(135deg, var(--primary-light), var(--primary));
  color: white;
}

.thread-status-dot {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 12px;
  height: 12px;
  border-radius: var(--radius-full);
  border: 2px solid var(--surface);
}
.dot-open { background: var(--secondary); }
.dot-progress { background: var(--warning); }
.dot-closed { background: var(--text-disabled); }

.thread-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.thread-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

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

.thread-time {
  font-size: 11px;
  color: var(--text-tertiary);
  font-weight: 500;
  flex-shrink: 0;
}

.thread-subject {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.thread-item.unread .thread-name,
.thread-item.unread .thread-subject {
  color: var(--text-primary);
}

.thread-item.unread .thread-preview {
  color: var(--text-secondary);
  font-weight: 500;
}

.unread-badge {
  background: var(--danger);
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: var(--radius-full);
  margin-left: auto;
}

/* ── Right Pane: Chat Area ── */
.chat-header {
  height: 72px;
  padding: 0 var(--sp-6);
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  z-index: 10;
}

.chat-header-info {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
}

.chat-header-text {
  display: flex;
  flex-direction: column;
}

.chat-req-id {
  font-size: 11px;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.chat-req-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}

.chat-actions {
  display: flex;
  gap: var(--sp-2);
}

.chat-action-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.chat-action-btn:hover {
  background: var(--bg-alt);
  color: var(--text-primary);
}

/* Message Area */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: var(--sp-6);
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
  background: var(--bg-alt);
}

.chat-date-divider {
  display: flex;
  align-items: center;
  text-align: center;
  margin: var(--sp-4) 0;
}

.chat-date-divider::before,
.chat-date-divider::after {
  content: '';
  flex: 1;
  border-bottom: 1px solid var(--border);
}

.chat-date-divider span {
  padding: 0 var(--sp-4);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Bubbles */
.message-row {
  display: flex;
  align-items: flex-end;
  gap: var(--sp-3);
  max-width: 80%;
}

.message-row.outgoing {
  margin-left: auto;
  flex-direction: row-reverse;
}

.message-avatar {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  background: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  flex-shrink: 0;
}

.message-avatar.user {
  background: linear-gradient(135deg, var(--secondary), var(--secondary-light));
}

.message-content {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.message-bubble {
  background: var(--surface);
  padding: var(--sp-3) var(--sp-4);
  border-radius: 16px 16px 16px 4px;
  font-size: 14px;
  color: var(--text-primary);
  line-height: 1.5;
  box-shadow: var(--shadow-xs);
  border: 1px solid var(--border);
}

.message-row.outgoing .message-bubble {
  background: var(--primary);
  color: white;
  border-radius: 16px 16px 4px 16px;
  border-color: var(--primary);
}

.message-meta {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 2px;
  display: flex;
  gap: var(--sp-2);
}

.message-row.outgoing .message-meta {
  justify-content: flex-end;
}

/* Attachments in chat */
.message-attachment {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  background: var(--bg-alt);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--radius-md);
  margin-top: var(--sp-2);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.message-row.outgoing .message-attachment {
  background: rgba(255,255,255,0.1);
  border-color: rgba(255,255,255,0.2);
  color: white;
}

.message-attachment:hover {
  background: var(--border);
}

.message-row.outgoing .message-attachment:hover {
  background: rgba(255,255,255,0.15);
}

.attachment-icon {
  width: 32px;
  height: 32px;
  background: var(--surface);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--danger);
}

.message-row.outgoing .attachment-icon {
  color: var(--primary);
}

.attachment-info {
  display: flex;
  flex-direction: column;
}

.attachment-name {
  font-size: 13px;
  font-weight: 600;
}

.attachment-size {
  font-size: 11px;
  opacity: 0.7;
}

/* ── Chat Input ── */
.chat-input-area {
  padding: var(--sp-4) var(--sp-6);
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: flex-end;
  gap: var(--sp-3);
  z-index: 10;
}

.chat-input-wrapper {
  flex: 1;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  transition: all var(--transition-fast);
}

.chat-input-wrapper:focus-within {
  border-color: var(--primary);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--primary-muted);
}

.chat-input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 14px;
  color: var(--text-primary);
  resize: none;
  max-height: 120px;
  outline: none;
  font-family: inherit;
  padding: 0;
  line-height: 1.5;
}

.chat-input::placeholder {
  color: var(--text-tertiary);
}

.chat-attach-btn {
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px;
  border-radius: 50%;
  transition: all var(--transition-fast);
}

.chat-attach-btn:hover {
  color: var(--primary);
  background: var(--primary-subtle);
}

.chat-send-btn {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-full);
  background: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}

.chat-send-btn:hover {
  background: var(--primary-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

/* ── New Request Modal overrides if necessary ── */
.file-drop-area {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-md);
  padding: var(--sp-6);
  text-align: center;
  background: var(--bg-alt);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.file-drop-area:hover {
  border-color: var(--primary);
  background: var(--primary-subtle);
}

.file-drop-icon {
  color: var(--primary);
  margin-bottom: var(--sp-2);
}

.file-drop-text {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
}

/* ── Responsive adjustments ── */
@media (max-width: 992px) {
  .support-sidebar {
    width: 320px;
  }
}

@media (max-width: 768px) {
  .support-page-content {
    flex-direction: column;
  }
  .support-sidebar {
    width: 100%;
    height: 40vh;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .support-main {
    height: 60vh;
  }
}
