/* ===========================================
   VARIABLES
   =========================================== */
:root {
  /* Colors */
  --color-background: #fcfcfc;
  --color-white: #ffffff;
  --color-text-primary: #333;
  --color-text-secondary: #555;
  --color-text-muted: #777;
  --color-text-light: #888;
  
  /* Brand colors */
  --color-primary: #4B85C3;
  --color-primary-light: #EFF8FF;
  --color-primary-border: rgba(75, 133, 195, 0.25);
  --color-primary-border-hover: rgba(75, 133, 195, 0.6);
  
  /* State colors */
  --color-success: #4CAF50;
  --color-warning: #E67E22;
  --color-danger: #C77;
  --color-danger-light: #FFF2F2;
  --color-warning-light: #FFF7ED;
  --color-info: #6A5ACD;
  --color-info-light: #f5f5ff;
  
  /* Chat colors */
  --color-user-bubble: #EFF8FF;
  --color-user-text: #4B85C3;
  --color-user-indicator: #2196F3;
  --color-ai-bubble: #F8F8F8;
  --color-ai-text: #555;
  --color-ai-indicator: #4CAF50;
  
  /* UI Elements */
  --border-radius-sm: 4px;
  --border-radius-md: 8px;
  --border-radius-lg: 10px;
  --border-radius-xl: 16px;
  --border-radius-full: 20px;
  --border-radius-circle: 50%;
  
  /* Shadow */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.08);
  
  /* Spacing */
  --spacing-xs: 5px;
  --spacing-sm: 10px;
  --spacing-md: 15px;
  --spacing-lg: 20px;
  
  /* Border */
  --border-thin: 1px;
  
  /* Transitions */
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s ease;
}

/* ===========================================
   RESET & MAIN LAYOUT
   =========================================== */
body {
  font-family: Arial, sans-serif;
  background-color: var(--color-background);
  display: flex;
  justify-content: center;
  align-items: flex-start;
  min-height: 100vh;
  margin: 0;
  padding-top: var(--spacing-lg);
}

#app {
  width: 100%;
  max-width: 600px;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--spacing-sm) var(--spacing-lg);
}

.app-title {
  color: var(--color-text-secondary);
  margin: 0 0 var(--spacing-md) 0;
  font-size: 18px;
  text-align: center;
  font-weight: 500;
}

.app-title:after {
  content: "";
  display: block;
  width: 40px;
  height: 3px;
  background-color: var(--color-primary-light);
  margin: 6px auto 0;
  border-radius: var(--border-radius-sm);
}

/* ===========================================
   STATUS AND VOLUME INDICATORS
   =========================================== */
#status-volume-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  margin-bottom: var(--spacing-sm);
}

/* Status indicators styles */
#status-container {
  display: flex;
  justify-content: flex-start;
  gap: var(--spacing-sm);
  flex: 0 0 auto;
}

.status-indicator {
  text-align: center;
  padding: var(--spacing-xs) 8px;
  border-radius: var(--border-radius-md);
  font-size: 12px;
  width: 100px;
  border: var(--border-thin) solid rgba(0, 0, 0, 0.1);
  box-shadow: var(--shadow-sm);
}

#room-status {
  background-color: var(--color-primary-light);
  color: var(--color-primary);
  border-color: rgba(75, 133, 195, 0.35);
}

#ai-state {
  background-color: #fafafa;
  color: var(--color-text-muted);
  border-color: rgba(119, 119, 119, 0.25);
}

/* ===========================================
   CHAT CONTAINER AND AGENT SELECTION
   =========================================== */
.chat-container {
  width: 100%;
  position: relative;
  margin-bottom: var(--spacing-md);
  display: flex;
  flex-direction: column;
  height: 400px; /* Fixed total height */
}

/* Agent selection */
.agent-selection-container {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 8px 0;
  background-color: var(--color-white);
  border: var(--border-thin) solid var(--color-primary-border);
  border-bottom: none;
  border-radius: var(--border-radius-lg) var(--border-radius-lg) 0 0;
  height: auto;
  flex-shrink: 0;
  gap: 8px;
}

