/* BRHDG Virtual Assistant Styles */
:root {
  --navy: #1a2332;
  --navy-light: #243447;
  --cyan: #0097a7;
  --cyan-light: #00bcd4;
  --cyan-bg: #e0f7fa;
  --white: #ffffff;
  --gray-50: #f8f9fa;
  --gray-100: #f0f2f5;
  --gray-200: #e0e3e8;
  --gray-300: #c8ccd2;
  --gray-500: #6c757d;
  --gray-700: #495057;
  --gray-900: #212529;
  --red: #d32f2f;
  --green: #2e7d32;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

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

body {
  font-family: var(--font);
  background: var(--gray-100);
  height: 100vh;
  overflow: hidden;
}

/* Layout */
.va-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-width: 900px;
  margin: 0 auto;
  background: var(--white);
  box-shadow: 0 0 30px rgba(0,0,0,0.1);
}

/* Header */
.va-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: var(--navy);
  color: var(--white);
  flex-shrink: 0;
}

.va-logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.va-logo-icon { font-size: 1.4rem; }
.va-logo-text { font-weight: 600; font-size: 1.1rem; }

.va-header-actions {
  display: flex;
  gap: 8px;
}

.va-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 14px;
  border: none;
  border-radius: 6px;
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.2s;
}

.va-btn-sm {
  padding: 5px 10px;
  font-size: 0.8rem;
  background: rgba(255,255,255,0.15);
  color: var(--white);
}

.va-btn-sm:hover { background: rgba(255,255,255,0.25); }

.va-btn-primary {
  background: var(--cyan);
  color: var(--white);
}
.va-btn-primary:hover { background: var(--cyan-light); }

/* Auth */
.va-auth-required {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.va-auth-card {
  text-align: center;
  padding: 2rem;
}
.va-auth-card h2 { margin-bottom: 0.5rem; color: var(--gray-700); }
.va-auth-card p { margin-bottom: 1.5rem; color: var(--gray-500); }

/* Chat area */
.va-chat-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.va-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  scroll-behavior: smooth;
}

/* Welcome */
.va-welcome {
  text-align: center;
  padding: 60px 20px 40px;
}
.va-welcome h2 {
  color: var(--navy);
  font-size: 1.5rem;
  margin-bottom: 8px;
}
.va-welcome p {
  color: var(--gray-500);
  margin-bottom: 24px;
}
.va-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}
.va-suggestion {
  padding: 8px 16px;
  border: 1px solid var(--gray-200);
  border-radius: 20px;
  background: var(--white);
  color: var(--gray-700);
  font-family: var(--font);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
}
.va-suggestion:hover {
  border-color: var(--cyan);
  color: var(--cyan);
  background: var(--cyan-bg);
}

/* Messages */
.va-message {
  display: flex;
  margin-bottom: 16px;
}

.va-user {
  justify-content: flex-end;
}

.va-user .va-bubble {
  background: var(--cyan);
  color: var(--white);
  border-radius: 18px 18px 4px 18px;
  max-width: 75%;
}

.va-assistant .va-bubble {
  background: var(--gray-50);
  color: var(--gray-900);
  border: 1px solid var(--gray-200);
  border-radius: 18px 18px 18px 4px;
  max-width: 85%;
}

.va-bubble {
  padding: 12px 16px;
  line-height: 1.5;
  font-size: 0.95rem;
  word-wrap: break-word;
}

.va-bubble .va-text {
  white-space: pre-wrap;
}

.va-bubble .va-text h3, .va-bubble .va-text h4 {
  margin: 12px 0 4px;
  font-size: 1rem;
}

.va-bubble .va-text ul {
  margin: 4px 0;
  padding-left: 20px;
}

.va-bubble .va-text li {
  margin: 2px 0;
}

.va-bubble .va-text code {
  background: rgba(0,0,0,0.06);
  padding: 2px 5px;
  border-radius: 3px;
  font-size: 0.88rem;
}

