/* Nova-Link — Dark futuristic dashboard */
:root {
  --bg: #0a0a0f;
  --bg-card: #14141f;
  --bg-card-hover: #1a1a2e;
  --border: #2a2a3e;
  --text: #e0e0e8;
  --text-dim: #8888a0;
  --accent: #6c5ce7;
  --accent-glow: rgba(108, 92, 231, 0.3);
  --green: #00e676;
  --red: #ff5252;
  --yellow: #ffd740;
  --radius: 12px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* --- Header --- */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(10, 10, 15, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header h1 {
  font-size: 20px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent), #a29bfe);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 8px;
}

.status-dot.healthy { background: var(--green); box-shadow: 0 0 8px var(--green); }
.status-dot.unhealthy { background: var(--red); box-shadow: 0 0 8px var(--red); }
.status-dot.unknown { background: var(--yellow); }

/* --- Navigation --- */
.nav {
  display: flex;
  gap: 4px;
  padding: 8px 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.nav button {
  flex-shrink: 0;
  padding: 8px 16px;
  border: none;
  border-radius: 20px;
  background: transparent;
  color: var(--text-dim);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.nav button.active {
  background: var(--accent);
  color: white;
  box-shadow: 0 2px 12px var(--accent-glow);
}

/* --- Pages --- */
.page { display: none; padding: 16px; }
.page.active { display: block; }

/* --- Cards --- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  transition: all 0.2s;
}

.card:active { transform: scale(0.98); background: var(--bg-card-hover); }

.card-title {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-dim);
  margin-bottom: 8px;
}

.card-value {
  font-size: 28px;
  font-weight: 700;
}

.card-detail {
  font-size: 13px;
  color: var(--text-dim);
  margin-top: 4px;
}

/* --- Grid --- */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }

/* --- Health checks list --- */
.check-item {
  display: flex;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

.check-item:last-child { border-bottom: none; }

.check-icon { margin-right: 10px; font-size: 16px; }
.check-name { font-weight: 500; flex: 1; }
.check-detail { color: var(--text-dim); font-size: 12px; text-align: right; max-width: 50%; }

/* --- Chat --- */
.chat-container {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 130px);
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 0;
  -webkit-overflow-scrolling: touch;
}

.chat-bubble {
  max-width: 85%;
  padding: 12px 16px;
  border-radius: 16px;
  margin-bottom: 8px;
  font-size: 15px;
  line-height: 1.4;
  word-wrap: break-word;
  white-space: pre-wrap;
}

.chat-bubble.user {
  background: var(--accent);
  color: white;
  margin-left: auto;
  border-bottom-right-radius: 4px;
}

.chat-bubble.assistant {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

.chat-input-bar {
  display: flex;
  gap: 8px;
  padding: 12px 0;
  border-top: 1px solid var(--border);
}

.chat-input-bar input {
  flex: 1;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 24px;
  background: var(--bg-card);
  color: var(--text);
  font-size: 16px;
  outline: none;
}

.chat-input-bar input:focus { border-color: var(--accent); }

.chat-input-bar button {
  padding: 12px 20px;
  border: none;
  border-radius: 24px;
  background: var(--accent);
  color: white;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}

.chat-input-bar button:disabled { opacity: 0.5; }

/* --- Chat mode bar --- */
.chat-mode-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.mode-btn {
  padding: 6px 16px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: transparent;
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.mode-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.tts-btn {
  margin-left: auto;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
}

.tts-btn.active {
  color: var(--accent);
  border-color: var(--accent);
}

/* --- Voice settings panel --- */
.voice-settings {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 8px;
}

.voice-setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.voice-setting-row:last-of-type { border-bottom: none; }

.voice-setting-row label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  flex-shrink: 0;
  width: 50px;
}

.voice-setting-row select {
  flex: 1;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  outline: none;
  -webkit-appearance: none;
}

.speed-control {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
}

.speed-control input[type="range"] {
  flex: 1;
  -webkit-appearance: none;
  height: 4px;
  border-radius: 2px;
  background: var(--border);
  outline: none;
}

.speed-control input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
}

.speed-control span {
  font-size: 13px;
  color: var(--text-dim);
  min-width: 35px;
  text-align: right;
}

/* --- Voice input --- */
.voice-input-bar {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 20px 0;
  border-top: 1px solid var(--border);
}

.voice-status {
  font-size: 14px;
  color: var(--text-dim);
  text-align: center;
}

.mic-btn {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.mic-btn:active { transform: scale(0.95); }

.mic-btn.listening {
  border-color: var(--red);
  background: rgba(255, 82, 82, 0.15);
  color: var(--red);
  animation: pulse-ring 1.5s ease-in-out infinite;
}

@keyframes pulse-ring {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 82, 82, 0.3); }
  50% { box-shadow: 0 0 0 12px rgba(255, 82, 82, 0); }
}

.voice-transcript {
  font-size: 15px;
  color: var(--text);
  text-align: center;
  min-height: 20px;
  max-width: 90%;
  word-wrap: break-word;
}

/* --- Reports list --- */
.report-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.report-item:active { background: var(--bg-card-hover); }

.report-name {
  font-size: 14px;
  font-weight: 500;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.report-meta {
  font-size: 12px;
  color: var(--text-dim);
  text-align: right;
  flex-shrink: 0;
  margin-left: 12px;
}

/* --- Report detail --- */
.report-content {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  font-size: 14px;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-x: auto;
}

.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: transparent;
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
  margin-bottom: 12px;
}

/* --- Services --- */
.service-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 8px;
}

.service-name { font-weight: 500; font-size: 14px; }

.service-badge {
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
}

.service-badge.active { background: rgba(0, 230, 118, 0.15); color: var(--green); }
.service-badge.inactive { background: rgba(255, 82, 82, 0.15); color: var(--red); }

/* --- Controls --- */
.control-btn {
  width: 100%;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  color: var(--text);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  margin-bottom: 8px;
  transition: all 0.2s;
}

.control-btn:active { background: var(--bg-card-hover); transform: scale(0.98); }
.control-btn.primary { background: var(--accent); border-color: var(--accent); color: white; }

/* --- Loading --- */
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* --- Toast --- */
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  padding: 12px 24px;
  background: var(--bg-card);
  border: 1px solid var(--accent);
  border-radius: 24px;
  font-size: 14px;
  z-index: 200;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}

.toast.show { opacity: 1; }

/* Safe areas for iPhone notch */
@supports (padding-top: env(safe-area-inset-top)) {
  .header { padding-top: calc(16px + env(safe-area-inset-top)); }
  .chat-input-bar { padding-bottom: env(safe-area-inset-bottom); }
}
