/* Task Canvas Styles */

body {
  padding-top: 70px;
  overflow: hidden;
}

.main-container {
  height: calc(100vh - 70px);
  padding: 0;
}

.row {
  margin: 0;
  height: 100%;
}

/* ===== Left Panel: Chat Interface ===== */
.chat-panel {
  background-color: #f8f9fa;
  border-right: 2px solid #dee2e6;
  padding: 0;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.chat-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 20px;
}

.chat-history {
  flex: 1;
  overflow-y: auto;
  margin-bottom: 20px;
  padding: 15px;
  background-color: white;
  border-radius: 8px;
  border: 1px solid #e0e0e0;
}

.welcome-message {
  text-align: center;
  padding: 40px 20px;
  color: #6c757d;
}

.welcome-message h4 {
  color: #5f849b;
  margin-bottom: 15px;
}

.chat-message {
  margin-bottom: 20px;
  padding: 12px 16px;
  border-radius: 8px;
  max-width: 90%;
  animation: fadeIn 0.3s;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.chat-message.user {
  background-color: #e3f2fd;
  margin-left: auto;
  border: 1px solid #90caf9;
}

.chat-message.ai {
  background-color: #f5f5f5;
  margin-right: auto;
  border: 1px solid #e0e0e0;
}

.chat-message.error {
  background-color: #ffebee;
  border: 1px solid #ef5350;
  margin-right: auto;
}

.chat-message .message-header {
  font-weight: bold;
  margin-bottom: 8px;
  font-size: 0.9rem;
}

.chat-message.user .message-header {
  color: #1976d2;
}

.chat-message.ai .message-header {
  color: #5f849b;
}

.chat-message.error .message-header {
  color: #c62828;
}

.chat-message .message-content {
  line-height: 1.5;
  word-wrap: break-word;
}

.chat-message .message-content a {
  color: #2196f3;
  text-decoration: underline;
  font-weight: 500;
  word-break: break-all;
}

.chat-message .message-content a:hover {
  color: #1976d2;
  text-decoration: none;
}

.waiting-indicator {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 18px;
  background: linear-gradient(135deg, #fff3cd 0%, #ffe8a1 100%);
  border: 1px solid #ffc107;
  border-radius: 10px;
  margin-bottom: 15px;
  box-shadow: 0 2px 8px rgba(255, 193, 7, 0.2);
  max-width: 90%;
}

.waiting-indicator .spinner-border {
  width: 1.2rem;
  height: 1.2rem;
  flex-shrink: 0;
  margin-top: 2px;
}

.waiting-messages {
  position: relative;
  min-height: 24px;
  flex: 1;
  overflow: hidden;
}

.waiting-message {
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.4s ease;
  line-height: 1.6;
  color: #856404;
  font-weight: 500;
}

.waiting-message.active {
  opacity: 1;
  transform: translateY(0);
}

.waiting-message.fading {
  opacity: 0;
  transform: translateY(-10px);
}

.chat-input-area {
  border-top: 1px solid #e0e0e0;
  padding-top: 15px;
  background-color: white;
  border-radius: 8px;
  padding: 15px;
}

.chat-input-area textarea {
  resize: none;
  border: 1px solid #ced4da;
  font-size: 0.95rem;
}

.chat-input-area textarea:focus {
  border-color: #5f849b;
  box-shadow: 0 0 0 0.2rem rgba(95, 132, 155, 0.25);
}

/* ===== Right Panel: Preview ===== */
.preview-panel {
  background-color: white;
  padding: 0;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.preview-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 20px;
}

.preview-header {
  padding: 15px 20px;
  background-color: #5f849b;
  color: white;
  border-radius: 8px 8px 0 0;
  margin: -20px -20px 0 -20px;
}

.preview-header h5 {
  margin: 0;
  font-size: 1.1rem;
}

.preview-area {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  background-color: #fafafa;
  border: 1px solid #e0e0e0;
  border-top: none;
  margin: 0 -20px -20px -20px;
}

.preview-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 40px;
}

/* ===== Task Preview Blocks ===== */
.preview-block {
  background-color: white;
  border: 1px solid #dee2e6;
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 15px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.preview-block.block-title {
  background-color: #e3f2fd;
  border-left: 4px solid #2196f3;
}

.preview-block.block-title h2 {
  margin: 0;
  font-size: 1.5rem;
  color: #1565c0;
}

.preview-block.block-text {
  border-left: 4px solid #9e9e9e;
}

.preview-block.block-question {
  background-color: #fff3e0;
  border-left: 4px solid #ff9800;
}

.preview-block.block-self-assessment {
  background-color: #f3e5f5;
  border-left: 4px solid #9c27b0;
}

.block-label {
  display: inline-block;
  font-size: 0.85rem;
  font-weight: bold;
  padding: 4px 12px;
  border-radius: 4px;
  margin-bottom: 12px;
  text-transform: uppercase;
}

.block-label.label-title {
  background-color: #2196f3;
  color: white;
}

.block-label.label-text {
  background-color: #9e9e9e;
  color: white;
}

.block-label.label-question {
  background-color: #ff9800;
  color: white;
}

.block-label.label-self-assessment {
  background-color: #9c27b0;
  color: white;
}

.question-type {
  font-weight: bold;
  color: #f57c00;
  margin-bottom: 10px;
}

.question-options {
  margin-top: 15px;
}

.question-option {
  padding: 10px;
  background-color: white;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  margin-bottom: 8px;
}

.ai-prompt-section {
  margin-top: 15px;
  padding: 12px;
  background-color: rgba(255, 255, 255, 0.7);
  border: 1px dashed #ff9800;
  border-radius: 6px;
  font-size: 0.9rem;
}

.ai-prompt-section .section-title {
  font-weight: bold;
  color: #f57c00;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.ai-prompt-preview {
  max-height: 100px;
  overflow-y: auto;
  font-family: 'Courier New', monospace;
  font-size: 0.85rem;
  color: #424242;
  line-height: 1.4;
}

.question-flags {
  margin-top: 12px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.flag-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 0.8rem;
  font-weight: 500;
}

.flag-badge.callAISI {
  background-color: #4caf50;
  color: white;
}

.flag-badge.repeated {
  background-color: #2196f3;
  color: white;
}

.self-assessment-prompt {
  font-style: italic;
  margin-bottom: 12px;
  color: #6a1b9a;
}

.self-assessment-options {
  margin-top: 10px;
}

/* ===== Scrollbar Styling ===== */
.chat-history::-webkit-scrollbar,
.preview-area::-webkit-scrollbar {
  width: 8px;
}

.chat-history::-webkit-scrollbar-track,
.preview-area::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 4px;
}

.chat-history::-webkit-scrollbar-thumb,
.preview-area::-webkit-scrollbar-thumb {
  background: #888;
  border-radius: 4px;
}

.chat-history::-webkit-scrollbar-thumb:hover,
.preview-area::-webkit-scrollbar-thumb:hover {
  background: #555;
}

/* ===== Responsive Design ===== */
@media (max-width: 768px) {
  .main-container {
    height: auto;
  }

  .chat-panel,
  .preview-panel {
    height: 50vh;
    border-right: none;
    border-bottom: 2px solid #dee2e6;
  }
}

/* Custom button styles to match main theme */
.chat-input-area .btn-primary,
#saveTaskBtn.btn-success {
  background-color: #5f849b !important;
  border-color: #5f849b !important;
  color: white !important; /* Ensure text color is white */
}

.chat-input-area .btn-primary:hover,
.chat-input-area .btn-primary:focus,
#saveTaskBtn.btn-success:hover,
#saveTaskBtn.btn-success:focus {
  background-color: #55768a !important; /* Darker shade for hover/focus */
  border-color: #55768a !important;
}

/* Also ensure active state matches hover */
.chat-input-area .btn-primary:active,
#saveTaskBtn.btn-success:active {
  background-color: #55768a !important;
  border-color: #55768a !important;
}
