/* Luna 6 Modern Chatbot & Voice Interface */

.luna-chat-shell {
  display: grid;
  grid-template-columns: 1fr 340px;
  height: calc(100vh - 52px);
  background: #f4f7f6;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  overflow: hidden;
}

@media (max-width: 960px) {
  .luna-chat-shell {
    grid-template-columns: 1fr;
  }
  .luna-dossier-panel {
    display: none;
  }
}

/* Chat Main Area */
.luna-chat-main {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: #ffffff;
  border-right: 1px solid #dce4e1;
  position: relative;
}

/* Chat Header */
.luna-chat-header {
  padding: 14px 24px;
  background: #ffffff;
  border-bottom: 1px solid #e5ece8;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-shrink: 0;
}

.luna-chat-header__brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.luna-chat-avatar {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, #1b2f7a 0%, #29469e 100%);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 16px;
  box-shadow: 0 4px 10px rgba(27, 47, 122, 0.25);
  position: relative;
}

.luna-chat-avatar::after {
  content: "";
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 11px;
  height: 11px;
  background: #10b981;
  border: 2px solid #ffffff;
  border-radius: 50%;
}

.luna-chat-header__info h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: #17334b;
  display: flex;
  align-items: center;
  gap: 8px;
}

.luna-chat-header__info p {
  margin: 2px 0 0;
  font-size: 12px;
  color: #64748b;
}

.luna-model-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: #eef8f4;
  border: 1px solid #c2e5d6;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  color: #0f766e;
}

.luna-model-badge__dot {
  width: 7px;
  height: 7px;
  background: #10b981;
  border-radius: 50%;
  animation: lunaPulse 2s infinite;
}

@keyframes lunaPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.85); }
}

/* Chat Stream / Message Feed */
.luna-chat-stream {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  scroll-behavior: smooth;
}

/* Messages */
.luna-msg {
  display: flex;
  gap: 12px;
  max-width: 820px;
  width: 100%;
}

.luna-msg--user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.luna-msg--assistant {
  align-self: flex-start;
}

.luna-msg__icon {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
}

.luna-msg--assistant .luna-msg__icon {
  background: #1b2f7a;
  color: #ffffff;
}

.luna-msg--user .luna-msg__icon {
  background: #e2e8f0;
  color: #334155;
}

.luna-msg__bubble {
  padding: 14px 18px;
  border-radius: 14px;
  font-size: 14.5px;
  line-height: 1.6;
  position: relative;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.luna-msg--assistant .luna-msg__bubble {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  color: #1e293b;
  border-top-left-radius: 4px;
}

.luna-msg--user .luna-msg__bubble {
  background: #1b2f7a;
  color: #ffffff;
  border-top-right-radius: 4px;
}

.luna-msg__bubble p {
  margin: 0 0 10px;
}

.luna-msg__bubble p:last-child {
  margin-bottom: 0;
}

.luna-msg__bubble strong {
  font-weight: 650;
}

.luna-msg__meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  font-size: 11px;
  color: #94a3b8;
}

.luna-msg--user .luna-msg__meta {
  color: rgba(255, 255, 255, 0.7);
  justify-content: flex-end;
}

.luna-speak-btn {
  background: none;
  border: none;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 11px;
  color: #64748b;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.15s;
}

.luna-speak-btn:hover {
  background: #e2e8f0;
  color: #0f172a;
}

/* Tool Badges */
.luna-tool-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  margin: 4px 4px 6px 0;
  background: #e6f4ea;
  border: 1px solid #b7e1cd;
  border-radius: 6px;
  font-size: 11.5px;
  color: #137333;
  font-weight: 600;
}

/* Proposal Action Card inside chat */
.luna-card-action {
  margin-top: 14px;
  padding: 16px;
  background: #ffffff;
  border: 1px solid #c7d8e8;
  border-left: 4px solid #1b2f7a;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(27, 47, 122, 0.08);
}

.luna-card-action h4 {
  margin: 0 0 6px;
  font-size: 14px;
  color: #1b2f7a;
  display: flex;
  align-items: center;
  gap: 8px;
}

.luna-card-action p {
  margin: 0 0 12px;
  font-size: 12.5px;
  color: #475569;
}

.luna-card-action__btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  background: #1b2f7a;
  color: #ffffff;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s ease-in-out;
}

.luna-card-action__btn:hover {
  background: #132258;
}

