/* TactCode AI Styles */

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  --bg: #0b1120;
  --bg-elevated: #020617;
  --bg-panel: #0f172a;
  --bg-muted: #1e293b;
  --border: #1e293b;
  --border-strong: #334155;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --text-soft: #64748b;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-active-border: #60a5fa;
  --primary-glow: rgba(37, 99, 235, 0.5);
  --accent: #fbbf24;
  --sidebar-bg: #020617;
  --overlay: rgba(0, 0, 0, 0.85);
  --modal-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
  --tooltip-shadow: 0 14px 32px rgba(2, 6, 23, 0.35);
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, sans-serif;
  display: flex;
  flex-direction: row;
  min-height: 100vh;
  overflow-x: hidden;
  overflow-y: auto;
}

.app-shell {
  display: flex;
  flex: 1;
  min-width: 0;
  min-height: 100vh;
}

.homepage {
  position: relative;
  min-height: 100vh;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  overflow: visible;
  background:
    radial-gradient(circle at top left, rgba(37, 99, 235, 0.28), transparent 32%),
    radial-gradient(circle at bottom right, rgba(251, 191, 36, 0.18), transparent 28%),
    linear-gradient(135deg, #020617 0%, #0f172a 52%, #111827 100%);
}

.homepage-backdrop {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(rgba(148, 163, 184, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148, 163, 184, 0.08) 1px, transparent 1px);
  background-size: 32px 32px;
  mask-image: radial-gradient(circle at center, black 35%, transparent 90%);
}

.homepage-content {
  position: relative;
  z-index: 1;
  width: min(760px, 100%);
  padding: 40px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 24px;
  background: rgba(2, 6, 23, 0.72);
  box-shadow: 0 24px 80px rgba(2, 6, 23, 0.5);
  backdrop-filter: blur(18px);
  margin: auto 0;
}

.homepage-kicker {
  margin: 0 0 12px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: #93c5fd;
}

.homepage h1 {
  margin: 0;
  font-size: clamp(2.5rem, 6vw, 4.8rem);
  line-height: 0.95;
  letter-spacing: -0.04em;
  max-width: 10ch;
}

.homepage-description {
  margin: 24px 0 0;
  max-width: 60ch;
  color: var(--text-muted);
  font-size: 16px;
  line-height: 1.7;
}

.homepage-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 28px;
}

.homepage-primary,
.homepage-secondary {
  min-width: 150px;
  padding: 12px 18px;
  font-size: 14px;
  font-weight: 600;
}

.homepage-primary {
  background: linear-gradient(135deg, #2563eb 0%, #38bdf8 100%);
}

.homepage-secondary {
  background: transparent;
  border: 1px solid rgba(148, 163, 184, 0.32);
  color: var(--text);
}

.homepage-secondary:hover {
  background: rgba(148, 163, 184, 0.12);
}

.mouse-scroller {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  margin-top: 36px;
  padding: 0;
  background: transparent;
  border: none;
  color: var(--text-muted);
}

.mouse-scroller:hover {
  background: transparent;
  color: var(--text);
  transform: translateY(-1px);
}

.mouse-scroller-shell {
  position: relative;
  width: 28px;
  height: 46px;
  border: 2px solid rgba(148, 163, 184, 0.5);
  border-radius: 999px;
}

.mouse-scroller-wheel {
  position: absolute;
  top: 8px;
  left: 50%;
  width: 4px;
  height: 9px;
  margin-left: -2px;
  border-radius: 999px;
  background: #93c5fd;
  animation: mouseWheelScroll 1.6s ease-in-out infinite;
}

.mouse-scroller-text {
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.02em;
}

@keyframes mouseWheelScroll {
  0% {
    opacity: 0;
    transform: translateY(0);
  }
  20% {
    opacity: 1;
  }
  70% {
    opacity: 1;
    transform: translateY(12px);
  }
  100% {
    opacity: 0;
    transform: translateY(12px);
  }
}

body.light-theme {
  --bg: linear-gradient(180deg, #f7f5ff 0%, #ffffff 38%, #f4f7ff 100%);
  --bg-elevated: rgba(255, 255, 255, 0.88);
  --bg-panel: rgba(255, 255, 255, 0.92);
  --bg-muted: #ede9fe;
  --border: rgba(139, 92, 246, 0.18);
  --border-strong: rgba(124, 58, 237, 0.28);
  --text: #22163f;
  --text-muted: #6d5d92;
  --text-soft: #8a7aa8;
  --primary: #7c3aed;
  --primary-hover: #6d28d9;
  --primary-active-border: #c4b5fd;
  --primary-glow: rgba(124, 58, 237, 0.25);
  --accent: #db2777;
  --sidebar-bg: linear-gradient(180deg, rgba(109, 40, 217, 0.1) 0%, rgba(255, 255, 255, 0.94) 100%);
  --overlay: rgba(76, 29, 149, 0.25);
  --modal-shadow: 0 18px 40px rgba(91, 33, 182, 0.14);
  --tooltip-shadow: 0 18px 35px rgba(124, 58, 237, 0.18);
}

body.vscode {
  background: #1e1e1e;
  color: #cccccc;
  font-family: "Segoe WPC", "Segoe UI", sans-serif;
}

body.vscode header {
  background: #333333;
  border-bottom: 1px solid #252526;
  font-size: 14px;
}

body.vscode #sidebar {
  background: #252526;
  border-right: 1px solid #1e1e1e;
}

body.vscode #newChatBtn {
  background: #0e639c;
  color: #ffffff;
  border: none;
  border-radius: 2px;
}

