/* ============================================
   Gemini API Explorer v2026 - Dark Google Theme
   Based on GPT Explorer style, Google blue accent
   ============================================ */
*, *::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:  #4285F4;   /* Google blue */
  --primary-l:#7ab3f8;
  --green-3:  #26a641;
  --green-4:  #39d353;
  --text:     #f1f5f9;
  --muted:    #64748b;
  --user-bg:  rgba(66, 133, 244, 0.10);
  --bot-bg:   rgba(30, 41, 59, 0.8);
  --sys-bg:   rgba(66, 133, 244, 0.07);
  --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.22; 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, #4285F4, #34A853);
  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(--primary-l); border-color: var(--primary); }

/* 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(66, 133, 244, 0.25);
  align-self: flex-end;
  margin-left: auto;
}

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

.model-message {
  background: var(--sys-bg);
  border-color: rgba(66, 133, 244, 0.18);
  align-self: stretch;
  font-style: italic;
  font-size: 0.8rem;
  color: rgba(122, 179, 248, 0.85);
}

/* 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;
}

.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;
  margin-top: 6px;
  display: block;
}

/* 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;
}

.textarea-stack {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

#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: 180px;
}
#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;
}

#user-message, #model-message {
  width: 100%;
  padding: 10px 14px;
  background: rgba(30, 41, 59, 0.9);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 0.88rem;
  font-family: inherit;
  resize: none;
  min-height: 38px;
  max-height: 100px;
  overflow-y: auto;
}
#user-message:focus, #model-message:focus { outline: none; border-color: var(--primary); }
#model-message { border-style: dashed; }
#model-message::placeholder { color: rgba(66, 133, 244, 0.4); }

#send-btn {
  width: 42px;
  height: 84px;
  background: linear-gradient(135deg, #4285F4, #34A853);
  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(66, 133, 244, 0.4);
}
#send-btn:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(66, 133, 244, 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(--primary-l); font-weight: 600; }

/* 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; }
  #send-btn { height: 42px; width: 100%; }
  .input-row-2 { flex-direction: column; }
  .textarea-stack { width: 100%; }
}
