/* ===== Support / Ticket System Styles ===== */

/* ── Ticket Cards ── */
.ticket-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 12px;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}
.ticket-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 1px;
  background: linear-gradient(90deg, transparent, var(--rgba-6-182-212-0-3), transparent);
  opacity: 0; transition: opacity var(--transition);
}
.ticket-card:hover { border-color: var(--border-light); transform: translateY(-2px); box-shadow: 0 8px 32px var(--rgba-0-0-0-0-3); }
.ticket-card:hover::before { opacity: 1; }
.ticket-card.ticket-unread { border-left: 3px solid var(--primary); }
.ticket-card-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.ticket-subject { font-size: 14px; font-weight: 600; color: var(--text); display: flex; align-items: center; gap: 8px; }
.ticket-card-meta { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12px; color: var(--text-muted); }
.ticket-card-meta span { display: flex; align-items: center; gap: 5px; }
.unread-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--primary); flex-shrink: 0;
  box-shadow: 0 0 8px var(--rgba-6-182-212-0-6);
  animation: pulse-dot 1.5s ease-in-out infinite;
}
@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(0.85); }
}

/* ── Chat Layout ── */
.chat-layout {
  display: flex;
  flex-direction: column;
  height: calc(100vh - var(--header-height) - 70px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
  flex-shrink: 0;
  flex-wrap: wrap;
}
.chat-header-info { flex: 1; min-width: 0; }
.chat-title { font-size: 15px; font-weight: 700; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-meta { display: flex; align-items: center; gap: 8px; margin-top: 4px; flex-wrap: wrap; }
.chat-header-actions { display: flex; gap: 8px; }

/* ── Messages ── */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-behavior: smooth;
}

.msg-row {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  max-width: 80%;
}
.msg-mine { align-self: flex-end; flex-direction: row-reverse; }
.msg-theirs { align-self: flex-start; }

.msg-avatar { flex-shrink: 0; }
.msg-avatar-img { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; }
.msg-avatar-placeholder {
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: var(--hex-fff);
}

.msg-bubble-wrap { display: flex; flex-direction: column; gap: 4px; max-width: 100%; }
.msg-mine .msg-bubble-wrap { align-items: flex-end; }
.msg-theirs .msg-bubble-wrap { align-items: flex-start; }

.msg-sender-name { font-size: 11px; color: var(--text-muted); font-weight: 600; display: flex; align-items: center; gap: 5px; }

.msg-bubble {
  padding: 10px 14px;
  border-radius: 16px;
  max-width: 100%;
  word-break: break-word;
  position: relative;
}
.msg-bubble-mine {
  background: linear-gradient(135deg, var(--primary), var(--primary-dim));
  color: var(--hex-fff);
  border-bottom-right-radius: 4px;
  box-shadow: 0 4px 16px var(--rgba-6-182-212-0-3);
}
.msg-bubble-theirs {
  background: var(--surface3);
  border: 1px solid var(--border);
  color: var(--text);
  border-bottom-left-radius: 4px;
}
.msg-text { font-size: 14px; line-height: 1.6; }
.msg-time { font-size: 11px; color: var(--text-muted); }

/* ── Attachments in messages ── */
.msg-attachments { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }
.attach-item { border-radius: var(--radius-xs); overflow: hidden; }
.attach-image { max-width: 280px; max-height: 200px; border-radius: var(--radius-xs); display: block; cursor: pointer; transition: opacity var(--transition); }
.attach-image:hover { opacity: 0.9; }
.attach-video { max-width: 280px; max-height: 200px; border-radius: var(--radius-xs); display: block; background: var(--hex-000); }
.attach-audio-wrap { background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius-xs); padding: 10px 14px; }
.attach-audio-label { font-size: 12px; color: var(--text-muted); margin-bottom: 6px; display: flex; align-items: center; gap: 6px; }
.attach-audio { width: 240px; height: 36px; }
.attach-file { display: flex; align-items: center; gap: 8px; font-size: 13px; padding: 8px 12px; background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius-xs); }
.attach-file a { color: var(--primary); }

/* ── Chat Input Area ── */
.chat-input-area {
  border-top: 1px solid var(--border);
  padding: 14px 16px;
  background: var(--surface2);
  flex-shrink: 0;
}

.attachment-previews {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}
.attach-preview-item {
  position: relative;
  width: 72px; height: 72px;
  border-radius: var(--radius-xs);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface3);
  flex-shrink: 0;
}
.attach-preview-img { width: 100%; height: 100%; object-fit: cover; }
.attach-preview-icon {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; color: var(--primary);
}
.attach-preview-remove {
  position: absolute; top: 3px; right: 3px;
  width: 20px; height: 20px;
  background: var(--rgba-0-0-0-0-75); border: none;
  border-radius: 50%; color: var(--hex-fff); font-size: 10px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: background var(--transition);
}
.attach-preview-remove:hover { background: var(--danger); }

