/* lab.css - WhatsApp-like chatbot simulator styles */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
    Arial, sans-serif;
  background: #e5ddd5;
  height: 100vh;
  overflow: hidden;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  height: 100vh;
  background: white;
  display: flex;
  flex-direction: column;
}

/* Header */
.lab-header {
  background: #075e54;
  color: white;
  padding: 15px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.lab-title {
  font-size: 18px;
  font-weight: 500;
}

.lab-controls {
  display: flex;
  gap: 10px;
  align-items: center;
}

.restaurant-selector {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: white;
  padding: 5px 10px;
  border-radius: 4px;
  font-size: 12px;
}

.clear-btn {
  background: #25d366;
  border: none;
  color: white;
  padding: 6px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
}

.clear-btn:hover {
  background: #20c157;
}

/* Confirm state for clear chat */
.clear-btn.danger {
  background: #dc3545;
}
.clear-btn.danger:hover {
  background: #c82333;
}

/* Chat Container */
.chat-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  /* Allow inner flex child (.messages-area) to actually shrink and scroll */
  min-height: 0;
  background: #e5ddd5;
  background-image: radial-gradient(
      circle at 25px 25px,
      rgba(255, 255, 255, 0.2) 2%,
      transparent 0%
    ),
    radial-gradient(
      circle at 75px 75px,
      rgba(255, 255, 255, 0.2) 2%,
      transparent 0%
    );
  background-size: 100px 100px;
}

/* Messages Area */
.messages-area {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  /* Important for Safari/Chrome inside flex columns */
  min-height: 0;
}

