/* ===== Chat app layout (uses Polytoria theme vars from style.css) ===== */

body {
  font-family: "Varela Round", var(--bs-body-font-family);
  height: 100vh;
  overflow: hidden;
}

.chat-app {
  display: flex;
  height: 100vh;
  width: 100%;
}

/* ---------- Sidebar ---------- */
.chat-sidebar {
  width: 260px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background-color: #1a1a1a;
  border-right: 1px solid #2d2d2d;
  transition: margin-left 0.25s ease;
}

.chat-sidebar.collapsed {
  margin-left: -260px;
}

.chat-sidebar-header {
  padding: 1rem;
  border-bottom: 1px solid #2d2d2d;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.chat-brand {
  font-size: 1.1rem;
  font-weight: 600;
  color: #f6f6f6;
}

.chat-new-btn {
  width: 100%;
}

.chat-sidebar-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem;
}

.chat-sidebar-empty {
  color: #757575;
  font-size: 0.85rem;
  text-align: center;
  padding: 1.5rem 0.5rem;
}

.chat-conversation-item {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  color: #cacaca;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}

.chat-conversation-item:hover {
  background-color: #ffffff0d;
  color: #fff;
}

.chat-conversation-item.active {
  background-color: #3bafff26;
  color: #3bafff;
}

.chat-sidebar-footer {
  padding: 0.75rem 1rem;
  border-top: 1px solid #2d2d2d;
  color: #757575;
  font-size: 0.75rem;
}

/* ---------- Main area ---------- */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid #2d2d2d;
  background-color: #1a1a1a;
}

.chat-title {
  font-size: 1rem;
  margin: 0;
  color: #f6f6f6;
}

.chat-subtitle {
  margin: 0;
  font-size: 0.75rem;
  color: #757575;
}

.chat-toggle-btn {
  display: none;
}

/* ---------- Messages ---------- */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.chat-welcome {
  margin: auto;
  text-align: center;
  color: #cacaca;
}

.chat-welcome-icon {
  font-size: 3rem;
  margin-bottom: 0.5rem;
}

.chat-welcome h2 {
  font-size: 1.5rem;
  color: #f6f6f6;
}

.chat-welcome p {
  font-size: 0.95rem;
  color: #757575;
}

.chat-message {
  display: flex;
  max-width: 75%;
}

.chat-message.user {
  align-self: flex-end;
}

.chat-message.bot {
  align-self: flex-start;
}

.chat-bubble {
  padding: 0.65rem 1rem;
  border-radius: 16px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.95rem;
}

.chat-message.user .chat-bubble {
  background-color: #3bafff;
  color: #000;
  border-bottom-right-radius: 4px;
}

.chat-message.bot .chat-bubble {
  background-color: #262626;
  color: #f6f6f6;
  border-bottom-left-radius: 4px;
  border: 1px solid #2d2d2d;
}

.chat-bubble.typing-dots {
  display: flex;
  gap: 5px;
  align-items: center;
}

.chat-bubble.typing-dots span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: #757575;
  animation: chatBlink 1.2s infinite;
}

.chat-bubble.typing-dots span:nth-child(2) {
  animation-delay: 0.2s;
}

.chat-bubble.typing-dots span:nth-child(3) {
  animation-delay: 0.4s;
}

/* Live response indicator: [spinner] thinking / [spinner] using tool [name] */
.chat-bubble.live-indicator {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 0.55rem 0.95rem;
  background-color: #262626;
  border: 1px solid #2d2d2d;
  border-bottom-left-radius: 4px;
}

.chat-live-status {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-size: 0.9rem;
  color: #a0aec0;
  user-select: none;
}

.chat-live-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(59, 175, 255, 0.25);
  border-top-color: #3bafff;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
  animation: live-spin 0.75s linear infinite;
}

@keyframes live-spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.chat-live-text {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 500;
  letter-spacing: 0.2px;
  color: #cbd5e0;
}

.live-tool-tag {
  background: rgba(59, 175, 255, 0.12);
  color: #5dcceb;
  padding: 1px 7px;
  border-radius: 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.85em;
  border: 1px solid rgba(59, 175, 255, 0.25);
  font-weight: 600;
}

@keyframes chatBlink {
  0%,
  80%,
  100% {
    opacity: 0.25;
  }
  40% {
    opacity: 1;
  }
}

/* ---------- Composer ---------- */
.chat-composer {
  padding: 1rem 1.25rem 1.25rem;
  border-top: 1px solid #2d2d2d;
  background-color: #1a1a1a;
}

.chat-composer-inner {
  display: flex;
  gap: 0.5rem;
  align-items: flex-end;
  max-width: 800px;
  margin: 0 auto;
}

