/**
 * Bedrock Chat - Main Stylesheet
 */

:root {
  /* SenseAbility Brand Colors */
  --primary-color: #00147E;
  --primary-hover: #000f5e;
  --primary-light: #0020be;
  --accent-color: #FF6B00;
  --accent-hover: #e55f00;
  --secondary-color: #64748b;
  --success-color: #10b981;
  --danger-color: #ef4444;
  --warning-color: #f59e0b;

  --bg-primary: #ffffff;
  --bg-secondary: #f8fafc;
  --bg-tertiary: #f1f5f9;
  --bg-sidebar: #001147;

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-sidebar: #e2e8f0;
  --text-sidebar-muted: #94a3b8;

  --border-color: #e2e8f0;
  --border-sidebar: #002873;
  --border-accent: #FF6B00;

  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);

  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;

  --transition: all 0.2s ease;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  height: 100vh;
  overflow: hidden;
}

#app {
  display: flex;
  height: 100vh;
  width: 100%;
}

/* Sidebar */
.sidebar {
  width: 280px;
  background-color: var(--bg-sidebar);
  color: var(--text-sidebar);
  display: flex;
  flex-direction: column;
  transition: transform 0.3s ease;
  z-index: 100;
}

.sidebar-header {
  padding: 0.5rem 1rem;
  border-bottom: 2px solid var(--border-accent);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(135deg, var(--bg-sidebar) 0%, var(--primary-color) 100%);
}

.logo-container {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 0.5rem 0;
  overflow: hidden;
}

.logo-iframe {
  width: 100%;
  height: 80px;
  border: none;
  background: transparent;
}

.sidebar-header h1 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-sidebar);
}

.sidebar-section {
  padding: 1rem;
  border-bottom: 1px solid var(--border-sidebar);
}

.sidebar-section:first-of-type {
  padding-top: 0.5rem;
}

.app-title {
  text-align: center;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border-sidebar);
}

.app-title h2 {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--accent-color);
  text-transform: uppercase;
  letter-spacing: 2px;
  margin: 0;
}

.sidebar-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.sidebar-section h2 {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-sidebar-muted);
}

/* Agent List */
.agent-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.agent-item {
  padding: 0.75rem;
  background-color: rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.agent-item:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

.agent-item.active {
  background-color: rgba(0, 20, 126, 0.2);
  border: 1px solid var(--accent-color);
}

.agent-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  background-color: var(--primary-color);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.875rem;
}

.agent-info {
  flex: 1;
  min-width: 0;
}

.agent-name {
  font-weight: 500;
  font-size: 0.875rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.agent-description {
  font-size: 0.75rem;
  color: var(--text-sidebar-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Conversation List */
.conversation-list {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  max-height: 300px;
  overflow-y: auto;
}

.conversation-item {
  padding: 0.75rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition);
}

.conversation-item:hover {
  background-color: rgba(255, 255, 255, 0.05);
}

.conversation-title {
  font-size: 0.875rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conversation-date {
  font-size: 0.75rem;
  color: var(--text-sidebar-muted);
}

/* Main Content */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Header */
.header {
  padding: 1rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: var(--bg-primary);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.model-selector select {
  padding: 0.5rem 2rem 0.5rem 1rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  background-color: var(--bg-secondary);
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2364748b'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.5rem center;
  background-size: 1rem;
  min-width: 250px;
}

.model-selector select:focus {
  outline: none;
  border-color: var(--accent-color);
  box-shadow: 0 0 0 3px rgba(255, 107, 0, 0.15);
}

.agent-indicator {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

/* Chat Container */
.chat-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.messages {
  flex: 1;
  padding: 1.5rem 2rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.welcome-message {
  text-align: center;
  margin-top: auto;
  margin-bottom: auto;
  color: var(--text-secondary);
}

.welcome-message h2 {
  margin-bottom: 0.5rem;
  color: var(--text-primary);
}

/* Message Styles */
.message {
  display: flex;
  gap: 1rem;
  max-width: 1200px;
  margin-left: auto;
  margin-right: auto;
}

/* Make messages with HTML preview even wider */
.message:has(.html-preview-container) {
  max-width: 1400px;
}

.message.user {
  flex-direction: row-reverse;
}

.message-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-weight: 600;
  font-size: 0.875rem;
}

.message.assistant .message-avatar {
  background-color: var(--primary-color);
  color: white;
}

.message.user .message-avatar {
  background-color: var(--secondary-color);
  color: white;
}

.message-content {
  flex: 1;
  min-width: 0;
}

.message-bubble {
  padding: 1rem;
  border-radius: var(--radius-lg);
  line-height: 1.6;
}

.message.assistant .message-bubble {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
}

.message.user .message-bubble {
  background-color: var(--primary-color);
  color: white;
}

.message-bubble:empty {
  display: none;
}

.message-image {
  max-width: 100%;
  border-radius: var(--radius-md);
  margin-top: 0.5rem;
}

.message-meta {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 0.5rem;
}

.message.user .message-meta {
  text-align: right;
}

/* Streaming Cursor */
.streaming-cursor::after {
  content: '▋';
  animation: blink 1s infinite;
}

@keyframes blink {
  0%, 50% { opacity: 1; }
  100% { opacity: 0; }
}

/* Raw Output Window */
.raw-output-window {
  margin-top: 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-secondary);
  overflow: hidden;
  max-width: 600px;
}

.raw-output-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.75rem;
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border-color);
}

.raw-output-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.raw-output-content {
  margin: 0;
  padding: 0.75rem;
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
  font-size: 0.75rem;
  line-height: 1.4;
  color: var(--text-primary);
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 150px;
  overflow-y: auto;
  background: var(--bg-secondary);
}

/* Input Area */
.input-area {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-color);
  background-color: var(--bg-primary);
}

.file-attachments {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}

.file-attachment {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  background-color: var(--bg-tertiary);
  border-radius: var(--radius-md);
  font-size: 0.875rem;
}

.file-attachment button {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
}

.file-attachment button:hover {
  color: var(--danger-color);
}

.input-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 0.75rem;
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 0.75rem;
  transition: var(--transition);
}

