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

:root {
  --bg-primary: #0a0a1a;
  --bg-secondary: #0d1117;
  --bg-card: rgba(13, 17, 23, 0.8);
  --accent: #00d4ff;
  --accent-dim: rgba(0, 212, 255, 0.15);
  --accent-glow: rgba(0, 212, 255, 0.4);
  --text-primary: #e0e6ed;
  --text-secondary: #7a8ba3;
  --text-dim: #3d4f65;
  --success: #00ff88;
  --error: #ff4466;
  --warning: #ffaa00;
  --border: rgba(0, 212, 255, 0.1);
  --font-display: 'Orbitron', monospace;
  --font-body: 'Rajdhani', 'Segoe UI', sans-serif;
}

html, body {
  height: 100%;
  font-family: var(--font-body);
  background: var(--bg-primary);
  color: var(--text-primary);
  overflow-x: hidden;
}

/* ===== Particle Canvas ===== */
#particles {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

#visualizer {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 120px;
  z-index: 0;
  pointer-events: none;
  opacity: 0.3;
}

/* ===== Container ===== */
.container {
  position: relative;
  z-index: 1;
  max-width: 800px;
  margin: 0 auto;
  padding: 30px 20px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ===== Header ===== */
.header {
  text-align: center;
  margin-bottom: 30px;
}

.logo {
  font-family: var(--font-display);
  font-size: 2.2rem;
  font-weight: 900;
  letter-spacing: 6px;
  margin-bottom: 4px;
}

.logo-bracket {
  color: var(--text-dim);
}

.logo-text {
  background: linear-gradient(135deg, var(--accent), #0088cc);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: none;
  filter: drop-shadow(0 0 20px var(--accent-glow));
}

.subtitle {
  font-family: var(--font-display);
  font-size: 0.7rem;
  letter-spacing: 4px;
  color: var(--text-secondary);
  text-transform: uppercase;
}

.status-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 12px;
  font-family: var(--font-display);
  font-size: 0.65rem;
  letter-spacing: 3px;
  text-transform: uppercase;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-secondary);
  transition: background 0.3s;
}

.status-dot.listening {
  background: var(--success);
  box-shadow: 0 0 12px var(--success);
  animation: pulse-dot 1s infinite;
}

.status-dot.processing {
  background: var(--warning);
  box-shadow: 0 0 12px var(--warning);
  animation: pulse-dot 0.5s infinite;
}

.status-dot.error {
  background: var(--error);
  box-shadow: 0 0 12px var(--error);
}

.status-text {
  color: var(--text-secondary);
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ===== Central Orb ===== */
.orb-container {
  position: relative;
  width: 200px;
  height: 200px;
  margin: 10px 0 30px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.orb-rings {
  position: absolute;
  width: 100%;
  height: 100%;
}

.ring {
  position: absolute;
  top: 50%;
  left: 50%;
  border: 1px solid var(--accent-dim);
  border-radius: 50%;
  transform: translate(-50%, -50%);
}

.ring-1 {
  width: 160px;
  height: 160px;
  animation: spin-ring 8s linear infinite;
  border-style: dashed;
}

.ring-2 {
  width: 180px;
  height: 180px;
  animation: spin-ring 12s linear infinite reverse;
  border-color: rgba(0, 212, 255, 0.08);
}

.ring-3 {
  width: 200px;
  height: 200px;
  animation: spin-ring 20s linear infinite;
  border-color: rgba(0, 212, 255, 0.05);
  border-style: dotted;
}

@keyframes spin-ring {
  from { transform: translate(-50%, -50%) rotate(0deg); }
  to { transform: translate(-50%, -50%) rotate(360deg); }
}

.orb {
  position: relative;
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #00e5ff, #0066aa, #003366);
  box-shadow:
    0 0 40px var(--accent-glow),
    0 0 80px rgba(0, 212, 255, 0.2),
    inset 0 0 30px rgba(0, 0, 0, 0.3);
  transition: transform 0.3s, box-shadow 0.3s;
}

.orb.listening {
  transform: scale(1.15);
  box-shadow:
    0 0 60px var(--accent-glow),
    0 0 120px rgba(0, 212, 255, 0.3),
    inset 0 0 30px rgba(0, 0, 0, 0.2);
  animation: orb-pulse 1.5s ease-in-out infinite;
}

.orb.processing {
  animation: orb-spin 1s linear infinite;
}

@keyframes orb-pulse {
  0%, 100% { transform: scale(1.15); }
  50% { transform: scale(1.25); }
}

@keyframes orb-spin {
  from { transform: rotate(0deg) scale(1.1); }
  to { transform: rotate(360deg) scale(1.1); }
}

.orb-core {
  position: absolute;
  top: 20%;
  left: 20%;
  width: 30%;
  height: 30%;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  filter: blur(8px);
}

.orb-glow {
  position: absolute;
  top: -20%;
  left: -20%;
  width: 140%;
  height: 140%;
  border-radius: 50%;
  background: radial-gradient(circle, var(--accent-glow), transparent 70%);
  opacity: 0.4;
  pointer-events: none;
}

.mic-btn {
  position: absolute;
  bottom: -15px;
  left: 50%;
  transform: translateX(-50%);
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: var(--bg-secondary);
  border: 2px solid var(--accent-dim);
  color: var(--accent);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s;
  z-index: 2;
}

.mic-btn:hover {
  border-color: var(--accent);
  box-shadow: 0 0 20px var(--accent-glow);
  transform: translateX(-50%) scale(1.1);
}

.mic-btn.active {
  background: var(--accent);
  color: var(--bg-primary);
  border-color: var(--accent);
  box-shadow: 0 0 30px var(--accent-glow);
  animation: mic-pulse 1s infinite;
}

@keyframes mic-pulse {
  0%, 100% { box-shadow: 0 0 30px var(--accent-glow); }
  50% { box-shadow: 0 0 50px var(--accent-glow), 0 0 80px rgba(0, 212, 255, 0.15); }
}

/* ===== Transcript ===== */
.transcript-section {
  width: 100%;
  margin-bottom: 16px;
}

.transcript-label,
.response-label,
.history-label {
  font-family: var(--font-display);
  font-size: 0.6rem;
  letter-spacing: 3px;
  color: var(--text-dim);
  text-transform: uppercase;
  margin-bottom: 8px;
  padding-left: 4px;
}

.transcript {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 20px;
  min-height: 50px;
  font-size: 1.1rem;
  font-weight: 500;
  color: var(--accent);
  backdrop-filter: blur(10px);
  transition: border-color 0.3s;
}

.transcript.active {
  border-color: var(--accent);
  box-shadow: 0 0 20px rgba(0, 212, 255, 0.1);
}

.transcript .placeholder {
  color: var(--text-dim);
  font-style: italic;
  font-weight: 300;
}

.transcript .interim {
  color: var(--text-secondary);
  font-style: italic;
}

/* ===== Text Input ===== */
.input-section {
  width: 100%;
  margin-bottom: 20px;
}

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

#textInput {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 18px;
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 500;
  color: var(--text-primary);
  outline: none;
  backdrop-filter: blur(10px);
  transition: border-color 0.3s;
}

#textInput:focus {
  border-color: var(--accent);
  box-shadow: 0 0 20px rgba(0, 212, 255, 0.1);
}