.attachment-preview {
  position: relative;
  display: inline-block;
  margin-bottom: 0.5rem;
  border-radius: 8px;
  border: 1px solid #2d2d2d;
  background-color: #262626;
  padding: 0.5rem;
}

.attachment-preview img {
  max-height: 100px;
  border-radius: 4px;
}

#removeAttachmentBtn {
  position: absolute;
  top: -8px;
  right: -8px;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
}

.chat-message-attachment {
  display: block;
  max-width: min(100%, 320px);
  max-height: 280px;
  border-radius: 10px;
  margin-bottom: 0.5rem;
  object-fit: contain;
  background-color: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.12);
  cursor: zoom-in;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.chat-message.user .chat-message-attachment {
  border-color: rgba(0, 0, 0, 0.15);
  background-color: rgba(255, 255, 255, 0.22);
}

.chat-message-attachment:hover {
  transform: scale(1.015);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
}

.chat-input {
  background-color: #262626;
  border-color: #2d2d2d;
  border-radius: 12px;
  resize: none;
  max-height: 160px;
}

.chat-input:focus {
  background-color: #262626;
  border-color: #3bafff;
  box-shadow: 0 0 0 0.2rem #3bafff33;
}

.chat-send-btn {
  border-radius: 12px;
  padding: 0.45rem 1rem;
  flex-shrink: 0;
}

.chat-disclaimer {
  margin: 0.5rem 0 0;
  text-align: center;
  font-size: 0.7rem;
  color: #757575;
}

/* ---------- Widgets (player/game/guild cards) ---------- */
.chat-bubble-rich {
  min-width: 220px;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.chat-bubble-rich .chat-text {
  white-space: normal;
  word-break: break-word;
}

/* Markdown formatting inside chat */
.markdown-body {
  font-size: 0.95rem;
  line-height: 1.55;
  color: #f6f6f6;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4 {
  font-weight: 700;
  color: #f6f6f6;
  margin: 0.75rem 0 0.35rem 0;
  line-height: 1.3;
}

.markdown-body h1:first-child,
.markdown-body h2:first-child,
.markdown-body h3:first-child,
.markdown-body h4:first-child {
  margin-top: 0;
}

.markdown-body h1 { font-size: 1.25rem; }
.markdown-body h2 { font-size: 1.15rem; }
.markdown-body h3 { font-size: 1.05rem; }
.markdown-body h4 { font-size: 0.95rem; }

.markdown-body p {
  margin: 0 0 0.5rem 0;
}

.markdown-body p:last-child {
  margin-bottom: 0;
}

.markdown-body ul,
.markdown-body ol {
  margin: 0 0 0.5rem 0;
  padding-left: 1.25rem;
}

.markdown-body ul:last-child,
.markdown-body ol:last-child {
  margin-bottom: 0;
}

.markdown-body li {
  margin-bottom: 0.2rem;
}

.markdown-body li:last-child {
  margin-bottom: 0;
}

.markdown-body a {
  color: #3bafff;
  text-decoration: none;
}

.markdown-body a:hover {
  text-decoration: underline;
}

.markdown-body code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.85em;
  background-color: #1a1a1a;
  color: #5dcceb;
  padding: 0.15rem 0.35rem;
  border-radius: 4px;
  border: 1px solid #333;
}

.markdown-body pre {
  background-color: #181818;
  border: 1px solid #2d2d2d;
  border-radius: 8px;
  padding: 0.75rem 1rem;
  overflow-x: auto;
  margin: 0.5rem 0;
}

.markdown-body pre code {
  background: none;
  border: none;
  padding: 0;
  color: #f6f6f6;
  font-size: 0.85rem;
}

.markdown-body blockquote {
  border-left: 3px solid #3bafff;
  padding-left: 0.75rem;
  margin: 0.5rem 0;
  color: #a0a0a0;
}

.markdown-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.5rem 0;
  font-size: 0.85rem;
}

.markdown-body th,
.markdown-body td {
  border: 1px solid #333;
  padding: 0.4rem 0.6rem;
  text-align: left;
}

.markdown-body th {
  background-color: #1e1e1e;
  color: #f6f6f6;
}

.markdown-body hr {
  border: none;
  border-top: 1px solid #2d2d2d;
  margin: 0.75rem 0;
}

.poly-widget {
  width: 100%;
}

.poly-widget-loading,
.poly-widget-error {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: #757575;
  font-size: 0.85rem;
}

.poly-widget-error {
  color: #ff8a8a;
  flex-wrap: wrap;
}

.poly-widget-retry {
  flex-shrink: 0;
}

.poly-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid #3bafff;
  border-top-color: transparent;
  border-radius: 50%;
  animation: polySpin 0.8s linear infinite;
}

@keyframes polySpin {
  to {
    transform: rotate(360deg);
  }
}