.input-wrapper:focus-within {
  border-color: var(--accent-color);
  box-shadow: 0 0 0 3px rgba(255, 107, 0, 0.15);
}

#messageInput {
  flex: 1;
  border: none;
  background: none;
  resize: none;
  font-family: inherit;
  font-size: 1rem;
  line-height: 1.5;
  max-height: 200px;
  min-height: 24px;
}

#messageInput:focus {
  outline: none;
}

/* Buttons */
.btn-primary {
  background-color: var(--primary-color);
  color: white;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-md);
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
}

.btn-primary:hover:not(:disabled) {
  background-color: var(--primary-hover);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-secondary {
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-md);
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
}

.btn-secondary:hover {
  background-color: var(--border-color);
}

.btn-send {
  background-color: var(--primary-color);
  color: white;
  border: none;
  padding: 0.5rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-send:hover:not(:disabled) {
  background-color: var(--primary-hover);
}

.btn-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-icon {
  background: none;
  border: none;
  padding: 0.5rem;
  cursor: pointer;
  color: var(--text-secondary);
  border-radius: var(--radius-md);
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-icon:hover {
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
}

/* Streaming Indicator */
.streaming-indicator {
  display: flex;
  gap: 0.25rem;
  align-items: center;
  margin-top: 0.5rem;
}

.streaming-indicator .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--accent-color);
  animation: pulse 1.4s infinite ease-in-out both;
}

.streaming-indicator .dot:nth-child(1) { animation-delay: -0.32s; }
.streaming-indicator .dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes pulse {
  0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
  40% { opacity: 1; transform: scale(1); }
}

/* Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
  display: none;
}

.modal.active {
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
}

.modal-content {
  position: relative;
  background-color: var(--bg-primary);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.5rem;
  border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
  font-size: 1.25rem;
  font-weight: 600;
}

.modal-body {
  padding: 1.5rem;
}

/* Form */
.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  font-size: 0.875rem;
}

.form-group input[type="text"],
.form-group input[type="number"],
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-family: inherit;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--accent-color);
  box-shadow: 0 0 0 3px rgba(255, 107, 0, 0.15);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.checkbox-wrapper {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.checkbox-wrapper input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
}

.modal-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  margin-top: 1.5rem;
}

/* Prompt Sections */
.prompt-sections {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1rem;
  background: var(--bg-secondary);
  margin-bottom: 1rem;
}

.prompt-sections > h3 {
  margin: 0 0 1rem 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.prompt-sections .form-group label::after {
  content: ' *';
  color: var(--danger-color);
}

.prompt-sections .form-group label.optional::after {
  content: '';
}

.prompt-sections textarea {
  min-height: 60px;
  resize: vertical;
}

/* Extended Thinking Controls */
#extendedThinkingControls {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1rem;
  background: var(--bg-secondary);
  margin-bottom: 1rem;
}

#extendedThinkingBudgetGroup {
  margin-left: 24px;
  margin-top: 0.5rem;
}

#agentThinkingBudget {
  flex: 1;
  margin-right: 0.5rem;
}

#agentThinkingBudgetValue {
  font-size: 0.875rem;
  color: var(--text-secondary);
  min-width: 50px;
  text-align: right;
}

/* Loading Overlay */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(255, 255, 255, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--border-color);
  border-top-color: var(--accent-color);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Toast */
.toast-container {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  z-index: 3000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  padding: 1rem;
  border-radius: var(--radius-md);
  background-color: var(--bg-primary);
  box-shadow: var(--shadow-lg);
  border-left: 4px solid var(--accent-color);
  min-width: 300px;
  animation: slideIn 0.3s ease;
}

@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.toast.success { border-left-color: var(--success-color); }
.toast.error { border-left-color: var(--danger-color); }
.toast.warning { border-left-color: var(--warning-color); }

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

.mobile-only { display: none; }

/* Responsive */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: -280px;
    top: 0;
    bottom: 0;
    transition: transform 0.3s ease;
  }

  .sidebar.open {
    transform: translateX(280px);
  }

  .mobile-only {
    display: flex;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .model-selector select {
    min-width: 200px;
  }
}

/* Large screens - make content wider */
@media (min-width: 1440px) {
  .message {
    max-width: 1400px;
  }

  .message:has(.html-preview-container) {
    max-width: 1600px;
  }
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary);
}

/* HTML Preview Container */
.html-preview-container {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--bg-secondary);
  max-width: 100%;
  width: 100%;
}

.html-preview-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 1rem;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border-color);
  gap: 1rem;
}

.html-preview-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.html-preview-actions {
  display: flex;
  gap: 0.25rem;
}

.html-preview-actions .btn-icon {
  padding: 0.4rem;
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--text-secondary);
  border-radius: 4px;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.html-preview-actions .btn-icon:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.html-preview-frame {
  width: 100%;
  height: 700px;
  min-height: 500px;
  border: none;
  background: white;
  display: block;
}

.html-preview-container.expanded .html-preview-frame {
  height: 90vh;
  min-height: 600px;
}

/* Image Output */
.image-output-container {
  display: flex;
  justify-content: center;
  padding: 1rem;
}

.generated-image {
  max-width: 100%;
  max-height: 600px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
}
