/* Prevent layout shift when modals hide the scrollbar */
html {
  scrollbar-gutter: stable;
}

/* Panel tabs */
.panel-tab.active {
  background-color: white;
  color: #111827;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

/* Sidebar transitions */
#pages-sidebar {
  width: 240px;
  transition: width 0.3s ease-in-out, background-color 0.3s ease-in-out;
  overflow: hidden;
}

#pages-sidebar.collapsed {
  width: 64px;
  background-color: rgba(243, 244, 246, 0.3);
}

.sidebar-text {
  opacity: 1;
  transition: opacity 0.2s ease-in-out;
}

#pages-sidebar.collapsed .sidebar-text {
  opacity: 0;
}

.sidebar-add-btn {
  opacity: 1;
  transition: opacity 0.2s ease-in-out;
}

#pages-sidebar.collapsed .sidebar-add-btn {
  opacity: 0;
  display: none;
}

/* Add page button at end of list - visible only when collapsed */
.sidebar-add-btn-collapsed {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease-in-out;
}

.sidebar-add-btn-collapsed {
  transition: background-color 0.2s ease-in-out !important;
}

.sidebar-add-btn-collapsed:hover {
  background-color: rgb(240, 240, 240) !important;
}

.add-page-icon {
  color: rgb(160, 160, 160) !important;
  transition: color 0.2s ease-in-out !important;
}

.sidebar-add-btn-collapsed:hover .add-page-icon {
  color: #f46a3c !important;
}

#pages-sidebar.collapsed .sidebar-add-btn-collapsed {
  opacity: 1;
  pointer-events: auto;
  transition: opacity 0.3s ease-in-out;
}

#toggle-chevron {
  transition: transform 0.3s ease-in-out;
}

#pages-sidebar.collapsed #toggle-chevron {
  transform: rotate(180deg);
}

/* Chat area transitions */
#chat-area {
  width: 450px;
  transition: width 0.3s ease-in-out, background-color 0.3s ease-in-out;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
}

#chat-area.collapsed {
  width: 48px;
  background-color: rgba(243, 244, 246, 0.2);
}

#chat-area.resizing {
  transition: none;
}

/* Resize handle */
.chat-resize-handle {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  cursor: ew-resize;
  z-index: 10;
  transition: background-color 0.2s ease-in-out;
}

.chat-resize-handle:hover {
  background-color: color-mix(in srgb, var(--color-primary) 30%, transparent);
}

.chat-resize-handle.active {
  background-color: color-mix(in srgb, var(--color-primary) 50%, transparent);
}

#chat-area.collapsed .chat-resize-handle {
  display: none;
  pointer-events: none;
}

/* Iframe overlay during resize */
.resize-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 9999;
  cursor: ew-resize;
  display: none;
}

.resize-overlay.active {
  display: block;
}

#flex-row {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: opacity 0.3s ease-in-out;
}

#collection-chat-area {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

#collection-flex-row {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

#model-chat-area {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  min-width: 0;
}

#model-flex-row {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

#chat-area.collapsed #flex-row {
  opacity: 0;
}

#chat-area .chat-text {
  opacity: 1;
  transition: opacity 0.2s ease-in-out;
  white-space: nowrap;
  overflow: hidden;
}

#chat-area.collapsed .chat-text {
  opacity: 0;
}

.chat-current {
  transition: opacity 0.3s ease-in-out;
}

#chat-area.collapsed .chat-current {
  opacity: 0;
}

#chat-toggle-chevron {
  transition: transform 0.3s ease-in-out;
}

#chat-area.collapsed #chat-toggle-chevron {
  transform: rotate(180deg);
}

.chat-icons {
  position: absolute;
  right: 0.5rem;
  transition: left 0.3s ease-in-out, right 0.3s ease-in-out, transform 0.3s ease-in-out;
}

#chat-area.collapsed .chat-icons {
  left: 50%;
  right: auto;
  transform: translateX(-50%);
}

#chat-area.collapsed #chat-menu-dropdown {
  display: none;
}

/* Adjust main grid when collapsed */
main {
  transition: grid-template-columns 0.3s ease-in-out;
}

main.sidebar-collapsed {
  grid-template-columns: 80px 64px 450px 2fr;
}

main.chat-collapsed {
  grid-template-columns: 80px 240px 48px 2fr;
}

main.sidebar-collapsed.chat-collapsed {
  grid-template-columns: 80px 64px 48px 2fr;
}

.sidebar-icons {
  position: absolute;
  right: 0.5rem;
  transition: left 0.3s ease-in-out, right 0.3s ease-in-out, transform 0.3s ease-in-out;
}