body.vscode #newChatBtn:hover {
  background: #1177bb;
}

body.vscode .history-item.active {
  background: #37373d;
  color: #ffffff;
}

body.vscode .history-item:hover:not(.active) {
  background: #2a2d2e;
}

body.vscode #inputWrapper {
  background: #1e1e1e;
  border-top: 1px solid #454545;
}

body.vscode textarea {
  background: #3c3c3c;
  border: 1px solid #3c3c3c;
  color: #cccccc;
  border-radius: 2px;
}

body.vscode textarea:focus {
  border-color: #007fd4;
}

body.vscode button:not(.mode-btn):not(#newChatBtn):not(.copy-btn) {
  background: #0e639c;
  border-radius: 2px;
}

body.vscode button:not(.mode-btn):not(#newChatBtn):not(.copy-btn):hover {
  background: #1177bb;
}

body.vscode .msg.user {
  background: #063970;
  border-radius: 4px;
}

body.vscode .msg.ai {
  background: #252526;
  border: 1px solid #3c3c3c;
  border-radius: 4px;
}

body.vscode .mode-btn {
  background: #333333;
  border: 1px solid #454545;
  border-radius: 2px;
  color: #cccccc;
}

body.vscode .mode-btn.active {
  background: #0e639c;
  border-color: #0e639c;
  box-shadow: none;
}

body.vscode .preset-box {
  background: #252526;
  border-color: #3c3c3c;
  border-radius: 4px;
  color: #cccccc;
}

body.vscode .preset-box:hover {
  background: #2a2d2e;
  border-color: #454545;
}

body.vscode .markdown-body pre {
  background: #1e1e1e;
  border: 1px solid #3c3c3c;
  border-radius: 4px;
}

body.vscode .markdown-body code:not(pre code) {
  background: #3c3c3c;
  color: #ce9178;
}

body.vscode .tooltip {
  background: #252526;
  border: 1px solid #454545;
  color: #cccccc;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

body.vscode .auth-modal {
  background: #252526;
  border: 1px solid #3c3c3c;
  border-radius: 4px;
}

body.vscode .auth-modal input {
  background: #3c3c3c;
  border: 1px solid #3c3c3c;
  border-radius: 2px;
}

body.vscode .auth-modal input:focus {
  border-color: #007fd4;
  outline: none;
}

body.vscode .auth-modal button[type="submit"] {
  background: #0e639c;
  border-radius: 2px;
}

body.vscode .auth-modal button[type="submit"]:hover {
  background: #1177bb;
}

body.vscode .auth-toggle a {
  color: #3794ff;
}

#sidebar {
  width: 260px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 12px;
}

#newChatBtn {
  width: 100%;
  text-align: left;
  background: var(--bg-muted);
  color: var(--text);
  border: 1px solid var(--border-strong);
  padding: 10px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  margin-bottom: 16px;
  transition: background 0.2s;
}

#newChatBtn:hover {
  background: var(--border-strong);
}

#chatHistoryList {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 2px;
}

