/*
 * jj-chatbot frontend styles — jeepjohn.com Cyber-Goth palette
 * Primary: neon green #39ff14, Cyan #00e5ff, Violet #b388ff, Deep black #050507
 */

/* === CSS Custom Properties === */
:root {
  /* Palette */
  --color-bg: #050507;
  --color-bg-alt: #0b0d12;
  --color-primary: #39ff14;
  --color-cyan: #00e5ff;
  --color-violet: #b388ff;
  --color-accent: #b6ff00;
  --color-gold: #ffcc66;
  --color-text: #d8ffe8;
  --color-text-dim: #a8c9a8;

  /* Bubbles */
  --color-user-bg: rgba(179, 136, 255, 0.12);
  --color-user-border: rgba(179, 136, 255, 0.35);
  --color-assistant-bg: rgba(57, 255, 20, 0.08);
  --color-assistant-border: rgba(57, 255, 20, 0.25);

  /* System */
  --color-error: #ff66aa;
  --color-error-bg: rgba(255, 0, 51, 0.1);

  /* Layout */
  --header-height: 56px;
  --sidebar-width: 280px;
  --font-stack: "Orbitron", "Rajdhani", "Eurostile", "Consolas", "Courier New", monospace;
  --border-glow: 0 0 6px rgba(57, 255, 20, 0.4);
  --text-glow: 0 0 4px rgba(57, 255, 20, 0.6);
}

/* === Reset === */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* === Base === */
html {
  font-size: 16px;
  height: 100%;
}

body {
  font-family: var(--font-stack);
  background: var(--color-bg);
  color: var(--color-text);
  min-height: 100vh;
  overflow: hidden;
}

/* HTML5 [hidden] must beat authored display rules below.
   Without this, #age-gate {display:flex} and #app {display:flex}
   override the hidden attribute and the modal never dismisses. */
[hidden] { display: none !important; }

/* === Age Gate Modal === */
#age-gate {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(5, 5, 7, 0.85);
}

#age-gate .modal-content {
  background: var(--color-bg-alt);
  border: 1px solid var(--color-primary);
  box-shadow: var(--border-glow), 0 0 40px rgba(57, 255, 20, 0.15);
  padding: 2rem 2.5rem;
  max-width: 520px;
  width: 90%;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

#age-gate h2 {
  color: var(--color-primary);
  text-shadow: var(--text-glow);
  font-size: 1.4rem;
  text-align: center;
}

#age-gate-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

#age-gate-form label {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  cursor: pointer;
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--color-text);
}

#age-gate-form input[type="checkbox"] {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  accent-color: var(--color-primary);
  cursor: pointer;
  margin-top: 0.15rem;
}

#age-gate-form button {
  font-family: var(--font-stack);
  font-size: 1.05rem;
  padding: 0.65rem 1.5rem;
  background: var(--color-primary);
  color: var(--color-bg);
  border: none;
  cursor: pointer;
  box-shadow: var(--border-glow);
  transition: box-shadow 0.2s, opacity 0.2s;
}

#age-gate-form button:disabled {
  opacity: 0.4;
  cursor: default;
  box-shadow: none;
}

#age-gate-form button:not(:disabled):hover {
  box-shadow: 0 0 14px rgba(57, 255, 20, 0.6);
}

/* === Offline Banner === */
.offline-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 9000;
  background: #ff0033;
  color: #fff;
  text-align: center;
  padding: 0.5rem 1rem;
  font-size: 0.95rem;
  font-family: var(--font-stack);
  text-shadow: 0 0 3px rgba(255, 255, 255, 0.5);
}

/* === Truth banner (persistent warning strip) === */
.truth-banner {
  padding: 0.55rem 1rem;
  margin: 0 1rem 0.5rem 1rem;
  border: 1px solid #ffcc00;
  border-radius: 4px;
  background: rgba(255, 204, 0, 0.08);
  color: #ffd54a;
  font-size: 0.82rem;
  font-family: var(--font-stack);
  line-height: 1.35;
  text-align: center;
  text-shadow: 0 0 4px rgba(255, 204, 0, 0.35);
  flex-shrink: 0;
}
.truth-banner strong {
  color: #ffe58a;
  font-weight: 600;
}

/* === Main App === */
#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-height: 100vh;
}

/* === Header === */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 1.25rem;
  border-bottom: 1px solid rgba(57, 255, 20, 0.25);
  background: rgba(0, 0, 0, 0.3);
  flex-shrink: 0;
  min-height: var(--header-height);
}

header h1 {
  font-size: 1.15rem;
  color: var(--color-primary);
  text-shadow: var(--text-glow);
  letter-spacing: 0.05em;
  margin: 0;
}

#reset-session {
  font-family: var(--font-stack);
  font-size: 0.85rem;
  padding: 0.35rem 0.9rem;
  background: transparent;
  color: var(--color-cyan);
  border: 1px solid var(--color-cyan);
  cursor: pointer;
  transition: background 0.2s, box-shadow 0.2s;
}

#reset-session:hover {
  background: rgba(0, 229, 255, 0.1);
  box-shadow: 0 0 6px rgba(0, 229, 255, 0.3);
}

/* === Layout === */
.layout {
  display: flex;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

/* === Chat Section === */
#chat {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 0;
  overflow: hidden;
}

#chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-height: 0;
}

/* Chat bubbles */
.chat-message {
  max-width: 85%;
  padding: 0.6rem 1rem;
  border-radius: 4px;
  line-height: 1.55;
  font-size: 0.95rem;
  word-wrap: break-word;
  white-space: pre-wrap;
}

