/* ================================================================
   TECH IN TOWN — AI Technician Page
   Max Sullivan Chat Interface
   ================================================================ */

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

:root {
  --bg:        #060c18;
  --bg2:       #0a1628;
  --bg3:       #0e1a2e;
  --border:    #1e3a5f;
  --cyan:      #00d4ff;
  --cyan-dim:  rgba(0,212,255,.15);
  --green:     #00e676;
  --purple:    #7c3aed;
  --text:      #e2e8f0;
  --muted:     #8fa5c0;
  --dim:       #4a6280;
  --font:      'Space Grotesk', system-ui, sans-serif;
  --mono:      'JetBrains Mono', 'Fira Code', monospace;
  --nav-h:     60px;
}

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ---------------------------------------------------------------
   NAV
   --------------------------------------------------------------- */
.anav {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--nav-h);
  background: rgba(6,12,24,.95);
  border-bottom: 1px solid var(--border);
  z-index: 100;
}

.anav-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 24px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.alogo {
  font-family: var(--mono);
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  letter-spacing: .04em;
}
.alogo span { color: var(--cyan); }

.anav-right {
  display: flex;
  align-items: center;
  gap: 20px;
}

.astatus {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: .8rem;
  color: var(--muted);
}

.aback {
  font-size: .8rem;
  color: var(--muted);
  text-decoration: none;
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  transition: color .2s, border-color .2s;
}
.aback:hover { color: var(--cyan); border-color: var(--cyan); }

/* ---------------------------------------------------------------
   MAIN LAYOUT
   --------------------------------------------------------------- */
.ai-layout {
  display: flex;
  height: 100vh;
  padding-top: var(--nav-h);
}

/* ---------------------------------------------------------------
   LEFT ASIDE
   --------------------------------------------------------------- */
.ai-aside {
  width: 300px;
  flex-shrink: 0;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 28px 22px 32px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

/* Scrollbar */
.ai-aside::-webkit-scrollbar { width: 4px; }
.ai-aside::-webkit-scrollbar-track { background: transparent; }
.ai-aside::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* Orb */
.orb-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.orb {
  width: 100px;
  height: 100px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.orb-ring {
  position: absolute;
  border-radius: 50%;
  border: 1px solid var(--cyan);
}
.r1 { width: 100%; height: 100%; opacity: .25; animation: spin 8s linear infinite; }
.r2 { width: 78%;  height: 78%;  opacity: .4;  animation: spin 5s linear infinite reverse; }
.r3 { width: 56%;  height: 56%;  opacity: .6;  animation: spin 3s linear infinite; }

@keyframes spin {
  to { transform: rotate(360deg); }
}

.orb-core {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, var(--cyan), var(--purple));
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--mono);
  font-weight: 600;
  font-size: .85rem;
  color: #fff;
  position: relative;
  z-index: 1;
}

/* Equaliser bars */
.orb-eq {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 22px;
}
.orb-eq span {
  width: 3px;
  background: var(--cyan);
  border-radius: 2px;
  animation: eqbar 1.2s ease-in-out infinite;
  height: 6px;
}
.orb-eq span:nth-child(1) { animation-delay: 0s;    animation-duration: 1.1s; }
.orb-eq span:nth-child(2) { animation-delay: .15s;  animation-duration: 0.9s; }
.orb-eq span:nth-child(3) { animation-delay: .3s;   animation-duration: 1.3s; }
.orb-eq span:nth-child(4) { animation-delay: .1s;   animation-duration: 1.0s; }
.orb-eq span:nth-child(5) { animation-delay: .4s;   animation-duration: 1.2s; }
.orb-eq span:nth-child(6) { animation-delay: .2s;   animation-duration: 0.8s; }
.orb-eq span:nth-child(7) { animation-delay: .35s;  animation-duration: 1.4s; }

.orb-eq.active span {
  animation-play-state: running;
}
.orb-eq:not(.active) span {
  height: 4px !important;
  animation-play-state: paused;
}

@keyframes eqbar {
  0%, 100% { height: 4px; }
  50%       { height: 18px; }
}

/* Bio */
.ai-bio h1 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 2px;
}
.ai-role {
  font-size: .75rem;
  color: var(--cyan);
  font-family: var(--mono);
  letter-spacing: .08em;
  text-transform: uppercase;
  margin-bottom: 10px;
}
.ai-desc {
  font-size: .85rem;
  color: var(--muted);
  line-height: 1.6;
}