.history-item {
  width: 100%;
  padding: 10px;
  background: transparent;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-muted);
  transition: background 0.2s, color 0.2s;
}

.history-item:hover {
  background: var(--bg-muted);
  color: var(--text);
}

.history-item.active {
  background: var(--bg-muted);
  color: var(--text);
  font-weight: 600;
}

#mainContent {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

header {
  position: relative;
  padding: 14px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
  display: flex;
  justify-content: space-between;
  align-items: center;
  backdrop-filter: blur(18px);
  z-index: 20;
  overflow: visible;
}

.brand {
  display: flex;
  flex-direction: column;
}

.brand .title {
  font-size: 18px;
  font-weight: 600;
}

.brand .subtitle {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 400;
  margin-top: 2px;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  position: relative;
  align-items: center;
  z-index: 21;
}

button {
  background: var(--primary);
  border: none;
  padding: 8px 12px;
  cursor: pointer;
  border-radius: 8px;
  color: white;
  font-size: 13px;
  transition: background 0.2s, box-shadow 0.2s, transform 0.2s;
}

button:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
}

.mode-btn {
  background: var(--bg-muted);
  border: 1px solid var(--border-strong);
  color: var(--text);
}

.mode-btn:hover {
  background: var(--border-strong);
}

.mode-btn.active {
  background: var(--primary);
  border-color: var(--primary-active-border);
  box-shadow: 0 0 10px var(--primary-glow);
  color: #fff;
}

#themeToggleBtn {
  background: linear-gradient(135deg, #7c3aed 0%, #db2777 100%);
  box-shadow: 0 10px 24px rgba(124, 58, 237, 0.22);
}

.tooltip {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 12px;
  width: 260px;
  display: none;
  z-index: 1000;
  line-height: 1.4;
  color: var(--text);
  box-shadow: var(--tooltip-shadow);
  backdrop-filter: blur(16px);
  pointer-events: none;
}

body.light-theme .tooltip {
  background: rgba(255, 255, 255, 0.98);
}

#chatContainer {
  flex: 1;
  overflow-y: auto;
  position: relative;
  display: flex;
  flex-direction: column;
}

#chat {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.msg {
  padding: 12px 14px;
  border-radius: 12px;
  max-width: 75%;
  line-height: 1.5;
  font-size: 14px;
  animation: fadeIn 0.2s ease-in;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.user {
  background: var(--primary);
  color: white;
  align-self: flex-end;
}

.user .markdown-body p {
  text-align: right;
}

.ai {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  align-self: flex-start;
}

#presetsContainer {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding: 20px;
  justify-content: center;
  align-content: center;
  flex: 1;
  max-width: 800px;
  margin: 0 auto;
}

.preset-box {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  width: calc(50% - 6px);
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
  font-size: 14px;
  color: var(--text);
  display: flex;
  align-items: center;
  min-height: 80px;
}

.preset-box:hover {
  background: var(--bg-muted);
  border-color: var(--border-strong);
  color: var(--text);
}

#inputWrapper {
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--border);
  background: var(--bg-elevated);
  padding: 12px 0 6px 0;
  backdrop-filter: blur(18px);
}

#inputArea {
  display: flex;
  padding: 0 12px 12px 12px;
  gap: 8px;
  max-width: 900px;
  margin: 0 auto;
  width: 100%;
}

textarea {
  flex: 1;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px;
  border-radius: 10px;
  outline: none;
  resize: none;
  font-family: inherit;
  font-size: 14px;
}

textarea:focus {
  border-color: var(--primary);
}

.disclaimer {
  text-align: center;
  font-size: 11px;
  color: var(--text-soft);
  padding: 0 12px;
}

.markdown-body {
  word-wrap: break-word;
}

.markdown-body p {
  margin: 0 0 10px 0;
}

.markdown-body p:last-child {
  margin-bottom: 0;
}

.markdown-body pre {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 32px 12px 12px 12px;
  margin-top: 8px;
  position: relative;
  font-family: monospace;
  font-size: 13px;
  overflow-x: auto;
}

.markdown-body code:not(pre code) {
  background: var(--bg-muted);
  padding: 2px 4px;
  border-radius: 4px;
  font-family: inherit;
  font-size: 0.9em;
  color: var(--accent);
}

.markdown-body pre code {
  background: transparent;
  padding: 0;
  border-radius: 0;
  white-space: pre;
  color: inherit;
}