.agent-select {
  width: 150px;
  padding: 5px 10px;
  border: var(--border-thin) solid var(--color-primary-border);
  border-radius: var(--border-radius-full);
  background-color: var(--color-white);
  font-size: 13px;
  color: var(--color-text-primary);
  cursor: pointer;
  outline: none;
}

.agent-select:hover {
  border-color: var(--color-primary-border-hover);
}

.agent-select:focus {
  border-color: var(--color-primary-border-hover);
}

/* Agent selection loading state */
.agent-select option[disabled][selected] {
  font-style: italic;
  color: var(--color-text-light);
}

/* Loading animation for the select box */
@keyframes selectPulse {
  0% { box-shadow: 0 0 0 rgba(75, 133, 195, 0.1); }
  50% { box-shadow: 0 0 10px rgba(75, 133, 195, 0.3); }
  100% { box-shadow: 0 0 0 rgba(75, 133, 195, 0.1); }
}

.agent-select[data-loading="true"] {
  animation: selectPulse 1.5s infinite;
}

/* Hide agent selection during call */
.call-active .agent-selection-container {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  height: 0;
  padding: 0;
  margin: 0;
  border: none;
  flex-basis: 0;
  transition: var(--transition-normal);
}

.call-active .agent-nav-btn {
  display: none;
}

/* Ensure the chat list expands to fill the container height when in call mode */
.call-active .chat-list {
  height: 100%;
  flex-grow: 1;
  border-radius: var(--border-radius-lg);
}

/* Agent navigation buttons */
.agent-nav-btn {
  background-color: transparent;
  border: var(--border-thin) solid var(--color-primary-border);
  width: 28px;
  height: 28px;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 0;
  font-size: 16px;
  color: var(--color-primary);
  cursor: pointer;
  border-radius: var(--border-radius-full);
}

.agent-nav-btn:hover {
  background-color: var(--color-primary-light);
}

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

.agent-nav-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background-color: transparent;
  color: var(--color-text-light);
}

/* ===========================================
   CHAT MESSAGES
   =========================================== */
.chat-list {
  width: 100%;
  flex: 1;
  border: var(--border-thin) solid var(--color-primary-border);
  padding: 12px;
  background-color: var(--color-white);
  box-sizing: border-box;
  display: flex;
  flex-direction: column-reverse;
  overflow: auto;
  border-radius: 0 0 var(--border-radius-lg) var(--border-radius-lg);
  box-shadow: var(--shadow-md);
}

/* Scrollbar styles */
.chat-list::-webkit-scrollbar {
  width: 4px;
}

.chat-list::-webkit-scrollbar-track {
  background: #fafafa;
}

.chat-list::-webkit-scrollbar-thumb {
  background: #ececec;
  border-radius: var(--border-radius-lg);
}

.chat-list::-webkit-scrollbar-thumb:hover {
  background: #dedede;
}

/* Chat message items */
.chat-item {
  display: flex;
  flex-direction: column;
  margin-bottom: 14px;
  max-width: 85%;
}

.chat-item.user {
  align-items: flex-end;
  align-self: flex-end;
}

.chat-item.ai {
  align-items: flex-start;
  align-self: flex-start;
}

/* Sender label */
.chat-id {
  font-weight: 600;
  font-size: 11px;
  color: var(--color-text-light);
  margin-bottom: 3px;
  display: flex;
  align-items: center;
}

.chat-id:before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: var(--border-radius-circle);
  margin-right: var(--spacing-xs);
}

.chat-item.user .chat-id:before {
  background-color: var(--color-user-indicator);
}

.chat-item.ai .chat-id:before {
  background-color: var(--color-ai-indicator);
}

/* Message content */
.chat-text {
  padding: var(--spacing-sm) 14px;
  border-radius: var(--border-radius-xl);
  max-width: 100%;
  font-size: 14px;
  white-space: pre-wrap;
  word-break: break-word;
  box-shadow: var(--shadow-sm);
  line-height: 1.4;
  border: var(--border-thin) solid transparent;
}