.chat-input-row {
  display: flex;
  align-items: flex-end;
  gap: 10px;
}
.chat-input-actions { display: flex; flex-direction: row; gap: 6px; flex-shrink: 0; }
.chat-attach-btn {
  width: 36px; height: 36px;
  background: var(--surface3); border: 1px solid var(--border);
  border-radius: var(--radius-xs); color: var(--text-secondary);
  font-size: 14px; display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: all var(--transition);
}
.chat-attach-btn:hover { background: var(--surface4); color: var(--primary); border-color: var(--border-light); }

.chat-textarea {
  flex: 1;
  background: var(--surface3);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  resize: none;
  outline: none;
  min-height: 40px;
  max-height: 140px;
  line-height: 1.5;
  transition: border-color var(--transition), box-shadow var(--transition);
  font-family: inherit;
}
.chat-textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow-sm);
}
.chat-textarea::placeholder { color: var(--text-muted); }

.chat-send-btn {
  width: 40px; height: 40px;
  padding: 0;
  border-radius: var(--radius-xs);
  justify-content: center;
  flex-shrink: 0;
}

/* ── Voice Recording UI ── */
.voice-recording-ui {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--rgba-248-113-113-0-06);
  border: 1px solid var(--rgba-248-113-113-0-2);
  border-radius: var(--radius-sm);
  margin-top: 10px;
  gap: 12px;
  flex-wrap: wrap;
}
.voice-rec-indicator { display: flex; align-items: center; gap: 10px; }
.voice-rec-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--danger);
  animation: pulse-dot 0.8s ease-in-out infinite;
}


.chat-topbar {
  margin-bottom: 12px;
  display: flex;
  align-items: center;
}

/* ── Closed Ticket Notice ── */
.chat-closed-notice {
  display: flex; align-items: center; justify-content: center;
  gap: 12px; padding: 16px;
  color: var(--text-muted); font-size: 14px;
  flex-wrap: wrap;
}