.chat-message.user {
  align-self: flex-end;
  background: var(--color-user-bg);
  border: 1px solid var(--color-user-border);
  color: var(--color-text);
}

.chat-message.assistant {
  align-self: flex-start;
  background: var(--color-assistant-bg);
  border: 1px solid var(--color-assistant-border);
  color: var(--color-text);
}

.chat-message.system {
  align-self: center;
  background: transparent;
  border: none;
  color: var(--color-text-dim);
  font-size: 0.85rem;
  text-align: center;
  max-width: 100%;
}

.chat-message.error {
  border-color: var(--color-error);
  color: var(--color-error);
}

/* Server-side tool activity indicators (search / fetch). */
.chat-message.tool-status {
  font-family: var(--font-mono, Consolas, monospace);
  font-size: 0.8rem;
  opacity: 0.85;
}
.chat-message.tool-status.tool-running {
  color: var(--color-accent, #00e5ff);
  animation: tool-pulse 1s ease-in-out infinite;
}
.chat-message.tool-status.tool-done {
  color: var(--color-primary, #39ff14);
}
.chat-message.tool-status.tool-error {
  color: var(--color-error);
}
@keyframes tool-pulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

.streaming-cursor::after {
  content: "▋";
  animation: blink 0.8s step-end infinite;
  color: var(--color-primary);
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* === Chat Input Form === */
#chat-form {
  display: flex;
  flex-direction: column;
  padding: 0.75rem 1.25rem;
  border-top: 1px solid rgba(57, 255, 20, 0.2);
  background: rgba(0, 0, 0, 0.25);
  flex-shrink: 0;
  gap: 0.5rem;
}

#chat-input {
  font-family: var(--font-stack);
  font-size: 0.95rem;
  padding: 0.55rem 0.75rem;
  background: var(--color-bg-alt);
  color: var(--color-text);
  border: 1px solid rgba(57, 255, 20, 0.25);
  resize: none;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  min-height: 3rem;
}

#chat-input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 4px rgba(57, 255, 20, 0.25);
}

#chat-submit {
  font-family: var(--font-stack);
  font-size: 0.95rem;
  padding: 0.5rem 1.5rem;
  background: var(--color-primary);
  color: var(--color-bg);
  border: none;
  cursor: pointer;
  box-shadow: var(--border-glow);
  transition: box-shadow 0.2s;
  align-self: flex-end;
}

#chat-submit:hover {
  box-shadow: 0 0 14px rgba(57, 255, 20, 0.6);
}

#chat-submit:disabled {
  opacity: 0.4;
  cursor: default;
  box-shadow: none;
}

/* === Personality Panel === */
#personality-panel {
  width: var(--sidebar-width);
  min-width: 200px;
  background: rgba(0, 0, 0, 0.25);
  border-left: 1px solid rgba(57, 255, 20, 0.2);
  padding: 1rem;
  overflow-y: auto;
  flex-shrink: 0;
}

#personality-panel details {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

#personality-panel summary {
  font-family: var(--font-stack);
  font-size: 0.95rem;
  color: var(--color-cyan);
  cursor: pointer;
  user-select: none;
  padding: 0.25rem 0;
}

#personality-panel label {
  font-size: 0.8rem;
  color: var(--color-text-dim);
  display: block;
  margin-bottom: 0.15rem;
}

#personality-overlay {
  font-family: var(--font-stack);
  font-size: 0.85rem;
  padding: 0.45rem 0.6rem;
  background: var(--color-bg-alt);
  color: var(--color-text);
  border: 1px solid rgba(0, 229, 255, 0.25);
  resize: vertical;
  outline: none;
  transition: border-color 0.2s;
  line-height: 1.45;
  width: 100%;
}

#personality-overlay:focus {
  border-color: var(--color-cyan);
  box-shadow: 0 0 4px rgba(0, 229, 255, 0.2);
}

.quick-traits {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
}

.quick-traits button {
  font-family: var(--font-stack);
  font-size: 0.72rem;
  padding: 0.25rem 0.55rem;
  background: transparent;
  color: var(--color-cyan);
  border: 1px solid var(--color-cyan);
  cursor: pointer;
  transition: background 0.2s, box-shadow 0.2s;
}

.quick-traits button:hover {
  background: rgba(0, 229, 255, 0.1);
  box-shadow: 0 0 4px rgba(0, 229, 255, 0.25);
}

.personality-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 0.25rem;
}

.personality-actions button {
  font-family: var(--font-stack);
  font-size: 0.75rem;
  padding: 0.2rem 0.6rem;
  background: transparent;
  color: var(--color-primary);
  border: 1px solid var(--color-primary);
  cursor: pointer;
  transition: background 0.2s, box-shadow 0.2s;
}

.personality-actions button:hover {
  background: rgba(57, 255, 20, 0.1);
  box-shadow: 0 0 4px rgba(57, 255, 20, 0.25);
}

#overlay-count {
  font-size: 0.75rem;
  color: var(--color-text-dim);
}

#personality-status {
  font-size: 0.75rem;
  color: var(--color-primary);
  margin-top: 0.25rem;
  min-height: 1.2em;
}

/* === Focus States === */
*:focus-visible {
  outline: 2px solid var(--color-cyan);
  outline-offset: 2px;
}

/* === Mobile === */
@media (max-width: 768px) {
  #personality-panel {
    width: 100%;
    min-width: unset;
    border-left: none;
    border-top: 1px solid rgba(57, 255, 20, 0.2);
    max-height: 40vh;
    flex-shrink: 0;
  }

  .layout {
    flex-direction: column;
  }

  header h1 {
    font-size: 0.95rem;
  }

  .chat-message {
    max-width: 95%;
  }
}

/* === Reduced Motion === */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
