/* ═══════════════════════════════════════════════
   Dvi-Coder.web — Style Sheet (v2)
   Welcome screen → Chat interface flow
   ═══════════════════════════════════════════════ */

:root {
  --bg-primary: #0d0e12;
  --bg-secondary: #14161c;
  --bg-tertiary: #1a1d26;
  --bg-card: #161920;
  --bg-input: #0f1116;
  --border: #2a2e3a;
  --border-light: #1e2230;
  --text-primary: #e4e7ef;
  --text-secondary: #8b8f9e;
  --text-muted: #5a5e6e;
  --accent-green: #22c55e;
  --accent-blue: #3b82f6;
  --accent-purple: #8b5cf6;
  --accent-orange: #f59e0b;
  --accent-red: #ef4444;
  --accent-cyan: #06b6d4;
  --font-mono: "SF Mono", "Fira Code", "Cascadia Code", "Consolas", monospace;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Arial", sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.6;
}

.bg-glow {
  position: fixed;
  top: -200px;
  right: -200px;
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(139, 92, 246, 0.06) 0%, transparent 70%);
  border-radius: 50%;
  pointer-events: none;
  z-index: 0;
}

/* ═══════════════════════════════════════════════
   WELCOME SCREEN
   ═══════════════════════════════════════════════ */

.welcome-screen {
  position: fixed;
  inset: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow-y: auto;
}

.welcome-card {
  max-width: 560px;
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: 16px;
  padding: 28px;
  position: relative;
}

.window-dots {
  display: flex;
  gap: 6px;
  margin-bottom: 20px;
}

.dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

.dot.red { background: #ff5f57; }
.dot.yellow { background: #febc2e; }
.dot.green { background: #28c840; }

.logo-area {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
}

.terminal-symbol {
  font-family: var(--font-mono);
  color: var(--accent-green);
  font-size: 20px;
  font-weight: bold;
}

.logo-area h1 {
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--text-primary);
}

.welcome-message {
  margin-bottom: 20px;
}

.welcome-message p {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 10px;
  line-height: 1.7;
}

.welcome-message strong {
  color: var(--accent-green);
}

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

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

/* Advantages box */
.advantages-box {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 24px;
}

.adv-title {
  font-weight: 600;
  color: var(--accent-green);
  font-size: 13px;
  margin-bottom: 8px;
}

.advantages-box ul {
  list-style: none;
  padding: 0;
}

.advantages-box li {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 6px;
  padding-left: 16px;
  position: relative;
}

.advantages-box li::before {
  content: '▸';
  position: absolute;
  left: 0;
  color: var(--accent-purple);
}

.advantages-box strong {
  color: var(--text-primary);
}

.advantages-box code {
  background: var(--bg-tertiary);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--accent-cyan);
}

/* API key input area */
.api-key-area {
  border-top: 1px solid var(--border-light);
  padding-top: 20px;
}

.api-input-wrapper {
  display: flex;
  gap: 10px;
}

.api-input-wrapper input {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  color: var(--text-primary);
  font-size: 14px;
  font-family: var(--font-mono);
  transition: border-color 0.2s;
}

.api-input-wrapper input:focus {
  outline: none;
  border-color: var(--accent-purple);
}

.api-input-wrapper input::placeholder {
  color: var(--text-muted);
}

#connectBtn {
  background: var(--accent-green);
  color: var(--bg-primary);
  border: none;
  border-radius: 10px;
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

#connectBtn:hover {
  background: #16a34a;
  transform: translateY(-1px);
}

.key-error {
  color: var(--accent-red);
  font-size: 13px;
  margin-top: 8px;
}

.api-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 10px;
}

/* ═══════════════════════════════════════════════
   CHAT SCREEN
   ═══════════════════════════════════════════════ */

.chat-screen {
  height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 1;
}

/* Header */
.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-light);
  flex-shrink: 0;
}

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

.header-title {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 1px;
}

.status-badge {
  font-size: 11px;
  color: var(--accent-green);
  background: rgba(34, 197, 94, 0.1);
  padding: 3px 8px;
  border-radius: 6px;
  border: 1px solid rgba(34, 197, 94, 0.2);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.model-select {
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 12px;
  font-family: var(--font-mono);
  cursor: pointer;
}

.icon-btn {
  background: transparent;
  border: 1px solid var(--border-light);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 16px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.icon-btn:hover {
  background: var(--bg-tertiary);
  border-color: var(--accent-purple);
}

/* Chat messages */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.message {
  display: flex;
  gap: 12px;
  max-width: 800px;
  width: 100%;
  margin: 0 auto;
}

.message.user {
  flex-direction: row-reverse;
}

.msg-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.message.user .msg-avatar {
  background: var(--accent-blue);
}

.message.assistant .msg-avatar {
  background: var(--accent-purple);
}

.msg-bubble {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  padding: 14px 16px;
  font-size: 14px;
  line-height: 1.7;
  max-width: calc(100% - 48px);
}

.message.user .msg-bubble {
  background: var(--accent-blue);
  color: white;
  border-color: var(--accent-blue);
}

.msg-bubble p {
  margin-bottom: 8px;
}

.msg-bubble p:last-child {
  margin-bottom: 0;
}

.msg-bubble strong {
  color: var(--accent-green);
}

.message.user .msg-bubble strong {
  color: white;
}

.msg-bubble a {
  color: var(--accent-cyan);
  text-decoration: none;
}

.msg-bubble a:hover {
  text-decoration: underline;
}

.msg-bubble ul {
  list-style: none;
  padding: 0;
  margin: 8px 0;
}

.msg-bubble li {
  margin-bottom: 4px;
  padding-left: 16px;
  position: relative;
}

.msg-bubble li::before {
  content: '▸';
  position: absolute;
  left: 0;
  color: var(--accent-purple);
}

.msg-bubble code.inline-code {
  background: var(--bg-tertiary);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--accent-cyan);
}

.msg-bubble .code-block {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  margin: 8px 0;
  font-family: var(--font-mono);
  font-size: 13px;
  overflow-x: auto;
  white-space: pre-wrap;
  color: var(--accent-green);
}

/* Typing indicator */
.typing {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  padding: 4px 0;
}

.typing .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: typingBounce 1.4s infinite ease-in-out;
}