.poly-card {
  display: flex;
  gap: 0.75rem;
  padding: 0.75rem;
  border-radius: 12px;
  background-color: #1f1f1f;
  border: 1px solid #2d2d2d;
  text-decoration: none;
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.poly-card:hover {
  border-color: #3bafff;
  text-decoration: none;
  transform: translateY(-1px);
}

.poly-card-banner {
  width: 100%;
  height: 70px;
  object-fit: cover;
  border-radius: 8px;
  margin-bottom: 0.5rem;
}

.poly-card-head {
  display: flex;
  gap: 0.75rem;
  width: 100%;
  flex-direction: column;
}

.poly-card-guild .poly-card-head {
  flex-direction: row;
}

.poly-card-guild .poly-card-banner {
  margin-bottom: 0;
}

.poly-card-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  background-color: #262626;
}

.poly-card-thumb {
  width: 96px;
  height: 96px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
  background-color: #262626;
}

.poly-card-icon {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
  background-color: #262626;
}

.poly-card-body {
  min-width: 0;
  flex: 1;
}

.poly-card-title-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.poly-card-title {
  font-size: 1rem;
  font-weight: 600;
  color: #f6f6f6;
  word-break: break-word;
}

.poly-card:hover .poly-card-title {
  color: #3bafff;
}

.poly-card-sub {
  margin: 0;
  font-size: 0.8rem;
  color: #3bafff;
}

.poly-card-desc {
  margin: 0.35rem 0 0;
  font-size: 0.82rem;
  color: #cacaca;
  white-space: pre-wrap;
  word-break: break-word;
}