.chat-item.user .chat-text {
  border-top-right-radius: var(--border-radius-sm);
  background-color: var(--color-user-bubble);
  color: var(--color-user-text);
  border-color: rgba(75, 133, 195, 0.2);
}

.chat-item.ai .chat-text {
  border-top-left-radius: var(--border-radius-sm);
  background-color: var(--color-ai-bubble);
  color: var(--color-ai-text);
  border-color: rgba(76, 175, 80, 0.1);
}

/* ===========================================
   BUTTONS
   =========================================== */
.button-container {
  display: flex;
  justify-content: center;
  gap: var(--spacing-lg);
  width: 100%;
}

button {
  padding: 8px var(--spacing-lg);
  border: var(--border-thin) solid rgba(0, 0, 0, 0.15);
  border-radius: var(--border-radius-full);
  font-size: 16px;
  cursor: pointer;
  transition: var(--transition-fast);
  box-shadow: var(--shadow-sm);
}

.start-button {
  background-color: var(--color-primary-light);
  color: var(--color-primary);
  border-color: rgba(75, 133, 195, 0.4);
}

.end-button {
  background-color: var(--color-danger-light);
  color: var(--color-danger);
  border-color: rgba(204, 119, 119, 0.4);
}

.interrupt-button {
  background-color: var(--color-warning-light);
  color: var(--color-warning);
  border-color: rgba(230, 126, 34, 0.4);
  position: relative;
}

.interrupt-button:before {
  /* content: "✋"; */
  margin-right: var(--spacing-xs);
  font-size: 14px;
}

.mute-button {
  background-color: var(--color-info-light);
  color: var(--color-info);
  border-color: rgba(106, 90, 205, 0.4);
  position: relative;
}

.mute-button:before {
  content: "🔊";
  margin-right: var(--spacing-xs);
  font-size: 14px;
}

.mute-button.muted:before {
  content: "🔇";
}

button:hover {
  opacity: 0.95;
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
  border-color: rgba(0, 0, 0, 0.2);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* ===========================================
   TEXT INPUT
   =========================================== */
.input-container {
  display: flex;
  width: 100%;
  margin-bottom: var(--spacing-md);
  gap: var(--spacing-sm);
  align-items: center;
}

.text-input {
  flex: 1;
  padding: var(--spacing-sm) var(--spacing-md);
  border-radius: var(--border-radius-full);
  border: var(--border-thin) solid rgba(75, 133, 195, 0.3);
  font-size: 14px;
  outline: none;
  transition: var(--transition-fast);
}

.text-input:focus {
  border-color: var(--color-primary-border-hover);
  box-shadow: 0 2px 6px var(--color-primary-shadow);
}

.send-button {
  padding: 8px var(--spacing-md);
  background-color: var(--color-primary);
  color: var(--color-white);
  border: none;
  border-radius: var(--border-radius-full);
  cursor: pointer;
  transition: var(--transition-fast);
}

.send-button:hover:not(:disabled) {
  background-color: #3a74b2;
}

.send-button:disabled {
  background-color: #cccccc;
  cursor: not-allowed;
}

/* ===========================================
   VOLUME VISUALIZATION
   =========================================== */
.volume-indicators {
  display: flex;
  justify-content: flex-end;
  flex: 1;
  gap: var(--spacing-md);
  margin-left: var(--spacing-sm);
}

.volume-container {
  width: 150px;
  position: relative;
}

.volume-bar-container {
  height: 24px;
  background-color: #f5f5f5;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
  position: relative;
  border: var(--border-thin) solid rgba(0, 0, 0, 0.06);
}

.volume-bar {
  height: 100%;
  width: 0;
  border-radius: 12px;
  transition: width 0.12s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  min-width: 8px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* Loading animation for the select box */
@keyframes selectPulse {
  0% { box-shadow: 0 0 0 rgba(75, 133, 195, 0.1); }
  50% { box-shadow: 0 0 10px rgba(75, 133, 195, 0.3); }
  100% { box-shadow: 0 0 0 rgba(75, 133, 195, 0.1); }
}

.agent-select[data-loading="true"] {
  animation: selectPulse 1.5s infinite;
}

/* Volume bar animations */
@keyframes gradientShift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

#userVolumeBar, #aiVolumeBar {
  background-size: 200% 100%;
  animation: gradientShift 3s ease infinite;
}

#userVolumeBar {
  background: linear-gradient(90deg, rgba(33, 150, 243, 0.9), rgba(100, 181, 246, 0.85));
}