#textInput::placeholder {
  color: var(--text-dim);
}

.send-btn {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: var(--accent-dim);
  border: 1px solid var(--border);
  color: var(--accent);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s;
}

.send-btn:hover {
  background: var(--accent);
  color: var(--bg-primary);
  border-color: var(--accent);
}

/* ===== Response ===== */
.response-section {
  width: 100%;
  margin-bottom: 20px;
  display: none;
}

.response-section.visible {
  display: block;
  animation: fade-in 0.4s ease;
}

.response {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 22px;
  font-size: 1.05rem;
  font-weight: 400;
  line-height: 1.6;
  color: var(--text-primary);
  backdrop-filter: blur(10px);
}

.response .type-tag {
  display: inline-block;
  font-family: var(--font-display);
  font-size: 0.55rem;
  letter-spacing: 2px;
  text-transform: uppercase;
  padding: 2px 10px;
  border-radius: 4px;
  margin-bottom: 8px;
}

.response .type-tag.system { background: rgba(0, 255, 136, 0.15); color: var(--success); }
.response .type-tag.web { background: rgba(0, 212, 255, 0.15); color: var(--accent); }
.response .type-tag.utility { background: rgba(255, 170, 0, 0.15); color: var(--warning); }
.response .type-tag.error { background: rgba(255, 68, 102, 0.15); color: var(--error); }
.response .type-tag.fallback { background: rgba(122, 139, 163, 0.15); color: var(--text-secondary); }
.response .type-tag.outlook { background: rgba(0, 120, 212, 0.2); color: #4da6ff; }
.response .type-tag.sharepoint { background: rgba(3, 131, 104, 0.2); color: #00c9a7; }

/* Microsoft Auth Status */
.ms-auth {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  font-family: var(--font-display);
  font-size: 0.55rem;
  letter-spacing: 2px;
  text-transform: uppercase;
}

.ms-auth-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--error);
}

.ms-auth-dot.connected {
  background: var(--success);
  box-shadow: 0 0 8px rgba(0, 255, 136, 0.5);
}

.ms-auth-text {
  color: var(--text-dim);
}

.ms-auth-link {
  color: var(--accent);
  cursor: pointer;
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s;
}

.ms-auth-link:hover {
  border-bottom-color: var(--accent);
}

/* Response whitespace for multi-line */
.response div {
  white-space: pre-wrap;
}

/* ===== History ===== */
.history-section {
  width: 100%;
  margin-top: auto;
}

.history {
  max-height: 250px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.history::-webkit-scrollbar {
  width: 4px;
}

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

.history::-webkit-scrollbar-thumb {
  background: var(--text-dim);
  border-radius: 2px;
}

.history-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  background: rgba(13, 17, 23, 0.5);
  border: 1px solid rgba(0, 212, 255, 0.05);
  border-radius: 8px;
  font-size: 0.85rem;
  animation: fade-in 0.3s ease;
}

.history-item .h-time {
  font-family: var(--font-display);
  font-size: 0.6rem;
  color: var(--text-dim);
  letter-spacing: 1px;
  min-width: 55px;
}

.history-item .h-icon {
  font-size: 0.9rem;
}

.history-item .h-text {
  color: var(--text-secondary);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-item .h-status {
  font-size: 0.7rem;
  font-family: var(--font-display);
  letter-spacing: 1px;
}

.history-item .h-status.ok { color: var(--success); }
.history-item .h-status.fail { color: var(--error); }

/* ===== Animations ===== */
@keyframes fade-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Typing animation for response text */
.typing-cursor::after {
  content: '|';
  animation: blink 0.7s infinite;
  color: var(--accent);
  margin-left: 2px;
}

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

/* ===== Responsive ===== */
@media (max-width: 600px) {
  .logo { font-size: 1.5rem; letter-spacing: 3px; }
  .subtitle { font-size: 0.55rem; }
  .orb-container { width: 150px; height: 150px; }
  .orb { width: 75px; height: 75px; }
  .ring-1 { width: 120px; height: 120px; }
  .ring-2 { width: 135px; height: 135px; }
  .ring-3 { width: 150px; height: 150px; }
}