.poly-card-desc-clamp {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.poly-card-meta {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-top: 0.5rem;
}

.poly-card-meta-item {
  font-size: 0.75rem;
  color: #757575;
}

.poly-card-tag {
  font-size: 0.7rem;
  color: #3bafff;
  background-color: #3bafff26;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  text-transform: capitalize;
}

.poly-badge {
  font-size: 0.6rem;
  font-weight: 700;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  letter-spacing: 0.03em;
}

.poly-badge-staff {
  color: #fff;
  background-color: #ff5951;
}

.poly-badge-plus {
  color: #000;
  background-color: #5dcceb;
}

.poly-badge-deluxe {
  color: #fff;
  background-color: #c869ff;
}

.poly-badge-legacy {
  color: #fff;
  background-color: #8e6cff;
}

.poly-badge-verified {
  color: #fff;
  background-color: #3bafff;
}

.poly-badge-limited {
  color: #000;
  background-color: #f7b731;
}

.poly-card-thumb-item {
  width: 72px;
  height: 72px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
  background-color: #262626;
}

.poly-price-tag {
  font-size: 0.8rem;
  font-weight: 700;
  color: #5dcceb;
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
}

/* ---------- Feed widget ---------- */
.poly-card-feed {
  flex-direction: column;
  gap: 0.6rem;
}

.poly-feed-author {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.poly-card-avatar-sm {
  width: 40px;
  height: 40px;
}

.poly-post {
  border-top: 1px solid #2d2d2d;
  padding-top: 0.6rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.poly-post-content {
  margin: 0;
  font-size: 0.85rem;
  color: #e6e6e6;
}

.poly-post-media {
  max-width: 100%;
  max-height: 180px;
  border-radius: 8px;
  object-fit: cover;
}

.poly-empty {
  margin: 0;
  color: #757575;
  font-size: 0.85rem;
  text-align: center;
}

/* ---------- Auth ---------- */
.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
}

.auth-box {
  width: 380px;
  max-width: 92vw;
  padding: 1.5rem;
  background-color: #1a1a1a;
  border: 1px solid #2d2d2d;
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.auth-brand {
  font-size: 1.2rem;
  text-align: center;
  color: #f6f6f6;
  font-weight: 700;
}

.auth-tabs {
  display: flex;
  background-color: #242424;
  border-radius: 8px;
  padding: 3px;
  gap: 4px;
}

.auth-tab {
  flex: 1;
  background: transparent;
  border: none;
  color: #888;
  font-weight: 600;
  font-size: 0.85rem;
  padding: 0.4rem 0.75rem;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.auth-tab:hover {
  color: #fff;
}

.auth-tab.active {
  background-color: #3bafff;
  color: #fff;
}

.auth-view {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.auth-box h2 {
  margin: 0;
  font-size: 1.1rem;
  text-align: center;
  color: #f6f6f6;
}

.auth-sub {
  margin: 0;
  font-size: 0.8rem;
  color: #757575;
  text-align: center;
}

.auth-input {
  background-color: #262626;
  border-color: #2d2d2d;
}

.auth-input:focus {
  background-color: #262626;
  border-color: #3bafff;
}

.auth-input-group {
  display: flex;
  gap: 0.4rem;
}

.auth-input-group .auth-input {
  flex: 1;
}

.auth-verify-section {
  background-color: #222;
  border: 1px solid #333;
  border-radius: 8px;
  padding: 0.65rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.auth-verify-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: #a0a0a0;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.verify-code-box {
  background-color: #161616;
  border: 1px dashed #444;
  border-radius: 6px;
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.verify-instructions {
  font-size: 0.75rem;
  color: #c0c0c0;
  margin: 0;
  line-height: 1.3;
}

.verify-code-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: #0c0c0c;
  padding: 0.35rem 0.5rem;
  border-radius: 4px;
  border: 1px solid #222;
}

.verify-code-display {
  color: #5dcceb;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.85rem;
  user-select: all;
  word-break: break-all;
}

.verify-link {
  font-size: 0.75rem;
  color: #3bafff;
  text-decoration: none;
  align-self: flex-start;
}

.verify-link:hover {
  text-decoration: underline;
}

.auth-submit-btn {
  width: 100%;
  padding: 0.55rem;
  font-weight: 600;
}

.auth-error {
  min-height: 1em;
  font-size: 0.8rem;
  color: #ff8a8a;
}

.settings-verified-card {
  background-color: #17241c;
  border: 1px solid #285434;
  border-radius: 8px;
  padding: 0.75rem;
}

.settings-unverified-card {
  background-color: #241f17;
  border: 1px solid #574424;
  border-radius: 8px;
  padding: 0.75rem;
}

.poly-badge-verified {
  background-color: #28a745;
  color: #fff;
}

.poly-badge-unverified {
  background-color: #e5a93b;
  color: #111;
}

/* ---------- User Box in Header ---------- */
.chat-user-box {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-left: auto;
}

.chat-user-label {
  font-size: 0.8rem;
  color: #a0a0a0;
  white-space: nowrap;
  background-color: #242424;
  padding: 0.25rem 0.6rem;
  border-radius: 6px;
  border: 1px solid #2d2d2d;
}

/* ---------- Settings Modal ---------- */
.settings-box {
  width: 520px !important;
  max-width: 92vw !important;
  max-height: 85vh;
  overflow-y: auto;
  text-align: left !important;
  gap: 1.25rem !important;
  padding: 1.5rem !important;
  background-color: #1c1c1c;
  border: 1px solid #333;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6);
}

.settings-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid #2d2d2d;
}

.settings-header h2 {
  font-size: 1.2rem !important;
  font-weight: 700;
  color: #f6f6f6 !important;
  margin: 0 !important;
  text-align: left !important;
}

.settings-close-btn {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border-radius: 6px;
  border: 1px solid #2d2d2d;
  background-color: #262626;
  color: #cacaca;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.settings-close-btn:hover {
  background-color: #333;
  color: #fff;
}

.settings-section {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  text-align: left !important;
}

.settings-section h3 {
  font-size: 0.95rem;
  font-weight: 600;
  color: #f6f6f6;
  margin: 0;
  text-align: left !important;
}

.settings-sub {
  margin: 0;
  font-size: 0.8rem;
  color: #888;
  text-align: left !important;
}

.settings-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.storage-bar-bg {
  width: 100%;
  height: 10px;
  background-color: #262626;
  border: 1px solid #2d2d2d;
  border-radius: 999px;
  overflow: hidden;
  margin: 0.25rem 0;
}

.storage-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #3bafff, #5dcceb);
  width: 0%;
  border-radius: 999px;
  transition: width 0.3s ease;
}

.settings-file-list {
  max-height: 200px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.25rem;
}

.settings-file-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0.75rem;
  background-color: #242424;
  border: 1px solid #2d2d2d;
  border-radius: 8px;
  transition: border-color 0.15s ease;
}

.settings-file-item:hover {
  border-color: #3bafff66;
}

.settings-file-item a {
  color: #3bafff;
  text-decoration: none;
  font-size: 0.85rem;
  word-break: break-all;
}

.settings-file-item a:hover {
  text-decoration: underline;
}

.settings-file-size {
  font-size: 0.75rem;
  color: #757575;
  margin: 0 0.5rem;
}

.btn-danger {
  background-color: #ff5951;
  color: #fff;
  border: none;
  font-weight: 500;
  transition: background-color 0.15s ease;
}

.btn-danger:hover {
  background-color: #e54f48;
}

/* ---------- Responsive ---------- */
@media (max-width: 767.98px) {
  .chat-sidebar {
    position: fixed;
    z-index: 100;
    height: 100vh;
  }

  .chat-toggle-btn {
    display: inline-block;
  }

  .chat-message {
    max-width: 90%;
  }

  .chat-user-label {
    display: none;
  }
}
