/* Journey Edit Layout with Chat */
.journey-edit-container {
  --header-height: 8rem; /* Approximate header height */
  display: flex;
  gap: 2rem;
  max-width: 1400px;
  margin: 0 auto;
  padding: 1rem;
}

.journey-edit-main {
  flex: 1;
  min-width: 0;
}

.journey-edit-sidebar {
  width: 400px;
  position: sticky;
  top: 1rem;
  height: calc(100vh - var(--header-height) - 2rem);
  max-height: calc(100dvh - var(--header-height) - 2rem);
}

/* Chat Container Styles */
.journey-chat-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  border: 1px solid var(--pico-muted-border-color);
  border-radius: var(--pico-border-radius);
  box-shadow: var(--pico-box-shadow);
}

.chat-header {
  padding: 1rem;
  border-bottom: 1px solid var(--pico-muted-border-color);
  border-radius: var(--pico-border-radius) var(--pico-border-radius) 0 0;
}

.chat-header h3 {
  margin: 0;
  font-size: 1.125rem;
  color: var(--pico-color);
}

.chat-model {
  margin: 0.25rem 0 0;
  font-size: 0.875rem;
  color: var(--pico-muted-color);
}

/* Messages Area */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* Message Styles */
.message {
  margin-bottom: 1.25rem;
  padding: 0.625rem;
  border-left: 3px solid var(--pico-muted-border-color);
}

.message.user {
  border-left-color: #007bff;
}

.message.assistant {
  border-left-color: #28a745;
}

.message.tool {
  border-left-color: #6c757d;
}

.message-role {
  font-weight: bold;
  margin-bottom: 0.3125rem;
  font-size: 0.875rem;
}

.message-content {
  white-space: pre-wrap;
}

.message-timestamp {
  font-size: 0.85em;
  color: var(--pico-muted-color);
  margin-top: 0.3125rem;
}

/* Tool Call Styles */
.tool-calls {
  margin-top: 0.625rem;
}

.tool-calls details {
  margin-bottom: 0.5rem;
  font-family: var(--pico-font-family-monospace);
}

.tool-calls summary {
  cursor: pointer;
}

.tool-call-content {
  padding: 0.625rem 0;
  font-size: 0.9em;
}

.tool-call-args {
  margin-bottom: 0.5rem;
}

.tool-call-arg {
  margin-left: 0.625rem;
  margin-bottom: 0.25rem;
}

.tool-call-arg pre {
  margin: 0.25rem 0 0 1.25rem;
  white-space: pre-wrap;
  word-wrap: break-word;
}

/* Tool Response Styles */
.tool-response details {
  font-family: var(--pico-font-family-monospace);
}

.tool-response summary {
  cursor: pointer;
}

.tool-response-content {
  padding: 0.625rem 0;
  white-space: pre-wrap;
  font-size: 0.9em;
}

/* Chat Input Area */
.chat-input {
  padding: 1rem;
  border-top: 1px solid var(--pico-muted-border-color);
  border-radius: 0 0 var(--pico-border-radius) var(--pico-border-radius);
}

.chat-input-group {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.chat-input-field {
  width: 100%;
  padding: 0.75rem 1rem;
  border: var(--pico-border-width) solid var(--pico-form-element-border-color);
  border-radius: var(--pico-border-radius);
  font-size: 1rem;
  transition: border-color var(--pico-transition);
  box-sizing: border-box;
  background-color: var(--pico-form-element-background-color);
  color: var(--pico-form-element-color);
}

.chat-input-field:focus {
  outline: none;
  border-color: var(--pico-primary);
  box-shadow: 0 0 0 3px var(--pico-primary-focus);
}

.chat-submit-button {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--pico-primary);
  color: var(--pico-primary-inverse);
  border: none;
  border-radius: var(--pico-border-radius);
  font-size: 0.9375rem;
  font-weight: 500;
  cursor: pointer;
  transition: background-color var(--pico-transition);
  box-sizing: border-box;
}

.chat-submit-button:hover {
  background: var(--pico-primary-hover);
}

.chat-submit-button:active {
  transform: translateY(1px);
}

.chat-errors {
  margin-bottom: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: var(--pico-del-background-color);
  border: var(--pico-border-width) solid var(--pico-del-color);
  border-radius: var(--pico-border-radius);
  color: var(--pico-del-color);
  font-size: 0.875rem;
}

/* Loading State */
.chat-loading {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 1rem;
  color: var(--pico-muted-color);
}

.chat-loading::after {
  content: '';
  display: inline-block;
  width: 1rem;
  height: 1rem;
  margin-left: 0.5rem;
  border: 2px solid var(--pico-muted-border-color);
  border-radius: 50%;
  border-top-color: var(--pico-primary);
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Responsive Design */
@media (max-width: 1024px) {
  .journey-edit-container {
    flex-direction: column;
  }

  .journey-edit-sidebar {
    width: 100%;
    position: static;
    height: min(500px, calc(100dvh - var(--header-height) - 2rem));
    max-height: none;
    margin-top: 2rem;
  }
}

@media (max-width: 768px) {
  .journey-edit-sidebar {
    height: min(400px, calc(100dvh - var(--header-height) - 2rem));
  }
}
