/* GigaChat styles */
.gigachat-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10000;
  display: none;
}

.gigachat-modal.is-open {
  display: block;
}

.gigachat-modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: -1;
}

.gigachat-modal-content {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 90%;
  max-width: 700px;
  height: 80vh;
  background: white;
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.gigachat-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.gigachat-modal-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.gigachat-close-btn {
  background: none;
  border: none;
  font-size: 28px;
  cursor: pointer;
  color: var(--faint);
  line-height: 1;
  padding: 0;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.12s ease;
}

.gigachat-close-btn:hover {
  color: var(--ink);
}

.gigachat-quota-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 20px;
  border-bottom: 1px solid var(--border);
  background: #f8fafc;
  font-size: 13px;
  color: var(--muted);
}

.gigachat-small-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px 10px;
  cursor: pointer;
  font-size: 13px;
  color: var(--accent);
  transition: background 0.12s ease, border-color 0.12s ease;
}

.gigachat-small-btn:hover {
  background: var(--accent-bg);
  border-color: var(--accent);
}

.gigachat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--bg);
}

.gigachat-message {
  max-width: 80%;
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 15px;
  line-height: 1.5;
}

.gigachat-message.user {
  align-self: flex-end;
  background: var(--accent);
  color: white;
  border-bottom-right-radius: 4px;
}

.gigachat-message.assistant {
  align-self: flex-start;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

/* Markdown content styles */
.gigachat-message.assistant h1,
.gigachat-message.assistant h2,
.gigachat-message.assistant h3,
.gigachat-message.assistant h4,
.gigachat-message.assistant h5,
.gigachat-message.assistant h6 {
  margin: 0.5em 0 0.25em;
  font-weight: 600;
  line-height: 1.3;
}

.gigachat-message.assistant h1 { font-size: 1.5em; border-bottom: 1px solid var(--border); padding-bottom: 0.3em; }
.gigachat-message.assistant h2 { font-size: 1.25em; border-bottom: 1px solid var(--border); padding-bottom: 0.3em; }
.gigachat-message.assistant h3 { font-size: 1.1em; }

.gigachat-message.assistant p {
  margin: 0.5em 0;
  line-height: 1.6;
}

.gigachat-message.assistant ul,
.gigachat-message.assistant ol {
  margin: 0.5em 0;
  padding-left: 1.5em;
}

.gigachat-message.assistant li {
  margin: 0.25em 0;
  line-height: 1.5;
}

.gigachat-message.assistant blockquote {
  margin: 0.5em 0;
  padding: 0.25em 1em;
  background: var(--bg);
  border-left: 4px solid var(--accent);
  border-radius: 4px;
  color: var(--muted);
}

.gigachat-message.assistant code {
  background: var(--bg);
  padding: 0.2em 0.4em;
  border-radius: 3px;
  font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
  font-size: 0.9em;
}

.gigachat-message.assistant pre {
  margin: 0.5em 0;
  padding: 1em;
  background: #1e1e1e;
  border-radius: 8px;
  overflow-x: auto;
}

.gigachat-message.assistant pre code {
  background: transparent;
  padding: 0;
  color: #d4d4d4;
}

/* Syntax highlighting styles (matching GitHub Dark theme) */
.gigachat-message.assistant .hljs-keyword {
  color: #ff7b72;
}

.gigachat-message.assistant .hljs-string,
.gigachat-message.assistant .hljs-doctag {
  color: #a5d6ff;
}

.gigachat-message.assistant .hljs-number {
  color: #ff7b72;
}

.gigachat-message.assistant .hljs-function,
.gigachat-message.assistant .hljs-title {
  color: #d2a8ff;
}

.gigachat-message.assistant .hljs-symbol,
.gigachat-message.assistant .hljs-bullet {
  color: #79c0ff;
}

.gigachat-message.assistant .hljs-section,
.gigachat-message.assistant .hljs-name {
  color: #7ee787;
}

.gigachat-message.assistant .hljs-variable {
  color: #79c0ff;
}

.gigachat-message.assistant .hljs-built_in {
  color: #7ee787;
}

.gigachat-message.assistant .hljs-type {
  color: #a5d6ff;
}

.gigachat-message.assistant .hljs-comment,
.gigachat-message.assistant .hljs-quote {
  color: #8b949e;
  font-style: italic;
}

.gigachat-message.assistant .hljs-meta,
.gigachat-message.assistant .hljs-tag {
  color: #8b949e;
}

.gigachat-message.assistant .hljs-subst {
  color: #d0d0d0;
}

.gigachat-message.assistant .hljs-selector-tag {
  color: #7ee787;
}

.gigachat-message.assistant .hljs-selector-id {
  color: #d2a8ff;
}

.gigachat-message.assistant .hljs-selector-class {
  color: #79c0ff;
}

.gigachat-message.assistant a {
  color: var(--accent);
  text-decoration: none;
}

.gigachat-message.assistant a:hover {
  text-decoration: underline;
}

.gigachat-message.assistant hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1em 0;
}

.gigachat-message.assistant table {
  border-collapse: collapse;
  margin: 0.5em 0;
  width: 100%;
}

.gigachat-message.assistant th,
.gigachat-message.assistant td {
  border: 1px solid var(--border);
  padding: 0.5em;
  text-align: left;
}

.gigachat-message.assistant th {
  background: var(--bg);
  font-weight: 600;
}

.gigachat-message.system {
  align-self: center;
  background: var(--amber-bg);
  color: var(--amber-ink);
  font-size: 13px;
  border-radius: 8px;
  padding: 8px 12px;
}

.gigachat-thread-preview {
  text-align: center;
  padding: 12px 20px 16px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.gigachat-thread-preview-btn {
  background: var(--accent);
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: background 0.12s ease, transform 0.04s ease;
}

.gigachat-thread-preview-btn:hover {
  background: var(--accent-ink);
}

.gigachat-thread-preview-btn:active {
  transform: translateY(1px);
}

.gigachat-messages-wrapper {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}

.gigachat-input-area {
  display: flex;
  padding: 16px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.gigachat-input-area input {
  flex: 1;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 24px;
  font-size: 15px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  font-family: inherit;
}

.gigachat-input-area input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.15);
}

.gigachat-send-btn {
  margin-left: 12px;
  padding: 12px 24px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 24px;
  cursor: pointer;
  font-size: 15px;
  font-weight: 600;
  transition: background 0.12s ease, transform 0.04s ease, box-shadow 0.12s ease;
  box-shadow: 0 1px 2px rgba(15, 118, 110, 0.18);
}

.gigachat-send-btn:hover {
  background: var(--accent-ink);
}

.gigachat-send-btn:active {
  transform: translateY(1px);
}

/* Chat button in header/navbar */
#gigachat-chat-btn {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--accent);
    color: white;
    border: none;
    box-shadow: 0 4px 12px rgba(15, 118, 110, 0.3);
    cursor: pointer;
    font-size: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, box-shadow 0.2s;
    z-index: 9999;
    outline: none;
}

#gigachat-chat-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 16px rgba(15, 118, 110, 0.4);
}

#gigachat-chat-btn:active {
    transform: scale(0.96);
}

/* Quota display in header */
#gigachat-quota {
  font-size: 13px;
  color: #666;
  margin-right: 16px;
}

/* Responsive */
@media (max-width: 600px) {
  .gigachat-modal-content {
    width: 95%;
    height: 90vh;
  }

  .gigachat-message {
    max-width: 85%;
  }

  #gigachat-chat-btn {
    bottom: 16px;
    right: 16px;
    width: 50px;
    height: 50px;
    font-size: 24px;
  }
}