.va-bubble .va-text pre {
  background: var(--navy);
  color: #e0e0e0;
  padding: 12px;
  border-radius: 6px;
  overflow-x: auto;
  margin: 8px 0;
}

.va-bubble .va-text pre code {
  background: none;
  padding: 0;
  color: inherit;
}

.va-bubble .va-text strong {
  font-weight: 600;
}

/* Tool status indicators */
.va-tools {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 6px;
}

.va-tool-status {
  font-size: 0.78rem;
  color: var(--gray-500);
  display: flex;
  align-items: center;
  gap: 6px;
}

.va-tool-status.done { color: var(--green); }

.va-tool-spinner {
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 2px solid var(--gray-300);
  border-top-color: var(--cyan);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Error */
.va-error .va-text { color: var(--red); }

/* Input area */
.va-input-area {
  padding: 12px 20px 16px;
  border-top: 1px solid var(--gray-200);
  background: var(--white);
  flex-shrink: 0;
}

.va-input-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.va-input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--gray-200);
  border-radius: 20px;
  font-family: var(--font);
  font-size: 0.95rem;
  resize: none;
  outline: none;
  line-height: 1.4;
  max-height: 150px;
  transition: border-color 0.2s;
}
.va-input:focus { border-color: var(--cyan); }

.va-voice-btn, .va-send-btn {
  width: 42px;
  height: 42px;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
  transition: all 0.2s;
}

.va-voice-btn {
  background: var(--gray-100);
  color: var(--gray-700);
}
.va-voice-btn:hover { background: var(--gray-200); }
.va-voice-btn.recording {
  background: var(--red);
  color: var(--white);
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(211,47,47,0.4); }
  50% { box-shadow: 0 0 0 8px rgba(211,47,47,0); }
}

.va-send-btn {
  background: var(--cyan);
  color: var(--white);
}
.va-send-btn:hover:not(:disabled) { background: var(--cyan-light); }
.va-send-btn:disabled {
  background: var(--gray-200);
  color: var(--gray-300);
  cursor: default;
}

/* Voice controls bar */
.va-voice-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  padding: 0 4px;
}

.va-toggle-btn {
  padding: 4px 10px;
  border: 1px solid var(--gray-200);
  border-radius: 16px;
  background: var(--white);
  color: var(--gray-500);
  font-family: var(--font);
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.va-toggle-btn:hover { border-color: var(--cyan); color: var(--cyan); }
.va-toggle-btn.active {
  background: var(--cyan);
  color: var(--white);
  border-color: var(--cyan);
}

.va-voice-select {
  padding: 4px 8px;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  background: var(--white);
  font-family: var(--font);
  font-size: 0.75rem;
  color: var(--gray-700);
  cursor: pointer;
  outline: none;
}
.va-voice-select:focus { border-color: var(--cyan); }

/* VOX settings panel */
.va-vox-settings {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 12px;
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  margin-top: 6px;
}

.va-vox-slider {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  color: var(--gray-500);
  white-space: nowrap;
}

.va-vox-slider label {
  font-weight: 600;
  color: var(--gray-600);
  min-width: 55px;
}

.va-vox-slider input[type="range"] {
  width: 80px;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--gray-200);
  border-radius: 2px;
  outline: none;
}

.va-vox-slider input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--cyan);
  cursor: pointer;
}

.va-vox-slider span {
  min-width: 22px;
  text-align: right;
  font-weight: 600;
  color: var(--gray-700);
  font-size: 0.72rem;
}

/* Live level meter */
.va-vox-level {
  width: 100px;
  height: 8px;
  background: var(--gray-200);
  border-radius: 4px;
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
}

.va-vox-level-fill {
  height: 100%;
  background: var(--green);
  border-radius: 4px;
  width: 0%;
  transition: width 0.08s;
}

.va-vox-level-mark {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--red);
  left: 30%;
}

/* Speaking state */
.va-voice-btn.speaking {
  background: var(--cyan);
  color: var(--white);
  animation: pulse-speak 1.5s ease-in-out infinite;
}