.copy-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  font-size: 11px;
  background: var(--primary);
  border: none;
  color: white;
  padding: 4px 6px;
  border-radius: 5px;
  cursor: pointer;
  z-index: 10;
}

.auth-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: var(--overlay);
  backdrop-filter: blur(4px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
}

.auth-modal {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  width: 320px;
  padding: 24px;
  border-radius: 12px;
  box-shadow: var(--modal-shadow);
  display: flex;
  flex-direction: column;
}

.auth-modal-shell {
  position: relative;
}

.auth-close-btn {
  position: absolute;
  top: 12px;
  right: 16px;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 20px;
  line-height: 1;
}

.auth-error {
  color: #ef4444;
  margin-bottom: 10px;
  font-size: 13px;
  text-align: center;
}

.auth-modal h2 {
  margin-top: 0;
  margin-bottom: 16px;
  text-align: center;
  font-size: 18px;
}

.auth-modal input {
  box-sizing: border-box;
  width: 100%;
  padding: 10px 12px;
  margin-bottom: 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  font-family: inherit;
  font-size: 14px;
}

.two-factor-container {
  margin-bottom: 12px;
  text-align: left;
}

.two-factor-label {
  font-size: 13px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.two-factor-checkbox {
  width: auto;
  margin: 0;
}

.verify-help {
  font-size: 12px;
  margin-bottom: 16px;
  color: var(--text-muted);
  text-align: center;
}

.verify-code-input {
  text-align: center;
  letter-spacing: 6px;
  font-weight: bold;
  font-size: 18px;
}

.auth-modal button[type="submit"] {
  box-sizing: border-box;
  width: 100%;
  padding: 10px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  transition: background 0.2s;
}

.auth-toggle {
  text-align: center;
  font-size: 12px;
  margin-top: 16px;
  margin-bottom: 0;
  color: var(--text-muted);
}

.auth-toggle-tight {
  margin-top: 8px;
}

.auth-toggle a {
  color: var(--primary);
  text-decoration: none;
}

.auth-toggle a:hover {
  text-decoration: underline;
}

body.light-theme .msg.user,
body.light-theme .copy-btn,
body.light-theme .auth-modal button[type="submit"] {
  background: linear-gradient(135deg, #7c3aed 0%, #a855f7 52%, #ec4899 100%);
}

body.light-theme .homepage {
  background:
    radial-gradient(circle at top left, rgba(124, 58, 237, 0.18), transparent 34%),
    radial-gradient(circle at bottom right, rgba(236, 72, 153, 0.18), transparent 28%),
    linear-gradient(135deg, #f8fafc 0%, #eef2ff 48%, #fff7ed 100%);
}

body.light-theme .homepage-content {
  background: rgba(255, 255, 255, 0.78);
  border-color: rgba(99, 102, 241, 0.16);
  box-shadow: 0 24px 80px rgba(99, 102, 241, 0.16);
}

body.light-theme .homepage-kicker {
  color: #6d28d9;
}

body.light-theme .homepage-secondary {
  color: var(--text);
  border-color: rgba(109, 40, 217, 0.22);
}

body.light-theme .homepage-secondary:hover {
  background: rgba(109, 40, 217, 0.08);
}

body.light-theme .mouse-scroller-shell {
  border-color: rgba(109, 40, 217, 0.28);
}

body.light-theme .mouse-scroller-wheel {
  background: #7c3aed;
}

body.light-theme .preset-box,
body.light-theme .auth-modal,
body.light-theme textarea,
body.light-theme #inputWrapper,
body.light-theme header {
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

body.light-theme .user .markdown-body p {
  color: #fff;
}

@media (max-width: 960px) {
  header {
    align-items: flex-start;
    gap: 12px;
  }

  .controls {
    justify-content: flex-start;
  }
}

@media (max-width: 720px) {
  body {
    flex-direction: column;
    min-height: 100vh;
  }

  .homepage {
    padding: 24px 16px;
  }

  .homepage-content {
    padding: 28px 20px;
  }

  .homepage h1 {
    max-width: none;
    font-size: clamp(2.25rem, 13vw, 3.5rem);
  }

  .mouse-scroller {
    margin-top: 28px;
  }

  #sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .preset-box {
    width: 100%;
  }
}
