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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background-color: #f5f5f5;
  color: #333;
  line-height: 1.6;
}

.container {
  max-width: 800px;
  margin: 0 auto;
  padding: 20px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
  padding-bottom: 20px;
  border-bottom: 1px solid #ddd;
}

header h1 {
  font-size: 24px;
  font-weight: 600;
  color: #1a1a1a;
}

.header-links {
  display: flex;
  gap: 20px;
}

.settings-link {
  color: #007bff;
  text-decoration: none;
  font-size: 14px;
}

.settings-link:hover {
  text-decoration: underline;
}

/* Main Content */
main {
  flex: 1;
}

/* Panels */
.panel {
  background: white;
  border-radius: 12px;
  padding: 30px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  margin-bottom: 20px;
}

.panel h2 {
  font-size: 20px;
  margin-bottom: 20px;
  color: #1a1a1a;
}

/* Form Elements */
.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  margin-bottom: 8px;
  font-weight: 500;
  color: #555;
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 16px;
  transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: #007bff;
}

.form-row {
  display: flex;
  gap: 20px;
}

.form-group.half {
  flex: 1;
}

.input-with-button {
  display: flex;
  gap: 10px;
}

.input-with-button input,
.input-with-button select {
  flex: 1;
}

/* Buttons */
.btn {
  display: inline-block;
  padding: 12px 24px;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}

.btn-primary {
  background-color: #007bff;
  color: white;
}

.btn-primary:hover {
  background-color: #0056b3;
}

.btn-secondary {
  background-color: #6c757d;
  color: white;
}

.btn-secondary:hover {
  background-color: #545b62;
}

.btn-success {
  background-color: #28a745;
  color: white;
}

.btn-success:hover {
  background-color: #218838;
}

.btn-danger {
  background-color: #dc3545;
  color: white;
}

.btn-danger:hover {
  background-color: #c82333;
}

.btn-text {
  background: transparent;
  color: #6c757d;
  padding: 8px 16px;
}

.btn-text:hover {
  color: #dc3545;
}

.btn-small {
  padding: 8px 16px;
  font-size: 14px;
}

.btn-large {
  padding: 16px 32px;
  font-size: 18px;
}

.btn-icon {
  padding: 4px 8px;
  font-size: 12px;
  background: #f0f0f0;
  border: 1px solid #ddd;
  border-radius: 4px;
  cursor: pointer;
}

.btn-icon:hover {
  background: #e0e0e0;
}

.button-group {
  margin-top: 15px;
}

/* Divider */
.divider {
  text-align: center;
  margin: 25px 0;
  color: #888;
  position: relative;
}

.divider::before,
.divider::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 40%;
  height: 1px;
  background-color: #ddd;
}

.divider::before {
  left: 0;
}

.divider::after {
  right: 0;
}

/* Session Info */
.session-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 15px;
  border-bottom: 1px solid #eee;
}

.session-code {
  display: flex;
  align-items: center;
  gap: 10px;
}

.session-code strong {
  font-size: 20px;
  font-family: monospace;
  letter-spacing: 2px;
}

.connection-status {
  display: flex;
  align-items: center;
  gap: 8px;
}

.mode-badge {
  padding: 4px 8px;
  border-radius: 12px;
  font-size: 12px;
  background-color: #f0f0f0;
  color: #555;
}

/* Status Indicator */
.status-indicator {
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 14px;
}

.status-indicator.connected {
  background-color: #d4edda;
  color: #155724;
}

.status-indicator.disconnected {
  background-color: #fff3cd;
  color: #856404;
}

/* Mode Selection */
.mode-selection {
  margin-bottom: 20px;
  padding-bottom: 15px;
  border-bottom: 1px solid #eee;
}

.mode-selection h4 {
  font-size: 14px;
  font-weight: 500;
  color: #555;
  margin-bottom: 10px;
}

.mode-toggle {
  display: flex;
  gap: 15px;
}

