/* ============================================
   GPT Explorer v2026 - Upgraded Visual
   ============================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:       #0f172a;
  --panel:    rgba(30, 41, 59, 0.90);
  --border:   rgba(148, 163, 184, 0.12);
  --primary:  #6366f1;
  --green-3:  #26a641;
  --green-4:  #39d353;
  --text:     #f1f5f9;
  --muted:    #64748b;
  --user-bg:  rgba(99, 102, 241, 0.1);
  --bot-bg:   rgba(30, 41, 59, 0.8);
  --sys-bg:   rgba(239, 68, 68, 0.08);
  --code-bg:  rgba(0, 0, 0, 0.4);
}

body {
  display: flex;
  flex-direction: column;
  height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  overflow: hidden;
}

/* Background canvas */
#bg-canvas {
  position: fixed; inset: 0;
  z-index: 0; opacity: 0.25; pointer-events: none;
}

/* Header */
header {
  position: relative; z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: rgba(15, 23, 42, 0.95);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(20px);
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-logo {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, #6366f1, #06b6d4);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.75rem; color: white;
  text-decoration: none;
}

.header-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
}

.header-meta {
  font-size: 0.7rem;
  color: var(--muted);
}

.back-link {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--muted); font-size: 0.78rem; text-decoration: none;
  padding: 5px 10px; border: 1px solid var(--border); border-radius: 8px;
  transition: all .2s;
}
.back-link:hover { color: var(--green-4); border-color: var(--green-3); }

/* System message textarea */
#system-message {
  position: relative; z-index: 10;
  width: 100%;
  padding: 12px 20px;
  background: rgba(239, 68, 68, 0.06);
  border: none;
  border-bottom: 1px solid rgba(239, 68, 68, 0.15);
  color: var(--text);
  font-family: inherit;
  font-size: 0.85rem;
  resize: vertical;
  min-height: 70px;
}
#system-message::placeholder { color: rgba(248, 113, 113, 0.5); }
#system-message:focus { outline: none; background: rgba(239, 68, 68, 0.1); }

/* Chat area */
#chat-container {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: relative; z-index: 5;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

/* Messages */
.message {
  max-width: 85%;
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 0.9rem;
  line-height: 1.65;
  word-wrap: break-word;
  white-space: pre-wrap;
  border: 1px solid var(--border);
}

.user-message {
  background: var(--user-bg);
  border-color: rgba(99, 102, 241, 0.25);
  align-self: flex-end;
  margin-left: auto;
}

.bot-message {
  background: var(--bot-bg);
  align-self: flex-start;
}

.system-message {
  background: var(--sys-bg);
  border-color: rgba(239, 68, 68, 0.2);
  align-self: stretch;
  font-style: italic;
  font-size: 0.8rem;
  color: rgba(248, 113, 113, 0.8);
}

/* Code blocks */
.code-block {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
  margin: 8px 0;
  overflow-x: auto;
}

.code-block pre {
  font-family: 'JetBrains Mono', 'Courier New', monospace;
  font-size: 0.82rem;
  color: var(--green-4);
  white-space: pre;
  line-height: 1.5;
}

/* Copy button */
.copy-btn-container {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.copy-btn {
  padding: 4px 12px;
  font-size: 0.72rem;
  background: rgba(99, 102, 241, 0.15);
  color: #818cf8;
  border: 1px solid rgba(99, 102, 241, 0.25);
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
  transition: all .2s;
}
.copy-btn:hover { background: rgba(99, 102, 241, 0.3); }

.token-info {
  font-size: 0.7rem;
  color: var(--muted);
  font-family: 'JetBrains Mono', monospace;
  background: rgba(0,0,0,0.2);
  padding: 3px 8px;
  border-radius: 4px;
}

/* Input area */
#input-container {
  position: relative; z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 16px;
  background: rgba(15, 23, 42, 0.95);
  border-top: 1px solid var(--border);
}

.input-row-1 {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.input-row-2 {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

#api-key {
  flex: 1;
  min-width: 160px;
  padding: 8px 12px;
  background: rgba(30, 41, 59, 0.9);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.82rem;
  font-family: inherit;
}
#api-key:focus { outline: none; border-color: var(--primary); }

#model-select {
  padding: 8px 12px;
  background: rgba(30, 41, 59, 0.9);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.82rem;
  font-family: inherit;
  min-width: 170px;
}
#model-select:focus { outline: none; border-color: var(--primary); }

.label-input {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--muted);
}

.label-input label { white-space: nowrap; }

#temperature {
  width: 56px;
  padding: 8px 10px;
  background: rgba(30, 41, 59, 0.9);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.82rem;
  font-family: inherit;
}
#temperature:focus { outline: none; border-color: var(--primary); }

.toggle-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}

#streaming-checkbox {
  width: 16px; height: 16px;
  accent-color: var(--primary);
  cursor: pointer;
}

#prompt {
  flex: 1;
  padding: 10px 14px;
  background: rgba(30, 41, 59, 0.9);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 0.9rem;
  font-family: inherit;
  resize: none;
  min-height: 42px;
  max-height: 140px;
  overflow-y: auto;
}
#prompt:focus { outline: none; border-color: var(--primary); }

#send-btn {
  width: 42px; height: 42px;
  background: linear-gradient(135deg, #6366f1, #06b6d4);
  color: white;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: all .2s;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}
#send-btn:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(99, 102, 241, 0.6); }
#send-btn:active { transform: translateY(0); }

/* Cost summary bar */
#cost-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.7rem;
  color: var(--muted);
  font-family: 'JetBrains Mono', monospace;
  padding: 4px 0 0;
}

#cost-bar .cost-item { display: flex; align-items: center; gap: 4px; }
#cost-bar .cost-val  { color: var(--green-4); font-weight: 600; }

/* Model pricing tooltip */
.model-info {
  font-size: 0.65rem;
  color: var(--muted);
  padding: 2px 0;
}

/* Responsive */
@media (max-width: 600px) {
  .input-row-1 { gap: 6px; }
  #model-select { min-width: 140px; }
  .message { max-width: 95%; }
  header { flex-wrap: wrap; gap: 8px; }
}