#aiVolumeBar {
  background: linear-gradient(90deg, var(--color-success), rgba(139, 195, 74, 0.85));
}

.volume-bar.active {
  box-shadow: 0 0 8px rgba(0, 0, 0, 0.15);
}

/* ===========================================
   AGENT CARD STYLES
   =========================================== */
.chat-agent-card {
  background: #f8f9fa;
  border-radius: var(--border-radius-md);
  padding: 12px;
  margin: 6px 0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  border: var(--border-thin) solid rgba(0, 0, 0, 0.07);
}

.agent-header {
  display: flex;
  align-items: center;
  margin-bottom: 8px;
}

.agent-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--border-radius-circle);
  margin-right: var(--spacing-sm);
}

.agent-info {
  flex: 1;
}

.agent-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text-primary);
  margin-bottom: 2px;
}

.agent-voice {
  font-size: 11px;
  color: #666;
}

.agent-description {
  font-size: 12px;
  color: #444;
  margin-bottom: 8px;
  line-height: 1.4;
}

.agent-capabilities {
  margin-bottom: 8px;
}

.capabilities-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-primary);
  margin-bottom: 4px;
}

.capabilities-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.capability-item {
  background: #e9ecef;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  color: #495057;
}

.agent-personality {
  font-size: 11px;
  color: #666;
}

.personality-label {
  font-weight: 600;
  margin-right: 4px;
}

.personality-text {
  color: #495057;
}

.chat-item.ai .chat-text .chat-agent-card {
  margin: 0;
  background: transparent;
  box-shadow: none;
  padding: 0;
}

/* ===========================================
   RESPONSIVE DESIGN
   =========================================== */
@media (max-width: 600px) {
  #status-volume-container {
    flex-direction: row;
    align-items: center;
    gap: var(--spacing-sm);
  }

  #status-container {
    flex: 1;
    justify-content: flex-start;
    gap: var(--spacing-xs);
  }

  .status-indicator {
    width: auto;
    min-width: 80px;
    font-size: 14px;
    padding: 4px 6px;
  }

  .volume-indicators {
    flex: 1;
    max-width: 150px;
  }

  .volume-container {
    margin: 0;
  }

  .volume-bar-container {
    height: 18px;
  }

  .button-container {
    gap: var(--spacing-sm);
    flex-wrap: nowrap;
  }

  button {
    padding: 6px 12px;
    font-size: 14px;
    flex: 1;
    min-width: 0;
  }

  .interrupt-button:before,
  .mute-button:before {
    font-size: 12px;
    margin-right: 3px;
  }

  .agent-selection-container {
    padding: 6px 0;
  }
  
  .agent-select {
    width: 120px;
    padding: 4px 6px;
    font-size: 12px;
  }
  
  .agent-nav-btn {
    width: 24px;
    height: 24px;
    font-size: 14px;
    flex: 0 0 auto;
  }
}

@media (max-width: 400px) {
  .status-indicator {
    min-width: 70px;
    font-size: 10px;
    padding: 3px 5px;
  }

  .volume-indicators {
    max-width: 120px;
  }

  .volume-bar-container {
    height: 14px;
  }

  .volume-bar {
    height: 14px;
  }

  button {
    padding: 5px 10px;
    font-size: 13px;
  }

  .agent-selection-container {
    padding: 4px 0;
  }
  
  .agent-select {
    width: 100px;
    padding: 3px 4px;
    font-size: 11px;
  }
  
  .agent-nav-btn {
    width: 22px;
    height: 22px;
    font-size: 12px;
    flex: 0 0 auto;
    min-width: 22px;
  }
} 