/** @format */

:root {
  font-family: Inter, system-ui, sans-serif;
  --bg-1: #eef3ff;
  --bg-2: #f7f9ff;
  --panel: #ffffff;
  --text-main: #111827;
  --text-muted: #6b7280;
  --primary: #2563eb;
  --primary-soft: #dbeafe;
  --border: #e5e7eb;
  --success-soft: #dcfce7;
}

body {
  margin: 0;
  background: radial-gradient(circle at top left, var(--bg-1), var(--bg-2));
  color: var(--text-main);
}

.app {
  max-width: 1240px;
  margin: 20px auto;
  padding: 0 12px;
}

.card {
  background: var(--panel);
  border-radius: 16px;
  box-shadow: 0 10px 26px rgba(37, 99, 235, 0.09);
  border: 1px solid rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(4px);
}

.hidden {
  display: none !important;
}

.auth {
  max-width: 400px;
  margin: 80px auto;
  padding: 24px;
}

.auth h1 {
  margin: 0 0 6px;
}

.auth p {
  margin-top: 0;
}

input,
textarea,
button {
  font: inherit;
}

input,
textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 11px 12px;
  margin-bottom: 8px;
  border-radius: 10px;
  border: 1px solid #d1d5db;
  background: #fff;
  transition: all 0.2s ease;
}

input:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

button {
  border: 0;
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
  background: var(--primary);
  color: #fff;
  transition:
    transform 0.12s ease,
    box-shadow 0.2s ease,
    background 0.2s ease;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 16px rgba(37, 99, 235, 0.24);
}

button.secondary {
  background: #6b7280;
}

button.danger {
  background: #b91c1c;
}

button.ghost {
  background: #e5edff;
  color: #1d4ed8;
}

.row {
  display: flex;
  gap: 8px;
}

.chat {
  display: grid;
  grid-template-columns: 350px 1fr;
  gap: 14px;
}

.sidebar,
.dialog {
  padding: 14px;
  min-height: 82vh;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-bottom: 10px;
}

.tab {
  background: #eef2ff;
  color: #111827;
  font-weight: 600;
}

.tab.active {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #fff;
}

.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  gap: 6px;
  padding: 8px;
  border-radius: 10px;
  background: #f8faff;
}

.actions-wrap {
  margin-bottom: 8px;
}

.actions-wrap button {
  width: 100%;
}

.results,
.conversations,
.chips {
  border: 1px solid var(--border);
  border-radius: 10px;
  max-height: 170px;
  overflow-y: auto;
  padding: 6px;
  background: #fafcff;
  margin-bottom: 8px;
}

.chips {
  max-height: 110px;
}

.conversations {
  max-height: 45vh;
}

.search-item,
.conv-item {
  padding: 8px;
  border-radius: 8px;
  margin-bottom: 6px;
  background: #eef2ff;
  border: 1px solid rgba(99, 102, 241, 0.08);
}

.conv-item {
  cursor: pointer;
}

.search-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: 999px;
  background: #e0e7ff;
  margin: 3px;
  font-size: 12px;
}

.chip button {
  background: transparent;
  color: #374151;
  padding: 0;
}

.conv-item.active {
  background: var(--primary-soft);
  border-color: rgba(37, 99, 235, 0.28);
}

.conv-item .muted {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dialog-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
}

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

.badge {
  background: #e5e7eb;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 600;
}

.messages {
  height: 54vh;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  background: linear-gradient(180deg, #fbfdff, #f8fbff);
}

.msg {
  background: #edf2ff;
  border-radius: 12px;
  padding: 9px;
  margin-bottom: 8px;
  border: 1px solid rgba(37, 99, 235, 0.1);
}

.msg.my {
  background: var(--success-soft);
  border-color: rgba(16, 185, 129, 0.18);
}

.msg .meta {
  font-size: 12px;
  color: #4b5563;
  margin-bottom: 4px;
}

.msg img,
.msg video,
.media-preview img,
.media-preview video {
  max-width: 320px;
  border-radius: 8px;
  display: block;
  margin-top: 8px;
}

.composer {
  margin-top: 8px;
  background: #f8faff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px;
}

.composer textarea {
  min-height: 70px;
}

.composer-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.media-preview {
  border: 1px dashed #cbd5e1;
  border-radius: 10px;
  padding: 8px;
  margin-bottom: 8px;
  background: #fff;
}

.support-btn {
  width: 100%;
  margin-top: 10px;
}

.support-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.support-actions button {
  background: #f59e0b;
  color: #111827;
  padding: 6px 8px;
  font-size: 12px;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 40;
}

.modal-card {
  width: min(560px, 92vw);
  background: #fff;
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 24px 48px rgba(15, 23, 42, 0.28);
}

.avatar {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  object-fit: cover;
  background: #dbeafe;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  color: #1e3a8a;
}

.muted {
  color: var(--text-muted);
  font-size: 13px;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(100, 116, 139, 0.38);
  border-radius: 999px;
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

@media (max-width: 980px) {
  .chat {
    grid-template-columns: 1fr;
  }

  .sidebar,
  .dialog {
    min-height: auto;
  }

  .messages {
    height: 45vh;
  }

  .dialog-actions {
    flex-wrap: wrap;
    justify-content: flex-end;
  }
}

@media (max-width: 700px) {
  .app {
    margin: 0;
    padding: 0;
  }

  .card {
    border-radius: 0;
    box-shadow: none;
    border: 0;
  }

  .chat {
    gap: 0;
  }

  .sidebar {
    min-height: auto;
    border-bottom: 1px solid #e5e7eb;
    padding-bottom: 10px;
  }

  .dialog {
    min-height: calc(100vh - 320px);
  }

  .messages {
    height: 44vh;
  }

  .composer-row {
    flex-direction: column;
    align-items: stretch;
  }

  .sidebar-header {
    flex-wrap: wrap;
  }

  .row {
    flex-wrap: wrap;
  }

  button {
    min-height: 42px;
  }

  .dialog {
    padding-top: 10px;
  }
}

.push-row {
  margin: 8px 0 10px;
}

.push-row p {
  margin: 6px 0 0;
}

.toast-container {
  position: fixed;
  right: 12px;
  bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 30;
}

.toast {
  background: #111827;
  color: #fff;
  border-radius: 10px;
  padding: 10px 12px;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.22);
  max-width: min(86vw, 420px);
  font-size: 13px;
}

.toast.hide {
  opacity: 0;
  transform: translateY(8px);
  transition: all 0.2s ease;
}

@media (max-width: 700px) {
  .tabs {
    position: sticky;
    top: 0;
    background: #fff;
    z-index: 3;
    padding-bottom: 4px;
  }

  .toast-container {
    left: 8px;
    right: 8px;
    bottom: 8px;
  }
}