#pages-sidebar.collapsed .sidebar-icons {
  left: 50%;
  right: auto;
  transform: translateX(-50%);
}

.sidebar-list-item {
  overflow: hidden;
  white-space: nowrap;
  transition: background-color 0.3s ease-in-out;
  flex-shrink: 0; /* DaisyUI .list is display:flex; prevent items from compressing when ul is height-bounded */
}

.sidebar-item-text {
  opacity: 1;
  transition: opacity 0.2s ease-in-out;
}

#pages-sidebar.collapsed .sidebar-item-text {
  opacity: 0;
}

.sidebar-list-item:not(.active):hover {
  background-color: rgb(249 250 251);
}

/* Page delete button - hidden by default, visible on hover */
.delete-page-btn {
  opacity: 0;
  transition: opacity 0.2s ease-in-out;
}

.sidebar-list-item:hover .delete-page-btn {
  opacity: 1;
}

/* Hide delete button when sidebar is collapsed */
#pages-sidebar.collapsed .delete-page-btn {
  display: none !important;
}

/* Agent delete button - hidden by default, visible on hover */
.delete-agent-btn {
  opacity: 0;
  transition: opacity 0.2s ease-in-out;
}

.sidebar-list-item:hover .delete-agent-btn {
  opacity: 1;
}

/* Email delete button - hidden by default, visible on hover */
.delete-email-btn {
  opacity: 0;
  transition: opacity 0.2s ease-in-out;
}

.sidebar-list-item:hover .delete-email-btn {
  opacity: 1;
}

/* Collection delete button - hidden by default, visible on hover */
.delete-collection-btn {
  opacity: 0;
  transition: opacity 0.2s ease-in-out;
}

.sidebar-list-item:hover .delete-collection-btn {
  opacity: 1;
}

/* Field delete button - hidden by default, visible on hover */
.delete-field-btn {
  opacity: 0;
  transition: opacity 0.2s ease-in-out;
}

.sidebar-list-item:hover .delete-field-btn {
  opacity: 1;
}

/* Model delete button - hidden by default, visible on hover */
.delete-model-btn {
  opacity: 0;
  transition: opacity 0.2s ease-in-out;
}

.sidebar-list-item:hover .delete-model-btn {
  opacity: 1;
}

/* Chat textarea placeholder */
#chat-textarea::placeholder {
  color: rgb(156 163 175);
  opacity: 1;
}

/* Chat message action icons */
.chat-current i.cursor-pointer {
  transition: opacity 0.2s ease-in-out;
}

.chat-current i.cursor-pointer:hover {
  opacity: 1 !important;
}

/* Hide thumbs icons by default, show on chat message hover */
.chat-action-hover {
  opacity: 0 !important;
  transition: opacity 0.2s ease-in-out;
}

.chat-message:hover .chat-action-hover {
  opacity: 0.5 !important;
}

.chat-message:hover .chat-action-hover:hover {
  opacity: 1 !important;
}

/* Thinking items - clickable styling */
.has-thinking:hover {
  background-color: rgba(0, 0, 0, 0.05);
  border-radius: 0.25rem;
}

.has-thinking {
  transition: background-color 0.2s ease-in-out;
}

:root {
  --color-primary: #f46a3c;
  --color-secondary: #0f0f0f;
  --wy-theme-color: #f46a3c;
  --wy-border-radius: 8px;
}

/* Custom scrollbar styling for all chat areas */
.chat-current {
  /* Standard scrollbar properties (Firefox and modern browsers) */
  scrollbar-width: thin !important;
  scrollbar-color: rgba(0,0,0, 0.3) transparent !important;
}

/* Webkit browsers (Chrome, Edge, Safari) */
.chat-current::-webkit-scrollbar {
  width: 6px !important;
}

.chat-current::-webkit-scrollbar-track {
  background: transparent !important;
  border-radius: 3px !important;
}

.chat-current::-webkit-scrollbar-thumb {
  background: rgba(0,0,0, 0.3) !important;
  border-radius: 3px !important;
  transition: background 0.2s ease !important;
}

.chat-current::-webkit-scrollbar-thumb:hover {
  background: rgba(0,0,0, 0.5) !important;
}

/* Custom scrollbar styling for new project textarea */
#project-prompt {
  scrollbar-width: thin;
  scrollbar-color: rgba(0,0,0, 0.3) transparent;
}

#project-prompt::-webkit-scrollbar {
  width: 6px;
}

#project-prompt::-webkit-scrollbar-track {
  background: transparent;
  border-radius: 3px;
}

#project-prompt::-webkit-scrollbar-thumb {
  background: rgba(0,0,0, 0.3);
  border-radius: 3px;
}