/* Suggestion Chips */
.luna-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.luna-chip {
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  border-radius: 20px;
  padding: 6px 12px;
  font-size: 12px;
  color: #334155;
  cursor: pointer;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.luna-chip:hover {
  background: #e2e8f0;
  border-color: #94a3b8;
  color: #0f172a;
}

/* Typing Indicator */
.luna-typing {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 12px 18px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  width: fit-content;
}

.luna-typing__dot {
  width: 7px;
  height: 7px;
  background: #94a3b8;
  border-radius: 50%;
  animation: lunaBounce 1.4s infinite ease-in-out both;
}

.luna-typing__dot:nth-child(1) { animation-delay: -0.32s; }
.luna-typing__dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes lunaBounce {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}

/* Bottom Chat Input Bar */
.luna-chat-input-bar {
  padding: 14px 24px 18px;
  background: #ffffff;
  border-top: 1px solid #e5ece8;
  flex-shrink: 0;
}

.luna-chat-input-wrapper {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #f8fafc;
  border: 1.5px solid #cbd5e1;
  border-radius: 24px;
  padding: 6px 10px 6px 16px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.luna-chat-input-wrapper:focus-within {
  border-color: #1b2f7a;
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(27, 47, 122, 0.12);
}

.luna-chat-input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 14px;
  color: #1e293b;
  outline: none;
  padding: 6px 0;
}

.luna-chat-input::placeholder {
  color: #94a3b8;
}

/* Voice Button */
.luna-voice-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #475569;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: all 0.15s;
  flex-shrink: 0;
}

.luna-voice-btn:hover {
  background: #f1f5f9;
  color: #0f172a;
}

.luna-voice-btn.is-recording {
  background: #ef4444;
  color: #ffffff;
  border-color: #dc2626;
  animation: voicePulse 1.2s infinite;
}

@keyframes voicePulse {
  0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }
  70% { transform: scale(1.08); box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); }
  100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

/* Send Button */
.luna-send-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: #1b2f7a;
  color: #ffffff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  transition: background 0.15s;
  flex-shrink: 0;
}

.luna-send-btn:hover {
  background: #132258;
}

.luna-send-btn:disabled {
  background: #cbd5e1;
  cursor: not-allowed;
}

.luna-input-hint {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  font-size: 11px;
  color: #94a3b8;
  padding: 0 12px;
}

/* Dossier Sidebar */
.luna-dossier-panel {
  background: #f8fafc;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.luna-dossier-panel h3 {
  margin: 0 0 4px;
  font-size: 13px;
  letter-spacing: 0.1em;
  color: #64748b;
  text-transform: uppercase;
}

.luna-dossier-panel h4 {
  margin: 0;
  font-size: 18px;
  color: #0f172a;
}

.luna-fact-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 16px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.luna-fact-card dt {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #64748b;
  margin-bottom: 4px;
}

.luna-fact-card dd {
  margin: 0 0 12px;
  font-size: 13px;
  font-weight: 600;
  color: #1e293b;
}

.luna-fact-card dd:last-child {
  margin-bottom: 0;
}

.luna-fact-card .empty-fact {
  color: #94a3b8;
  font-weight: normal;
  font-style: italic;
}

/* Web Search Card in Dossier */
.luna-web-search-card {
  margin-top: 12px;
  background: #f8fafc;
  border: 1px solid #cbd5e1;
}

.luna-web-search-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}

.luna-web-search-item {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 11.5px;
}

.luna-web-search-summary {
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 700;
  color: #0369a1;
}

.luna-web-search-term {
  max-width: 170px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.luna-web-search-sources {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.luna-web-source-pill {
  background: #f1f5f9;
  border-left: 3px solid #0284c7;
  padding: 6px 8px;
  border-radius: 4px;
}

.luna-web-source-title {
  display: block;
  font-size: 11px;
  color: #0f172a;
  line-height: 1.3;
}

.luna-web-source-snippet {
  margin: 3px 0;
  font-size: 10.5px;
  color: #475569;
  line-height: 1.35;
}

.luna-web-source-link {
  display: inline-block;
  font-size: 10px;
  color: #0284c7;
  text-decoration: underline;
  margin-top: 2px;
}

.luna-web-search-empty {
  margin: 8px 0 0;
  font-size: 11px;
  color: #94a3b8;
  font-style: italic;
  line-height: 1.4;
}

.luna-driver-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  color: #1d4ed8;
}

.luna-component-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.luna-component-tag {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  color: #334155;
}


/* Audio Player Bar */
.luna-audio-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 18px;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  font-size: 12px;
  color: #334155;
  flex-shrink: 0;
}