.typing .dot:nth-child(1) { animation-delay: 0s; }
.typing .dot:nth-child(2) { animation-delay: 0.2s; }
.typing .dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-6px); opacity: 1; }
}

/* Chat input */
.chat-input-bar {
  padding: 12px 20px 16px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-light);
  flex-shrink: 0;
}

.input-wrapper {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  max-width: 800px;
  margin: 0 auto;
}

#chatInput {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  color: var(--text-primary);
  font-size: 14px;
  font-family: var(--font-sans);
  resize: none;
  min-height: 44px;
  max-height: 200px;
  transition: border-color 0.2s;
}

#chatInput:focus {
  outline: none;
  border-color: var(--accent-purple);
}

#chatInput::placeholder {
  color: var(--text-muted);
}

.send-btn {
  background: var(--accent-green);
  color: var(--bg-primary);
  border: none;
  border-radius: 12px;
  width: 44px;
  height: 44px;
  min-width: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.send-btn:hover {
  background: #16a34a;
  transform: translateY(-1px);
}

.send-btn:active {
  transform: translateY(0);
}

.send-btn.loading {
  opacity: 0.5;
  cursor: not-allowed;
}

.send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.input-hints {
  display: flex;
  justify-content: space-between;
  max-width: 800px;
  margin: 6px auto 0;
  font-size: 11px;
  color: var(--text-muted);
}

/* ═══════════════════════════════════════════════
   SIDE PANELS (GitHub, HF, Settings)
   ═══════════════════════════════════════════════ */

.panel-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 50;
}

.side-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 400px;
  max-width: 90vw;
  height: 100vh;
  background: var(--bg-secondary);
  border-left: 1px solid var(--border-light);
  flex-direction: column;
  z-index: 51;
  overflow: hidden;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-light);
  flex-shrink: 0;
}

.panel-header h2 {
  font-size: 16px;
  font-weight: 600;
}

.close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: all 0.15s;
}

.close-btn:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

/* Form elements */
.form-group {
  margin-bottom: 14px;
}

.form-group label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-group input,
.form-group textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text-primary);
  font-size: 14px;
  font-family: var(--font-sans);
  transition: border-color 0.2s;
}

.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--accent-purple);
}

.form-group textarea {
  font-family: var(--font-mono);
  font-size: 13px;
  resize: vertical;
}

.form-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

.form-hint a {
  color: var(--accent-cyan);
  text-decoration: none;
}

.form-row {
  display: flex;
  gap: 10px;
}

.form-row .form-group {
  flex: 1;
}

.btn-row {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.action-btn {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.action-btn:hover {
  background: var(--border);
  border-color: var(--accent-purple);
}

.action-btn.danger {
  color: var(--accent-red);
  border-color: rgba(239, 68, 68, 0.3);
}

.action-btn.danger:hover {
  background: rgba(239, 68, 68, 0.1);
}

.result-area {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  margin-top: 14px;
  min-height: 80px;
  max-height: 300px;
  overflow-y: auto;
}

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

.result-text {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--accent-green);
  white-space: pre-wrap;
  word-break: break-all;
}

/* Settings sections */
.settings-section {
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border-light);
}

.settings-section:last-child {
  border-bottom: none;
}

.settings-section h3 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 10px;
  color: var(--text-primary);
}

.settings-section p {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.settings-section input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text-primary);
  font-size: 14px;
  margin-bottom: 8px;
}

.settings-section input:focus {
  outline: none;
  border-color: var(--accent-purple);
}

/* ═══════════════════════════════════════════════
   SCROLLBARS
   ═══════════════════════════════════════════════ */

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

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

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ═══════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════ */

@media (max-width: 640px) {
  .welcome-card {
    padding: 20px;
  }

  .message {
    max-width: 100%;
  }

  .msg-bubble {
    max-width: calc(100% - 48px);
  }

  .side-panel {
    width: 100vw;
  }

  .header-right .icon-btn {
    padding: 6px 8px;
  }

  .model-select {
    font-size: 11px;
  }
}