/* Tags */
.ai-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.ai-tags span {
  font-size: .72rem;
  padding: 3px 9px;
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--dim);
}

/* Quick topics */
.ai-quick-head {
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--dim);
  font-family: var(--mono);
}

.quick-topics {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.qtopic {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: .82rem;
  color: var(--muted);
  text-align: left;
  cursor: pointer;
  font-family: var(--font);
  transition: border-color .2s, color .2s, background .2s;
}
.qtopic:hover {
  border-color: var(--cyan);
  color: var(--cyan);
  background: var(--cyan-dim);
}

.book-tech-btn {
  display: block;
  background: transparent;
  border: 1px solid var(--cyan);
  border-radius: 8px;
  padding: 10px 16px;
  text-align: center;
  font-size: .85rem;
  font-weight: 600;
  color: var(--cyan);
  text-decoration: none;
  transition: background .2s;
}
.book-tech-btn:hover { background: var(--cyan-dim); }

/* Dot indicators */
.dot-green {
  display: inline-block;
  width: 8px; height: 8px;
  background: var(--green);
  border-radius: 50%;
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(0,230,118,.4); }
  50%       { box-shadow: 0 0 0 5px rgba(0,230,118,0); }
}

/* ---------------------------------------------------------------
   CHAT PANEL
   --------------------------------------------------------------- */
.ai-chat {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}

/* Messages */
.chat-msgs {
  flex: 1;
  overflow-y: auto;
  padding: 24px 28px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.chat-msgs::-webkit-scrollbar { width: 4px; }
.chat-msgs::-webkit-scrollbar-track { background: transparent; }
.chat-msgs::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* Message rows */
.msg {
  display: flex;
  gap: 12px;
  max-width: 780px;
}
.msg-user {
  flex-direction: row-reverse;
  margin-left: auto;
}

.msg-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--cyan), var(--purple));
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--mono);
  font-size: .72rem;
  font-weight: 600;
  color: #fff;
  flex-shrink: 0;
}

.msg-bubble {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px 18px;
  font-size: .9rem;
  line-height: 1.65;
  color: var(--text);
}
.msg-bubble p + p { margin-top: 8px; }
.msg-user .msg-bubble {
  background: var(--cyan-dim);
  border-color: rgba(0,212,255,.35);
}

/* Welcome tips */
.welcome-tips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}
.welcome-tips span {
  font-size: .78rem;
  color: var(--dim);
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 10px;
  font-family: var(--mono);
}

/* Code blocks in AI responses */
.msg-bubble code {
  font-family: var(--mono);
  background: var(--bg3);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: .85em;
  color: var(--cyan);
}
.msg-bubble pre {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  margin-top: 10px;
  overflow-x: auto;
  font-size: .82rem;
  line-height: 1.5;
}
.msg-bubble pre code {
  background: none;
  padding: 0;
  color: var(--text);
}
.msg-bubble .list-item {
  padding: 2px 0 2px 14px;
  font-size: .88rem;
  color: var(--text);
  line-height: 1.6;
  position: relative;
}

/* ---------------------------------------------------------------
   TYPING INDICATOR
   --------------------------------------------------------------- */
.typing-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 28px 12px;
}
.typing-indicator {
  display: flex;
  gap: 5px;
  align-items: center;
}
.typing-indicator span {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--cyan);
  animation: tdot .9s ease-in-out infinite;
}
.typing-indicator span:nth-child(2) { animation-delay: .15s; }
.typing-indicator span:nth-child(3) { animation-delay: .3s; }

@keyframes tdot {
  0%, 100% { opacity: .3; transform: scale(1); }
  50%       { opacity: 1;  transform: scale(1.3); }
}
.typing-label {
  font-size: .78rem;
  color: var(--dim);
  font-family: var(--mono);
}

/* ---------------------------------------------------------------
   INPUT AREA
   --------------------------------------------------------------- */
.chat-input-area {
  border-top: 1px solid var(--border);
  background: var(--bg2);
  padding: 16px 24px 14px;
}

.chat-input-wrap {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 10px 12px;
  transition: border-color .2s;
}
.chat-input-wrap:focus-within {
  border-color: var(--cyan);
}

.chat-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  font-family: var(--font);
  font-size: .92rem;
  color: var(--text);
  resize: none;
  line-height: 1.5;
  max-height: 140px;
  overflow-y: auto;
}
.chat-input::placeholder { color: var(--dim); }
.chat-input::-webkit-scrollbar { width: 3px; }
.chat-input::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.input-btns {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  flex-shrink: 0;
}