/* ── Admin Support Tab ── */
.support-split {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 0;
  height: calc(100vh - var(--header-height) - 48px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.support-split-admin-client {
    display: grid;
  grid-template-columns: 340px 1fr;
  gap: 0;
  height: calc(100vh - var(--header-height) - 140px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.support-ticket-list {
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.support-ticket-list-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
  flex-shrink: 0;
}
.support-ticket-list-header .card-title { margin-bottom: 10px; }
.support-ticket-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}
.admin-ticket-item {
  padding: 12px 14px;
  border-radius: var(--radius-xs);
  cursor: pointer;
  transition: all var(--transition);
  border: 1px solid transparent;
  margin-bottom: 4px;
}
.admin-ticket-item:hover { background: var(--surface2); border-color: var(--border); }
.admin-ticket-item.active { background: var(--rgba-6-182-212-0-08); border-color: var(--rgba-6-182-212-0-25); }
.admin-ticket-item.has-unread { border-left: 3px solid var(--primary); }
.admin-ticket-title { font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.admin-ticket-meta { font-size: 11px; color: var(--text-muted); margin-top: 4px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.support-chat-panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.support-empty-panel {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── Admin ticket filter bar ── */
.support-filter-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 0 0 10px;
}
.support-filter-bar .filter-select { font-size: 12px; padding: 6px 10px; }

/* ── Responsive ── */
@media (max-width: 900px) {
  .support-split { grid-template-columns: 1fr; }
  .support-split-admin-client { grid-template-columns: 1fr;}
  .support-ticket-list { height: 300px; border-right: none; border-bottom: 1px solid var(--border); }
}
@media (max-width: 768px) {
  .chat-layout { height: calc(100vh - var(--header-height) - 32px); }
  .msg-row { max-width: 95%; }
  .attach-image, .attach-video { max-width: 200px; }
}

/* ===== LIGHT MODE SUPPORT OVERRIDES ===== */
html[data-theme="light"] .ticket-card {
  background: var(--hex-ffffff);
  border-color: var(--rgba-8-145-178-0-13);
}
html[data-theme="light"] .ticket-card:hover {
  border-color: var(--rgba-8-145-178-0-28);
  box-shadow: 0 8px 32px var(--rgba-8-51-68-0-08);
}
html[data-theme="light"] .ticket-card.ticket-unread { border-left-color: var(--hex-0891b2); }
html[data-theme="light"] .ticket-subject { color: var(--hex-083344); }
html[data-theme="light"] .ticket-card-meta { color: var(--rgba-8-145-178-0-55); }
html[data-theme="light"] .unread-dot { background: var(--hex-0891b2); box-shadow: 0 0 8px var(--rgba-8-145-178-0-5); }

html[data-theme="light"] .chat-layout {
  background: var(--hex-ffffff);
  border-color: var(--rgba-8-145-178-0-13);
}
html[data-theme="light"] .chat-header {
  background: var(--rgba-8-145-178-0-04);
  border-bottom-color: var(--rgba-8-145-178-0-12);
}
html[data-theme="light"] .chat-title { color: var(--hex-083344); }
html[data-theme="light"] .chat-input-area {
  background: var(--rgba-8-145-178-0-04);
  border-top-color: var(--rgba-8-145-178-0-12);
}
html[data-theme="light"] .chat-textarea {
  background: var(--hex-ffffff);
  border-color: var(--rgba-8-145-178-0-18);
  color: var(--hex-083344);
}
html[data-theme="light"] .chat-textarea:focus {
  border-color: var(--rgba-8-145-178-0-5);
  box-shadow: 0 0 0 3px var(--rgba-8-145-178-0-1);
}
html[data-theme="light"] .chat-textarea::placeholder { color: var(--rgba-8-145-178-0-38); }
html[data-theme="light"] .msg-bubble-theirs {
  background: var(--rgba-8-145-178-0-06);
  border-color: var(--rgba-8-145-178-0-15);
  color: var(--hex-083344);
}
html[data-theme="light"] .msg-text { color: inherit; }
html[data-theme="light"] .msg-time { color: var(--rgba-8-145-178-0-5); }
html[data-theme="light"] .msg-sender-name { color: var(--rgba-8-145-178-0-55); }
html[data-theme="light"] .chat-attach-btn {
  background: var(--rgba-8-145-178-0-06);
  border-color: var(--rgba-8-145-178-0-15);
  color: var(--rgba-8-51-68-0-6);
}
html[data-theme="light"] .chat-attach-btn:hover {
  background: var(--rgba-8-145-178-0-12);
  color: var(--hex-0891b2);
  border-color: var(--rgba-8-145-178-0-28);
}
html[data-theme="light"] .attach-file {
  background: var(--rgba-8-145-178-0-05);
  border-color: var(--rgba-8-145-178-0-15);
  color: var(--hex-2e6a7a);
}
html[data-theme="light"] .attach-audio-wrap {
  background: var(--rgba-8-145-178-0-05);
  border-color: var(--rgba-8-145-178-0-15);
}
html[data-theme="light"] .attach-audio-label { color: var(--rgba-8-145-178-0-6); }
html[data-theme="light"] .attach-preview-item {
  background: var(--rgba-8-145-178-0-06);
  border-color: var(--rgba-8-145-178-0-15);
}
html[data-theme="light"] .attachment-previews { border-bottom-color: var(--rgba-8-145-178-0-12); }

html[data-theme="light"] .support-split, html[data-theme="light"] .support-split-admin-client {
  background: var(--hex-ffffff);
  border-color: var(--rgba-8-145-178-0-13);
}
html[data-theme="light"] .support-ticket-list { border-right-color: var(--rgba-8-145-178-0-12); }
html[data-theme="light"] .support-ticket-list-header {
  background: var(--rgba-8-145-178-0-04);
  border-bottom-color: var(--rgba-8-145-178-0-12);
}
html[data-theme="light"] .admin-ticket-item:hover {
  background: var(--rgba-8-145-178-0-05);
  border-color: var(--rgba-8-145-178-0-15);
}
html[data-theme="light"] .admin-ticket-item.active {
  background: var(--rgba-8-145-178-0-08);
  border-color: var(--rgba-8-145-178-0-25);
}
html[data-theme="light"] .admin-ticket-item.has-unread { border-left-color: var(--hex-0891b2); }
html[data-theme="light"] .admin-ticket-title { color: var(--hex-083344); }
html[data-theme="light"] .admin-ticket-meta { color: var(--rgba-8-145-178-0-55); }
html[data-theme="light"] .support-empty-panel { background: var(--hex-ffffff); }
html[data-theme="light"] .chat-closed-notice { color: var(--rgba-8-145-178-0-55); }
html[data-theme="light"] .voice-recording-ui {
  background: var(--rgba-220-38-38-0-05);
  border-color: var(--rgba-220-38-38-0-18);
}