.mode-option {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 8px 16px;
  border: 2px solid #ddd;
  border-radius: 8px;
  transition: all 0.2s;
}

.mode-option:hover {
  border-color: #007bff;
  background-color: #f8f9fa;
}

.mode-option input[type="radio"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.mode-option input[type="radio"]:checked + span {
  font-weight: 600;
}

.mode-option:has(input[type="radio"]:checked) {
  border-color: #007bff;
  background-color: #e7f3ff;
}

.mode-option span {
  font-size: 14px;
  color: #333;
  user-select: none;
}

/* Transcript */
.transcript-container {
  margin-bottom: 25px;
}

.transcript-container h3 {
  margin-bottom: 15px;
  font-size: 16px;
  color: #555;
}

.transcript {
  height: 300px;
  overflow-y: auto;
  padding: 15px;
  background-color: #f9f9f9;
  border-radius: 8px;
  border: 1px solid #eee;
}

.transcript-entry {
  margin-bottom: 15px;
  padding: 12px;
  border-radius: 8px;
  background-color: white;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.transcript-entry.self {
  background-color: #e3f2fd;
  margin-left: 20%;
}

.transcript-entry.partner {
  background-color: #f3e5f5;
  margin-right: 20%;
}

.transcript-entry .original {
  font-size: 14px;
  color: #666;
  margin-bottom: 5px;
}

.transcript-entry .translated {
  font-size: 16px;
  color: #333;
}

.transcript-entry .partial {
  opacity: 0.6;
  font-style: italic;
}

/* Controls */
.controls {
  text-align: center;
  margin-bottom: 20px;
}

/* Text Input Container */
.text-input-container {
  margin-top: 15px;
  margin-bottom: 20px;
}

.text-input-wrapper {
  display: flex;
  gap: 10px;
  align-items: center;
}

.text-input-wrapper input {
  flex: 1;
  padding: 12px 16px;
  border: 2px solid #ddd;
  border-radius: 8px;
  font-size: 16px;
  transition: border-color 0.2s;
}

.text-input-wrapper input:focus {
  outline: none;
  border-color: #007bff;
}

.text-input-wrapper button {
  padding: 12px 24px;
  white-space: nowrap;
}

/* Audio Indicator */
.audio-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 15px;
  color: #28a745;
}

.audio-wave {
  display: flex;
  align-items: center;
  gap: 3px;
  height: 24px;
}

.audio-wave span {
  width: 4px;
  height: 100%;
  background-color: #28a745;
  border-radius: 2px;
  animation: wave 0.5s ease-in-out infinite;
}

.audio-wave span:nth-child(2) { animation-delay: 0.1s; }
.audio-wave span:nth-child(3) { animation-delay: 0.2s; }
.audio-wave span:nth-child(4) { animation-delay: 0.3s; }
.audio-wave span:nth-child(5) { animation-delay: 0.4s; }

@keyframes wave {
  0%, 100% { transform: scaleY(0.3); }
  50% { transform: scaleY(1); }
}

/* Latency Display */
.latency-display {
  text-align: center;
  font-size: 12px;
  color: #888;
  margin-bottom: 15px;
}

/* Settings Sections */
.settings-section {
  background: white;
  border-radius: 12px;
  padding: 25px;
  margin-bottom: 20px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.settings-section h2 {
  font-size: 18px;
  margin-bottom: 20px;
  padding-bottom: 10px;
  border-bottom: 1px solid #eee;
}

.help-text {
  display: block;
  margin-top: 5px;
  font-size: 12px;
  color: #888;
}

.validation-status {
  display: block;
  margin-top: 5px;
  font-size: 12px;
}

.validation-status.valid {
  color: #28a745;
}

.validation-status.invalid {
  color: #dc3545;
}

.form-actions {
  display: flex;
  gap: 15px;
  justify-content: center;
  margin-top: 30px;
}

/* Status Message */
.status-message {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 14px;
  z-index: 1000;
  animation: fadeIn 0.3s ease;
}

.status-message.success {
  background-color: #d4edda;
  color: #155724;
  border: 1px solid #c3e6cb;
}

.status-message.error {
  background-color: #f8d7da;
  color: #721c24;
  border: 1px solid #f5c6cb;
}

.status-message.info {
  background-color: #d1ecf1;
  color: #0c5460;
  border: 1px solid #bee5eb;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateX(-50%) translateY(20px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* Logs Section */
.logs-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  user-select: none;
  padding: 5px 0;
}

.logs-header h3 {
  margin: 0;
  font-size: 16px;
  color: #555;
}

.toggle-icon {
  font-size: 14px;
  transition: transform 0.2s;
}

.toggle-icon.open {
  transform: rotate(180deg);
}

.logs-container {
  margin-top: 15px;
}

.logs {
  height: 200px;
  overflow-y: auto;
  padding: 12px;
  background-color: #1e1e1e;
  color: #d4d4d4;
  border-radius: 6px;
  font-family: 'Courier New', monospace;
  font-size: 12px;
  line-height: 1.4;
  margin-bottom: 10px;
}

.log-entry {
  margin-bottom: 4px;
  word-wrap: break-word;
}

.log-entry.info {
  color: #4ec9b0;
}

.log-entry.warn {
  color: #dcdcaa;
}

.log-entry.error {
  color: #f48771;
}

/* Chat Container */
.chat-container {
  margin-bottom: 25px;
}

.chat-container h3 {
  margin-bottom: 15px;
  font-size: 16px;
  color: #555;
}

.chat-messages {
  height: 300px;
  overflow-y: auto;
  padding: 15px;
  background-color: #ffffff;
  border-radius: 8px;
  border: 1px solid #e0e0e0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-message {
  display: flex;
  flex-direction: column;
  max-width: 75%;
  animation: slideIn 0.3s ease;
}

.chat-message.self {
  align-self: flex-end;
}

.chat-message.partner {
  align-self: flex-start;
}

.chat-message-header {
  font-size: 11px;
  color: #888;
  margin-bottom: 4px;
  font-weight: 500;
}

.chat-message.self .chat-message-header {
  text-align: right;
}

.chat-bubble {
  padding: 10px 14px;
  border-radius: 16px;
  word-wrap: break-word;
  position: relative;
}

.chat-message.self .chat-bubble {
  background-color: #007bff;
  color: white;
  border-bottom-right-radius: 4px;
}

.chat-message.partner .chat-bubble {
  background-color: #f1f3f4;
  color: #333;
  border-bottom-left-radius: 4px;
}

.chat-bubble-text {
  font-size: 14px;
  line-height: 1.4;
  margin-bottom: 4px;
}

.chat-bubble-translation {
  font-size: 12px;
  opacity: 0.85;
  font-style: italic;
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid rgba(255, 255, 255, 0.2);
}

.chat-message.partner .chat-bubble-translation {
  border-top-color: rgba(0, 0, 0, 0.1);
}

.chat-bubble.partial {
  opacity: 0.7;
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulse {
  0%, 100% { opacity: 0.7; }
  50% { opacity: 0.9; }
}

/* Utility Classes */
.hidden {
  display: none !important;
}

/* Footer */
footer {
  text-align: center;
  padding-top: 20px;
  margin-top: 30px;
  border-top: 1px solid #ddd;
  color: #888;
  font-size: 14px;
}

/* Responsive */
@media (max-width: 600px) {
  .container {
    padding: 15px;
  }

  .panel {
    padding: 20px;
  }

  .form-row {
    flex-direction: column;
    gap: 0;
  }

  .session-info {
    flex-direction: column;
    gap: 10px;
  }

  .transcript-entry.self,
  .transcript-entry.partner {
    margin-left: 0;
    margin-right: 0;
  }
}