.mic-btn,
.send-btn {
  width: 38px; height: 38px;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .2s, color .2s, transform .1s;
}

.mic-btn {
  background: var(--bg2);
  color: var(--muted);
  border: 1px solid var(--border);
}
.mic-btn:hover { color: var(--cyan); border-color: var(--cyan); }
.mic-btn.recording {
  background: rgba(255,59,48,.15);
  border-color: #ff3b30;
  color: #ff3b30;
  animation: rec-pulse 1s ease-in-out infinite;
}
@keyframes rec-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255,59,48,.4); }
  50%       { box-shadow: 0 0 0 6px rgba(255,59,48,0); }
}

.send-btn {
  background: var(--cyan);
  color: #000;
}
.send-btn:hover  { background: #33ddff; transform: scale(1.05); }
.send-btn:active { transform: scale(.95); }
.send-btn:disabled {
  background: var(--border);
  color: var(--dim);
  cursor: not-allowed;
  transform: none;
}

.input-hint {
  margin-top: 8px;
  font-size: .72rem;
  color: var(--dim);
  display: flex;
  align-items: center;
  gap: 0;
  flex-wrap: wrap;
}
.input-hint kbd {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  font-family: var(--mono);
  font-size: .7rem;
  color: var(--muted);
}

.clear-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--dim);
  font-size: .72rem;
  font-family: var(--font);
  padding: 0;
  transition: color .2s;
}
.clear-btn:hover { color: #ff5f5f; }

/* ---------------------------------------------------------------
   VOICE BAR
   --------------------------------------------------------------- */
.voice-bar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: rgba(0,212,255,.1);
  border-top: 1px solid var(--cyan);
  z-index: 200;
}
.vb-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.vb-dots {
  display: flex;
  gap: 4px;
  align-items: center;
}
.vb-dots span {
  width: 4px;
  background: var(--cyan);
  border-radius: 2px;
  animation: eqbar .8s ease-in-out infinite;
}
.vb-dots span:nth-child(1) { animation-delay: 0s;   height: 8px;  animation-duration: 0.7s; }
.vb-dots span:nth-child(2) { animation-delay: .1s;  height: 14px; animation-duration: 0.9s; }
.vb-dots span:nth-child(3) { animation-delay: .2s;  height: 20px; animation-duration: 0.8s; }
.vb-dots span:nth-child(4) { animation-delay: .05s; height: 14px; animation-duration: 1.0s; }
.vb-dots span:nth-child(5) { animation-delay: .15s; height: 8px;  animation-duration: 0.75s; }

#voice-label {
  font-size: .85rem;
  color: var(--cyan);
  font-family: var(--mono);
  flex: 1;
}
.vb-stop {
  padding: 7px 18px;
  border: 1px solid #ff5f5f;
  border-radius: 6px;
  background: none;
  color: #ff5f5f;
  font-size: .82rem;
  cursor: pointer;
  font-family: var(--font);
  transition: background .2s;
}
.vb-stop:hover { background: rgba(255,95,95,.15); }

/* ---------------------------------------------------------------
   ERROR STATE
   --------------------------------------------------------------- */
.msg-error .msg-bubble {
  border-color: rgba(255,95,95,.4);
  color: #ff9494;
}

/* ---------------------------------------------------------------
   RESPONSIVE
   --------------------------------------------------------------- */
@media (max-width: 900px) {
  .ai-layout { flex-direction: column; height: auto; overflow: auto; }
  html, body { overflow: auto; }

  .ai-aside {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border);
    flex-direction: row;
    flex-wrap: wrap;
    overflow: visible;
    padding: 20px 16px;
  }
  .orb-wrap { display: none; }
  .ai-bio   { flex: 1 1 200px; }
  .ai-tags, .ai-quick-head, .quick-topics, .book-tech-btn { flex: 1 1 100%; }

  .ai-chat { height: calc(100vh - var(--nav-h) - 200px); min-height: 400px; }
  .chat-msgs { padding: 16px; }
}

@media (max-width: 600px) {
  .anav-inner { padding: 0 16px; }
  .astatus span:last-child { display: none; }
  .chat-msgs  { padding: 12px; }
  .chat-input-area { padding: 12px 14px 10px; }
  .msg { max-width: 100%; }
}
