/* 
 * Common CSS Styles for the Voice and PDF Chat Application
 */

/* General container styles */
body {
  font-family: Arial, sans-serif;
  line-height: 1.6;
  margin: 0;
  padding: 0;
  background-color: #f5f7fa;
  color: #333;
}

.container {
  max-width: 800px;
  margin: 0 auto;
  padding: 20px;
  box-shadow: 0 0 10px rgba(0,0,0,0.1);
  border-radius: 8px;
  background-color: #ffffff;
}

h1, h2, h3 {
  color: #2c3e50;
}

/* Tab navigation */
.tab-nav {
  display: flex;
  border-bottom: 1px solid #ddd;
  margin-bottom: 20px;
}

.tab-button {
  padding: 10px 20px;
  background-color: transparent;
  border: none;
  cursor: pointer;
  font-weight: bold;
  color: #7f8c8d;
  transition: all 0.3s ease;
}

.tab-button:hover {
  color: #2980b9;
}

.tab-button.active {
  color: #2980b9;
  border-bottom: 3px solid #2980b9;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* Conversation styles */
#conversation-container {
  display: flex;
  flex-direction: column;
  height: 100%;
}

#conversation, #text-conversation {
  height: 400px;
  overflow-y: auto;
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 4px;
  background-color: #ffffff;
  margin-bottom: 20px;
  scroll-behavior: smooth;
}

.message {
  margin: 10px 0;
  padding: 10px;
  border-radius: 8px;
  max-width: 80%;
  word-wrap: break-word;
  animation: message-fade-in 0.3s ease-in-out;
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

@keyframes message-fade-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.user-message {
  background-color: #e3f2fd;
  margin-left: 20%;
  align-self: flex-end;
  border-bottom-right-radius: 2px;
}

.ai-message {
  background-color: #f5f5f5;
  margin-right: 20%;
  align-self: flex-start;
  border-bottom-left-radius: 2px;
}

.timestamp {
  font-size: 0.8em;
  color: #666;
  margin-top: 5px;
}

/* Input and controls */
.input-group {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
}

textarea, input[type="text"] {
  width: 100%;
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-family: inherit;
  resize: none;
}

textarea:focus, input[type="text"]:focus {
  outline: none;
  border-color: #3498db;
  box-shadow: 0 0 5px rgba(52, 152, 219, 0.3);
}

button {
  padding: 10px 20px;
  background-color: #007bff;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: background-color 0.3s ease;
}

button:hover {
  background-color: #0056b3;
}

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

/* Voice Controls */
#voice-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
}

#startButton {
  background-color: #4CAF50;
}

#startButton:hover {
  background-color: #388E3C;
}

#stopButton {
  background-color: #F44336;
}

#stopButton:hover {
  background-color: #D32F2F;
}

.voice-options {
  display: flex;
  align-items: center;
  margin-left: 10px;
  font-size: 0.9em;
}

.keyboard-shortcut {
  margin-left: 10px;
  font-size: 0.8em;
  color: #666;
  font-style: italic;
}

/* Speech test button */
.test-voice {
  background-color: #4CAF50;
  color: white;
  border: none;
  border-radius: 4px;
  padding: 5px 10px;
  cursor: pointer;
  font-size: 0.9em;
}

.test-voice:hover {
  background-color: #388E3C;
}

/* Speaking animation enhancements */
.speaking {
  position: relative;
  display: inline-block;
}

.speaking::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 0;
  width: 100%;
  height: 2px;
  background: linear-gradient(90deg, #3498db, #9b59b6, #3498db);
  background-size: 200% 100%;
  animation: speak-flow 1.5s infinite;
}

@keyframes speak-flow {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* Settings panels */
.settings-panel {
  margin-top: 20px;
  padding: 15px;
  background-color: #f9f9f9;
  border: 1px solid #ddd;
  border-radius: 4px;
}

.settings-row {
  display: flex;
  align-items: center;
  margin: 10px 0;
}

.settings-row label {
  width: 150px;
  margin-right: 10px;
}

.settings-row input[type="range"] {
  width: 200px;
  margin-right: 10px;
}

.settings-row span {
  width: 50px;
  text-align: center;
}

/* Audio visualizer */
#visualizer {
  width: 100%;
  height: 60px;
  margin: 10px 0;
  background-color: #f5f5f5;
  border-radius: 4px;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.1);
}

/* File upload area */
.upload-area {
  margin-bottom: 20px;
  padding: 20px;
  border: 2px dashed #ccc;
  border-radius: 4px;
  text-align: center;
  transition: border-color 0.3s ease;
}

.upload-area:hover {
  border-color: #3498db;
}

.upload-status {
  margin-top: 10px;
  font-style: italic;
  color: #666;
}

/* Status indicators */
.status {
  margin-left: 10px;
  padding: 5px 10px;
  border-radius: 4px;
  font-size: 14px;
  transition: all 0.3s ease;
}

.status.error {
  background-color: #ffebee;
  color: #c62828;
}

.status.info {
  background-color: #e3f2fd;
  color: #1565c0;
}

.status.success {
  background-color: #e8f5e9;
  color: #2e7d32;
}

.status.warning {
  background-color: #fff3e0;
  color: #e65100;
}

/* Debug panel */
#debug-panel {
  margin-top: 20px;
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 4px;
  background-color: #f9f9f9;
  font-family: monospace;
  font-size: 12px;
  max-height: 150px;
  overflow-y: auto;
}

.debug-entry {
  margin: 5px 0;
  border-bottom: 1px dotted #eee;
  padding-bottom: 5px;
}

.debug-time {
  color: #888;
  margin-right: 5px;
}

.debug-error {
  color: #c62828;
}

.debug-warning {
  color: #e65100;
}

.debug-success {
  color: #2e7d32;
}

/* PDF document list */
.document-list {
  margin: 10px 0;
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 10px;
  max-height: 200px;
  overflow-y: auto;
}

.document-item {
  padding: 8px;
  border-bottom: 1px solid #eee;
  display: flex;
  justify-content: space-between;
}

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

/* Loading animation */
.loading {
  display: inline-block;
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0% { opacity: 0.5; }
  50% { opacity: 1; }
  100% { opacity: 0.5; }
}

/* Style for the speaking animation */
.speaking {
  position: relative;
}

.speaking::after {
  content: '';
  position: absolute;
  bottom: -5px;
  left: 0;
  width: 100%;
  height: 2px;
  background: linear-gradient(90deg, #3498db, #9b59b6);
  animation: speak-pulse 1.5s infinite;
}

@keyframes speak-pulse {
  0% { transform: scaleX(0.1); opacity: 0.3; }
  50% { transform: scaleX(1); opacity: 1; }
  100% { transform: scaleX(0.1); opacity: 0.3; }
}

/* Responsive design */
@media (max-width: 600px) {
  .container {
    padding: 10px;
  }
  
  .settings-row {
    flex-direction: column;
    align-items: flex-start;
  }
  
  .settings-row label {
    width: 100%;
    margin-bottom: 5px;
  }
  
  #voice-controls {
    flex-direction: column;
    align-items: flex-start;
  }
}