/* Message Bubbles */
.message {
  max-width: 70%;
  padding: 8px 12px;
  border-radius: 8px;
  position: relative;
  word-wrap: break-word;
  animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.message.user {
  background: #dcf8c6;
  align-self: flex-end;
  border-bottom-right-radius: 2px;
  margin-left: auto;
}

.message.bot {
  background: white;
  align-self: flex-start;
  border-bottom-left-radius: 2px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.message-content {
  font-size: 14px;
  line-height: 1.4;
  margin-bottom: 4px;
}

.message-time {
  font-size: 11px;
  color: #999;
  text-align: right;
}

.message.user .message-time {
  color: #4a4a4a;
}

/* Typing Indicator */
.typing-indicator {
  display: none;
  background: white;
  padding: 12px 16px;
  border-radius: 8px;
  border-bottom-left-radius: 2px;
  max-width: 70%;
  align-self: flex-start;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.typing-dots {
  display: flex;
  gap: 4px;
}

.typing-dots span {
  width: 8px;
  height: 8px;
  background: #999;
  border-radius: 50%;
  animation: typing 1.4s infinite ease-in-out;
}

.typing-dots span:nth-child(2) {
  animation-delay: 0.2s;
}
.typing-dots span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typing {
  0%,
  60%,
  100% {
    transform: translateY(0);
    opacity: 0.5;
  }
  30% {
    transform: translateY(-10px);
    opacity: 1;
  }
}

/* Input Area */
.input-area {
  background: #f0f0f0;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-top: 1px solid #ddd;
}

.message-input {
  flex: 1;
  padding: 10px 15px;
  border: none;
  border-radius: 20px;
  background: white;
  font-size: 14px;
  outline: none;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.send-btn {
  background: #25d366;
  border: none;
  color: white;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.send-btn:hover {
  background: #20c157;
}

.send-btn:disabled {
  background: #ccc;
  cursor: not-allowed;
}

/* Quick Actions */
.quick-actions {
  background: #f8f8f8;
  padding: 10px 20px;
  border-top: 1px solid #ddd;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.quick-action {
  background: white;
  border: 1px solid #ddd;
  padding: 6px 12px;
  border-radius: 15px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

.quick-action:hover {
  background: #e8f5e8;
  border-color: #25d366;
}

/* Responsive */
@media (max-width: 768px) {
  .container {
    height: 100vh;
  }

  .lab-header {
    padding: 10px 15px;
  }

  .lab-title {
    font-size: 16px;
  }

  .messages-area {
    padding: 15px;
  }

  .message {
    max-width: 85%;
  }

  .input-area {
    padding: 8px 15px;
  }
}

/* Status indicators */
.connection-status {
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 10px;
  margin-left: 10px;
}

.connection-status.connected {
  background: #d4edda;
  color: #155724;
}

.connection-status.disconnected {
  background: #f8d7da;
  color: #721c24;
}

/* Message types */
.message.system {
  background: #fff3cd;
  color: #856404;
  align-self: center;
  font-size: 12px;
  border-radius: 15px;
  max-width: 90%;
  text-align: center;
}

.message-buttons {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-top: 8px;
}

.message-button {
  background: #f0f0f0;
  border: 1px solid #ddd;
  padding: 8px 12px;
  border-radius: 15px;
  cursor: pointer;
  text-align: center;
  font-size: 13px;
  transition: all 0.2s;
}

.message-button:hover {
  background: #e8f5e8;
  border-color: #25d366;
}

/* Firebase Status Indicator */
.firebase-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  margin-top: 8px;
  border: 1px solid #e0e0e0;
  background: #f8f9fa;
  transition: all 0.3s ease;
}

.firebase-status .status-icon {
  font-size: 16px;
}

.firebase-status .status-text {
  flex: 1;
  font-weight: 600;
}

.firebase-status .status-details {
  font-size: 10px;
  color: #666;
  font-weight: normal;
}

.firebase-status .debug-btn {
  background: #6c757d;
  color: white;
  border: none;
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.2s ease;
}

.firebase-status .debug-btn:hover {
  background: #5a6268;
}

/* Status states */
.firebase-status.ready {
  background: #f8f9fa;
  border-color: #dee2e6;
  color: #495057;
}

.firebase-status.connecting {
  background: #fff3cd;
  border-color: #ffeaa7;
  color: #856404;
  animation: pulse 2s infinite;
}

.firebase-status.connected {
  background: #d4edda;
  border-color: #c3e6cb;
  color: #155724;
}

.firebase-status.error {
  background: #f8d7da;
  border-color: #f5c6cb;
  color: #721c24;
  animation: shake 0.5s ease-in-out;
}

.firebase-status.writing {
  background: #d1ecf1;
  border-color: #bee5eb;
  color: #0c5460;
  animation: pulse 1s infinite;
}

.firebase-status.reading {
  background: #e2e3e5;
  border-color: #d6d8db;
  color: #383d41;
  animation: pulse 1.5s infinite;
}

/* Debug Panel */
.debug-panel {
  position: fixed;
  top: 20px;
  right: 20px;
  width: 400px;
  max-height: 80vh;
  background: white;
  border: 1px solid #ddd;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 1000;
  overflow: hidden;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}

.debug-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: #f8f9fa;
  border-bottom: 1px solid #dee2e6;
}

.debug-header h3 {
  margin: 0;
  font-size: 16px;
  color: #495057;
}

.debug-header .close-btn {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: #6c757d;
  padding: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: background 0.2s ease;
}

.debug-header .close-btn:hover {
  background: #e9ecef;
}

.debug-content {
  padding: 16px;
  max-height: calc(80vh - 60px);
  overflow-y: auto;
}

.debug-section {
  margin-bottom: 20px;
}

.debug-section h4 {
  margin: 0 0 12px 0;
  font-size: 14px;
  color: #495057;
  border-bottom: 1px solid #dee2e6;
  padding-bottom: 4px;
}

.status-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.status-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.status-item .label {
  font-size: 11px;
  color: #6c757d;
  font-weight: 500;
}

.status-item .value {
  font-size: 12px;
  color: #495057;
  font-weight: 600;
  padding: 4px 8px;
  background: #f8f9fa;
  border-radius: 4px;
  border: 1px solid #dee2e6;
}

.status-item .value.connected {
  background: #d4edda;
  border-color: #c3e6cb;
  color: #155724;
}

.status-item .value.disconnected {
  background: #f8d7da;
  border-color: #f5c6cb;
  color: #721c24;
}

.operations-list,
.results-list {
  max-height: 150px;
  overflow-y: auto;
  border: 1px solid #dee2e6;
  border-radius: 4px;
  background: #f8f9fa;
}

.operation-item,
.result-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border-bottom: 1px solid #dee2e6;
  font-size: 11px;
}

.operation-item:last-child,
.result-item:last-child {
  border-bottom: none;
}

.operation-item .time,
.result-item .time {
  color: #6c757d;
  min-width: 60px;
}

.operation-item .operation,
.result-item .operation {
  flex: 1;
  color: #495057;
  font-weight: 500;
}

.operation-item .restaurant {
  color: #6c757d;
  font-size: 10px;
}

.result-item .status {
  font-size: 14px;
}

.result-item .error-msg {
  color: #dc3545;
  font-size: 10px;
  font-style: italic;
}

.result-item.success {
  background: rgba(40, 167, 69, 0.1);
}

.result-item.error {
  background: rgba(220, 53, 69, 0.1);
}

.debug-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.action-btn {
  background: #007bff;
  color: white;
  border: none;
  border-radius: 4px;
  padding: 8px 12px;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.2s ease;
  flex: 1;
  min-width: 120px;
}

.action-btn:hover {
  background: #0056b3;
}

/* Animations */
@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.7;
  }
}

@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-2px);
  }
  75% {
    transform: translateX(2px);
  }
}

/* Enhanced console logging styles */
.console-log-group {
  border-left: 3px solid #007bff;
  padding-left: 10px;
  margin: 5px 0;
}

.console-log-firebase {
  border-left-color: #dc3545;
  background: rgba(220, 53, 69, 0.05);
}

.console-log-success {
  border-left-color: #28a745;
  background: rgba(40, 167, 69, 0.05);
}

.console-log-warning {
  border-left-color: #ffc107;
  background: rgba(255, 193, 7, 0.05);
}

.console-log-error {
  border-left-color: #dc3545;
  background: rgba(220, 53, 69, 0.05);
}