.luna-audio-bar__left {
  display: flex;
  align-items: center;
  gap: 10px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.luna-audio-bar__controls {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.luna-audio-btn {
  padding: 4px 10px;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  color: #1e293b;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.15s;
}

.luna-audio-btn:hover {
  background: #e2e8f0;
}

.luna-audio-btn.is-active {
  background: #1b2f7a;
  color: #ffffff;
  border-color: #1b2f7a;
}

.luna-audio-select {
  padding: 4px 8px;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  font-size: 11.5px;
  background: #ffffff;
  color: #1e293b;
  max-width: 180px;
}

/* OAuth Modal & Connection */
.luna-oauth-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.6);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.luna-oauth-card {
  background: #ffffff;
  border-radius: 12px;
  max-width: 520px;
  width: 100%;
  padding: 26px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
  gap: 16px;
  border-top: 5px solid #1b2f7a;
}

.luna-oauth-card h3 {
  margin: 0;
  font-size: 17px;
  color: #17334b;
  display: flex;
  align-items: center;
  gap: 8px;
}

.luna-oauth-card p {
  margin: 0;
  font-size: 13px;
  line-height: 1.55;
  color: #475569;
}

.luna-oauth-status-box {
  padding: 12px 16px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.luna-oauth-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.luna-oauth-field label {
  font-size: 12px;
  font-weight: 700;
  color: #334155;
}

.luna-oauth-field select, .luna-oauth-field input {
  padding: 9px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 13px;
  background: #ffffff;
}

.luna-oauth-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 8px;
}


/* Strict Viewport Fit for Luna Chat */
.luna-chat-shell {
  display: grid !important;
  grid-template-columns: 1fr 340px !important;
  height: 100% !important;
  max-height: 100% !important;
  overflow: hidden !important;
  background: #f4f7f6 !important;
  box-sizing: border-box !important;
}

@media (max-width: 960px) {
  .luna-chat-shell {
    grid-template-columns: 1fr !important;
  }
  .luna-dossier {
    display: none !important;
  }
}

.luna-chat-main {
  display: flex !important;
  flex-direction: column !important;
  height: 100% !important;
  max-height: 100% !important;
  overflow: hidden !important;
  background: #ffffff !important;
  border-right: 1px solid #dce4e1 !important;
  position: relative !important;
  box-sizing: border-box !important;
}

.luna-chat-stream {
  flex: 1 1 0 !important;
  min-height: 0 !important;
  overflow-y: auto !important;
  padding: 18px 24px !important;
  display: flex !important;
  flex-direction: column !important;
  gap: 16px !important;
  box-sizing: border-box !important;
}

/* Bottom Chat Input Bar */
.luna-input-box {
  padding: 10px 24px 14px !important;
  background: #ffffff !important;
  border-top: 1px solid #e2e8f0 !important;
  flex-shrink: 0 !important;
  box-sizing: border-box !important;
}

.luna-input-form {
  display: flex !important;
  align-items: flex-end !important;
  gap: 10px !important;
  background: #f8fafc !important;
  border: 1.5px solid #cbd5e1 !important;
  border-radius: 18px !important;
  padding: 6px 10px 6px 14px !important;
  box-shadow: 0 2px 6px rgba(0,0,0,0.03) !important;
  box-sizing: border-box !important;
}

.luna-input-form:focus-within {
  border-color: #1b2f7a !important;
  background: #ffffff !important;
  box-shadow: 0 0 0 3px rgba(27, 47, 122, 0.12) !important;
}

.luna-textarea {
  flex: 1 !important;
  border: none !important;
  background: transparent !important;
  outline: none !important;
  font: 14px inherit !important;
  color: #1e293b !important;
  resize: vertical !important;
  padding: 6px 0 !important;
  line-height: 1.45 !important;
  min-height: 24px !important;
  max-height: 230px !important;
  overflow-y: hidden !important;
  box-sizing: border-box !important;
  margin-bottom: 2px !important;
}

.luna-textarea::placeholder {
  color: #94a3b8 !important;
}

.luna-send-btn {
  background: #1b2f7a !important;
  color: #ffffff !important;
  border: none !important;
  border-radius: 20px !important;
  padding: 8px 16px !important;
  font-size: 13px !important;
  font-weight: 700 !important;
  cursor: pointer !important;
  display: inline-flex !important;
  align-items: center !important;
  gap: 6px !important;
  transition: background 0.15s !important;
  flex-shrink: 0 !important;
  margin-bottom: 2px !important;
}

.luna-send-btn:hover {
  background: #132258 !important;
}

.luna-voice-btn {
  width: 36px !important;
  height: 36px !important;
  border-radius: 50% !important;
  border: 1px solid #cbd5e1 !important;
  background: #ffffff !important;
  color: #475569 !important;
  cursor: pointer !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  font-size: 16px !important;
  transition: all 0.15s !important;
  flex-shrink: 0 !important;
  margin-bottom: 2px !important;
}

.luna-voice-btn:hover {
  background: #f1f5f9 !important;
  border-color: #94a3b8 !important;
}

.luna-voice-btn.is-recording {
  background: #ef4444 !important;
  border-color: #dc2626 !important;
  color: #ffffff !important;
  animation: pulseMic 1.2s infinite !important;
}

.luna-dossier {
  height: 100% !important;
  max-height: 100% !important;
  overflow-y: auto !important;
  box-sizing: border-box !important;
  padding: 20px !important;
}

/* In-Chat OAuth Banner Card */
.luna-auth-card {
  margin: 12px 0 !important;
  padding: 16px 20px !important;
  background: #fffdf5 !important;
  border: 1.5px solid #fde68a !important;
  border-left: 5px solid #f59e0b !important;
  border-radius: 8px !important;
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.08) !important;
}

.luna-auth-card h4 {
  margin: 0 0 6px !important;
  font-size: 14px !important;
  color: #b45309 !important;
  display: flex !important;
  align-items: center !important;
  gap: 8px !important;
}

.luna-auth-card p {
  margin: 0 0 12px !important;
  font-size: 13px !important;
  color: #475569 !important;
  line-height: 1.5 !important;
}

.luna-auth-card__actions {
  display: flex !important;
  gap: 10px !important;
  align-items: center !important;
  flex-wrap: wrap !important;
}