#project-prompt::-webkit-scrollbar-thumb:hover {
  background: rgba(0,0,0, 0.5);
}

/* Pulsating border animation for agent add prompt */
@keyframes agent-add-pulse {
  0%, 100% {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 0 rgba(244, 106, 60, 0.4);
  }
  50% {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 4px rgba(244, 106, 60, 0.2);
  }
}

.agent-add-pulse {
  animation: agent-add-pulse 2s ease-in-out infinite;
  border-color: var(--color-primary) !important;
  border-width: 2px !important;
  border-style: solid !important;
  border-radius: 0.5rem !important;
}

/* Poppins font for all headings */
h1, h2, h3, h4, h5, h6 {
  font-family: 'Poppins', sans-serif;
  font-weight: 600;
}

/* User list truncation */
#list-container .menu {
  width: 100%;
  min-width: 0;
}

#list-container .menu > li {
  min-width: 0;
  width: 100%;
}

#list-container .menu > li > a {
  min-width: 0;
  width: 100%;
  max-width: 100%;
}

/* Voice recording button animation */
@keyframes voice-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4);
  }
  70% {
    box-shadow: 0 0 0 8px rgba(239, 68, 68, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
  }
}

.voice-recording {
  animation: voice-pulse 1.5s infinite;
}

.voice-recording:hover i {
  color: white !important;
}

/* Markdown/Prose styling for chat messages */
.chat-message-content > :first-child {
  margin-top: 0 !important;
}

.chat-message-content h1 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-top: 0;
  margin-bottom: 0.75rem;
  line-height: 1.3;
}

.chat-message-content h2 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-top: 1.25rem;
  margin-bottom: 0.5rem;
  line-height: 1.3;
}

.chat-message-content h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-top: 1rem;
  margin-bottom: 0.5rem;
  line-height: 1.3;
}

.chat-message-content p {
  margin-top: 0.5rem;
  margin-bottom: 0.5rem;
  line-height: 1.6;
}

.chat-message-content ul,
.chat-message-content ol {
  margin-top: 0.5rem;
  margin-bottom: 0.5rem;
  padding-left: 1.5rem;
}

.chat-message-content li {
  margin-top: 0.25rem;
  margin-bottom: 0.25rem;
  line-height: 1.5;
}

.chat-message-content li > ul,
.chat-message-content li > ol {
  margin-top: 0.25rem;
  margin-bottom: 0.25rem;
}

.chat-message-content hr {
  margin-top: 1rem;
  margin-bottom: 1rem;
  border: 0;
  border-top: 1px solid rgba(0, 0, 0, 0.1);
}

.chat-message-content code {
  background-color: rgba(0, 0, 0, 0.05);
  padding: 0.125rem 0.25rem;
  border-radius: 0.25rem;
  font-size: 0.875em;
}

.chat-message-content pre {
  background-color: rgba(0, 0, 0, 0.05);
  padding: 0.75rem;
  border-radius: 0.375rem;
  overflow-x: auto;
  margin-top: 0.5rem;
  margin-bottom: 0.5rem;
}

.chat-message-content pre code {
  background-color: transparent;
  padding: 0;
}

/* Hide empty pre/code blocks */
.chat-message-content pre:empty,
.chat-message-content pre:has(code:empty),
.chat-message-content code:empty {
  display: none;
}

.chat-message-content blockquote {
  border-left: 3px solid rgba(0, 0, 0, 0.2);
  padding-left: 1rem;
  margin-left: 0;
  margin-top: 0.5rem;
  margin-bottom: 0.5rem;
  color: rgba(0, 0, 0, 0.7);
}

/* Constrain chat messages to prevent horizontal overflow */
.chat-message {
  min-width: 0;
  max-width: 100%;
}

.chat-message > div {
  min-width: 0;
  max-width: 100%;
}

.chat-message-content {
  overflow: hidden;
  min-width: 0;
}

/* Wrap tables in a scrollable container */
.chat-message-content .table-wrapper {
  overflow-x: auto;
  margin-top: 0.5rem;
  margin-bottom: 0.5rem;
}

.chat-message-content table {
  border-collapse: collapse;
  font-size: 0.875rem;
  white-space: nowrap;
}

.chat-message-content th,
.chat-message-content td {
  border: 1px solid rgba(0, 0, 0, 0.15);
  padding: 0.5rem 0.75rem;
  text-align: left;
}

.chat-message-content th {
  background-color: rgba(0, 0, 0, 0.05);
  font-weight: 600;
}

.chat-message-content tr:nth-child(even) {
  background-color: rgba(0, 0, 0, 0.02);
}