@keyframes pulse-speak {
  0%, 100% { box-shadow: 0 0 0 0 rgba(0,151,167,0.4); }
  50% { box-shadow: 0 0 0 8px rgba(0,151,167,0); }
}

/* Speak button on messages */
.va-speak-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.85rem;
  opacity: 0;
  transition: opacity 0.2s;
  padding: 2px 4px;
  border-radius: 4px;
}
.va-speak-btn:hover { background: rgba(0,0,0,0.05); }
.va-bubble { position: relative; }
.va-bubble:hover .va-speak-btn { opacity: 0.6; }
.va-speak-btn:hover { opacity: 1 !important; }

/* Voice mode — enlarge mic button */
.voice-mode .va-voice-btn {
  width: 56px;
  height: 56px;
  font-size: 1.5rem;
}

.va-voice-status {
  font-size: 0.8rem;
  color: var(--gray-500);
  margin-top: 4px;
  padding-left: 50px;
  min-height: 18px;
}

/* Confirmation Modal */
.va-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.va-modal {
  background: var(--white);
  border-radius: 12px;
  padding: 24px;
  max-width: 500px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}

.va-modal h3 {
  color: var(--navy);
  margin-bottom: 16px;
  font-size: 1.1rem;
}

.va-modal-body {
  margin-bottom: 20px;
  font-size: 0.9rem;
  line-height: 1.5;
}

.va-confirm-detail p {
  margin-bottom: 6px;
}

.va-confirm-body {
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  padding: 10px;
  margin-top: 4px;
  font-size: 0.85rem;
  white-space: pre-wrap;
  max-height: 200px;
  overflow-y: auto;
}

.va-confirm-note {
  color: var(--gray-500);
  font-size: 0.82rem;
  font-style: italic;
  margin-top: 8px;
}

.va-modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.va-btn-cancel {
  background: var(--gray-200);
  color: var(--gray-700);
}
.va-btn-cancel:hover { background: var(--gray-300); }

.va-btn-confirm {
  background: var(--green);
  color: var(--white);
  padding: 8px 24px;
}
.va-btn-confirm:hover { background: #388e3c; }

/* Mobile */
@media (max-width: 640px) {
  .va-container { max-width: 100%; }
  .va-header { padding: 10px 14px; }
  .va-messages { padding: 14px; }
  .va-input-area { padding: 10px 14px 14px; }
  .va-user .va-bubble, .va-assistant .va-bubble { max-width: 90%; }
  .va-welcome { padding: 40px 10px 30px; }
  .va-suggestion { font-size: 0.8rem; padding: 6px 12px; }
}

/* Scrollbar */
.va-messages::-webkit-scrollbar { width: 6px; }
.va-messages::-webkit-scrollbar-track { background: transparent; }
.va-messages::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 3px; }
.va-messages::-webkit-scrollbar-thumb:hover { background: var(--gray-500); }

/* Upload button */
.va-upload-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--gray-300);
  background: var(--white);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
  transition: all 0.15s;
}
.va-upload-btn:hover {
  background: var(--gray-100);
  border-color: var(--primary);
}
.va-upload-btn.uploading {
  background: #fff3e0;
  border-color: #ff9800;
  animation: pulse-upload 1.5s infinite;
}
@keyframes pulse-upload {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* Upload progress bar */
.va-upload-progress {
  background: #e3f2fd;
  border-radius: 8px;
  padding: 12px 16px;
  margin: 8px 0;
  font-size: 0.85rem;
  color: #1565c0;
}
.va-upload-progress .progress-bar {
  height: 4px;
  background: #bbdefb;
  border-radius: 2px;
  margin-top: 8px;
  overflow: hidden;
}
.va-upload-progress .progress-fill {
  height: 100%;
  background: #1976d2;
  border-radius: 2px;
  animation: indeterminate 1.5s infinite;
}
@keyframes indeterminate {
  0% { width: 0; margin-left: 0; }
  50% { width: 60%; margin-left: 20%; }
  100% { width: 0; margin-left: 100%; }
}