/* Interactive Options in Chat */
.chat-interactive-options {
  padding: 0.5rem 0;
}

.chat-interactive-options .chat-option-btn {
  transition: all 0.15s ease;
}

.chat-interactive-options .chat-option-btn:not(:disabled):hover {
  transform: translateY(-1px);
}

.chat-interactive-options .chat-option-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.chat-interactive-options .chat-option-btn.btn-outline:disabled {
  border-color: rgba(0, 0, 0, 0.3) !important;
  color: rgba(0, 0, 0, 0.5) !important;
}

.chat-interactive-options .chat-option-btn.btn-primary:disabled {
  background-color: var(--color-primary) !important;
  border-color: var(--color-primary) !important;
  color: rgba(255, 255, 255, 0.7) !important;
  opacity: 1;
}

/* Build stage progress shimmer */
@keyframes build-step-shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

.build-step-active {
  background: linear-gradient(
    90deg,
    currentColor 0%,
    #fde0d8 50%,
    currentColor 100%
  );
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: build-step-shimmer 3.5s linear infinite;
}

.typing-status-shimmer {
  background: linear-gradient(
    90deg,
    #444 0%,
    #aaa 50%,
    #444 100%
  );
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: build-step-shimmer 3.5s linear infinite;
}

/* Build overlay panel */
@property --border-angle {
  syntax: "<angle>";
  initial-value: 0deg;
  inherits: false;
}

/* Dim overlay on individual containers */
.build-dimmed::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.02);
  backdrop-filter: blur(0.6px);
  border-radius: inherit;
  z-index: 10;
  pointer-events: none;
  animation: dim-fade-in 0.4s ease forwards;
}

#chat-panel.build-dimmed #chat-messages {
  overflow: hidden;
}

@keyframes dim-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

#build-panel.build-panel-active {
  position: absolute;
  right: 0;
  top: 20px;
  bottom: 20px;
  width: 50%;
  z-index: 20;
  background: white;
  border-radius: 0.5rem;
  overflow: hidden;
  animation: slide-in-right 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  box-shadow: -10px 0 30px rgba(0, 0, 0, 0.12);
}

@keyframes slide-in-right {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

/* Animated orange gradient border */
#build-panel.build-panel-active::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 0.5rem;
  padding: 2px;
  background: conic-gradient(
    from var(--border-angle),
    #e5e7eb 30%,
    #d1d5db 42%,
    #f46a3c 50%,
    #d1d5db 58%,
    #e5e7eb 70%
  );
  -webkit-mask:
    linear-gradient(#fff 0 0) content-box,
    linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  animation: border-rotate 6s linear infinite;
  z-index: 1;
  pointer-events: none;
}

@keyframes border-rotate {
  to { --border-angle: 360deg; }
}

/* Done state — stop border animation, revert to normal border */
#build-panel.build-panel-done::before {
  animation: none;
  background: #e5e7eb;
}

/* Build complete floating card */
#build-complete-card {
  position: absolute;
  bottom: 20px;
  left: 12.5%;
  width: 75%;
  z-index: 2;
  transform: translateY(100%);
  opacity: 0;
  transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.4s ease;
}

#build-complete-card.build-complete-card-visible {
  transform: translateY(0);
  opacity: 1;
}

#build-complete-card .card-body {
  box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.08);
}

/* Build failed floating card — same geometry as #build-complete-card */
#build-failed-card {
  position: absolute;
  bottom: 20px;
  left: 12.5%;
  width: 75%;
  z-index: 2;
  transform: translateY(100%);
  opacity: 0;
  transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.4s ease;
}

#build-failed-card.build-failed-card-visible {
  transform: translateY(0);
  opacity: 1;
}

#build-failed-card .card-body {
  box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.08);
}

/* Fix DaisyUI tooltip z-index issues */
.tooltip:hover {
  z-index: 50 !important;
  position: relative;
}

/* Model detail tabs - pill/boxed style */
.model-tab {
  color: rgba(0, 0, 0, 0.5);
  cursor: pointer;
}

.model-tab:hover:not(.active) {
  color: rgba(0, 0, 0, 0.7);
  background-color: rgba(0, 0, 0, 0.05);
}

.model-tab.active {
  background-color: white;
  color: rgba(0, 0, 0, 0.9);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

/* New project flow transitions */
.flow-panel {
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.25s ease-out, transform 0.25s ease-out;
}
.flow-panel.visible {
  opacity: 1;
  transform: translateY(0);
}
#cards-container {
  transition: opacity 0.2s ease-out;
}
.card-entry {
  transition: border-color 0.2s, background-color 0.2s;
}

