/* ============================================
   Kaptio Edge Docs - Editor v2.0
   3-Panel Layout with AI Assistant
   ============================================ */

/* CSS Custom Properties - Kaptio Design Tokens */
:root {
  /* Primary Palette */
  --kaptio-primary-800: #032E36;
  --kaptio-primary-600: #034955;
  --kaptio-primary-400: #056F82;
  --kaptio-primary-300: #69A9B4;
  --kaptio-primary-200: #B4D4DA;
  --kaptio-primary-100: #E6F1F2;
  --kaptio-primary-50: #EFF5F5;
  
  /* Yellow CTA */
  --kaptio-yellow-400: #FFBC42;
  --kaptio-yellow-300: #FFD78E;
  --kaptio-yellow-200: #FFEBC6;
  
  /* Secondary */
  --kaptio-secondary-400: #DE37A4;
  
  /* Neutrals */
  --kaptio-background: #F9FAF8;
  --kaptio-white: #FFFFFF;
  --kaptio-black: #212121;
  --kaptio-grey-100: #EBEBEB;
  --kaptio-grey-200: #C3C3C3;
  --kaptio-grey-300: #878787;
  
  /* Semantic */
  --kaptio-success: #10B981;
  --kaptio-error: #C1121F;
  
  /* Shadows */
  --shadow-kaptio: 0 100px 80px rgba(0,0,0,0.07), 0 41.778px 33.422px rgba(0,0,0,0.05), 0 22.336px 17.869px rgba(0,0,0,0.04), 0 12.522px 10.017px rgba(0,0,0,0.04), 0 6.65px 5.32px rgba(0,0,0,0.03), 0 2.767px 2.214px rgba(0,0,0,0.02);
  --shadow-button: 0 1px 2px rgba(16,24,40,0.05);
  --shadow-card: 0 1px 3px rgba(0,0,0,0.1);
  
  /* Transitions */
  --transition-standard: 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============================================
   Base Styles
   ============================================ */

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

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: 'Lexend', system-ui, -apple-system, sans-serif;
  font-weight: 300;
  background-color: var(--kaptio-background);
  color: var(--kaptio-black);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  line-height: 1.5;
}

h1, h2, h3, h4, h5, h6 {
  font-weight: 700;
  color: var(--kaptio-primary-800);
  line-height: 1.2;
}

/* ============================================
   Layout Structure
   ============================================ */

.editor-layout {
  display: flex;
  flex-direction: column;
  height: 100vh;
  background: var(--kaptio-background);
}

.editor-main {
  display: grid;
  grid-template-columns: 280px 1fr 320px;
  height: calc(100vh - 60px);
  overflow: hidden;
}

.editor-main.ai-collapsed {
  grid-template-columns: 280px 1fr;
}

/* ============================================
   Header
   ============================================ */

.editor-header {
  height: 60px;
  background: var(--kaptio-white);
  border-bottom: 1px solid var(--kaptio-grey-100);
  padding: 0 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

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

.kaptio-logo {
  flex-shrink: 0;
}

.header-title-group {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}

.header-title {
  font-size: 1.125rem;
  margin: 0;
  font-weight: 700;
  color: var(--kaptio-primary-800);
}

.header-subtitle {
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--kaptio-grey-300);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.badge {
  padding: 0.375rem 0.75rem;
  border-radius: 0.375rem;
  font-size: 0.75rem;
  font-weight: 500;
}

.badge-tour {
  background: var(--kaptio-primary-100);
  color: var(--kaptio-primary-800);
}

.badge-doctype {
  background: var(--kaptio-yellow-200);
  color: var(--kaptio-black);
}

.btn-return {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.5rem 1rem;
  background: var(--kaptio-primary-400);
  color: var(--kaptio-white);
  border: none;
  border-radius: 0.375rem;
  font-family: 'Lexend', sans-serif;
  font-weight: 500;
  font-size: 0.875rem;
  cursor: pointer;
  transition: all var(--transition-standard);
}

.btn-return:hover {
  background: var(--kaptio-primary-600);
}

/* ============================================
   Left Sidebar - Context
   ============================================ */

.sidebar-left {
  background: var(--kaptio-white);
  border-right: 1px solid var(--kaptio-grey-100);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.context-cards {
  padding: 1.5rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.context-card {
  background: var(--kaptio-background);
  border: 1px solid var(--kaptio-grey-100);
  border-radius: 0.5rem;
  padding: 1rem;
}

.context-card-title {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--kaptio-grey-300);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.75rem;
}

.context-card-content {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.context-field {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}

.context-field .label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--kaptio-grey-300);
}

.context-field .value {
  font-size: 0.875rem;
  font-weight: 400;
  color: var(--kaptio-primary-800);
}

.loading-placeholder {
  font-size: 0.75rem;
  color: var(--kaptio-grey-300);
  font-style: italic;
}

/* Progress Steps */
.progress-steps {
  padding: 1.5rem;
  border-top: 1px solid var(--kaptio-grey-100);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.progress-step {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  opacity: 0.4;
  transition: opacity var(--transition-standard);
}

.progress-step.active,
.progress-step.completed {
  opacity: 1;
}

.progress-icon {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--kaptio-grey-100);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--kaptio-grey-300);
  flex-shrink: 0;
}

.progress-step.active .progress-icon {
  background: var(--kaptio-primary-400);
  color: var(--kaptio-white);
}

.progress-step.completed .progress-icon {
  background: var(--kaptio-success);
  color: var(--kaptio-white);
}

.progress-label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--kaptio-grey-300);
}

.progress-step.active .progress-label,
.progress-step.completed .progress-label {
  color: var(--kaptio-primary-800);
  font-weight: 600;
}

/* ============================================
   Center Content Area
   ============================================ */

.content-area {
  display: flex;
  flex-direction: column;
  background: var(--kaptio-white);
  overflow: hidden;
}

/* Tabs */
.tabs-header {
  display: flex;
  border-bottom: 2px solid var(--kaptio-grey-100);
  background: var(--kaptio-white);
  padding: 0 1.5rem;
  flex-shrink: 0;
}

.tab {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 1rem 1.5rem;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  font-family: 'Lexend', sans-serif;
  font-weight: 500;
  font-size: 0.875rem;
  color: var(--kaptio-grey-300);
  cursor: pointer;
  transition: all var(--transition-standard);
}

.tab:hover {
  color: var(--kaptio-primary-400);
  background: var(--kaptio-primary-50);
}

.tab.active {
  color: var(--kaptio-primary-800);
  border-bottom-color: var(--kaptio-primary-400);
}

.tab-icon {
  width: 18px;
  height: 18px;
  stroke-width: 2;
}

/* Tab Content */
.tab-content {
  flex: 1;
  display: none;
  flex-direction: column;
  overflow: hidden;
}

.tab-content.active {
  display: flex;
}

/* ============================================
   Preview & Edit Tab
   ============================================ */

.iframe-container {
  flex: 1;
  overflow: hidden;
  position: relative;
}

#documentIframe {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

.action-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  background: var(--kaptio-primary-50);
  border-top: 1px solid var(--kaptio-primary-200);
  flex-shrink: 0;
}

.action-bar-left,
.action-bar-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* Toggle Switch */
.toggle-switch {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
}

.toggle-switch input[type="checkbox"] {
  display: none;
}

.toggle-slider {
  position: relative;
  width: 44px;
  height: 24px;
  background: var(--kaptio-grey-200);
  border-radius: 12px;
  transition: background var(--transition-standard);
}

.toggle-slider::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  background: var(--kaptio-white);
  border-radius: 50%;
  transition: transform var(--transition-standard);
}

.toggle-switch input:checked + .toggle-slider {
  background: var(--kaptio-success);
}

.toggle-switch input:checked + .toggle-slider::after {
  transform: translateX(20px);
}

.toggle-label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--kaptio-primary-800);
}

.toggle-switch input:checked ~ .toggle-label {
  color: var(--kaptio-success);
}

/* ============================================
   Send Tab
   ============================================ */

.send-container {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 2rem;
  overflow-y: auto;
}

.send-form-card {
  background: var(--kaptio-white);
  border-radius: 0.75rem;
  box-shadow: var(--shadow-kaptio);
  padding: 2rem;
  max-width: 700px;
  width: 100%;
}

.send-title {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
}

.send-description {
  color: var(--kaptio-grey-300);
  font-size: 0.875rem;
  margin-bottom: 2rem;
}

/* ============================================
   Forms
   ============================================ */

.send-form {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.form-label {
  font-weight: 600;
  color: var(--kaptio-primary-800);
  font-size: 0.875rem;
}

.form-required {
  color: var(--kaptio-error);
}

.form-input,
.form-textarea {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid var(--kaptio-grey-100);
  border-radius: 0.5rem;
  font-family: 'Lexend', sans-serif;
  font-weight: 300;
  font-size: 0.875rem;
  color: var(--kaptio-black);
  background: var(--kaptio-white);
  transition: all var(--transition-standard);
}

.form-input:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--kaptio-primary-400);
  box-shadow: 0 0 0 3px var(--kaptio-primary-100);
}

.form-input::placeholder,
.form-textarea::placeholder {
  color: var(--kaptio-grey-300);
}

.form-textarea {
  resize: vertical;
  min-height: 120px;
}

.form-hint {
  font-size: 0.75rem;
  color: var(--kaptio-grey-300);
  font-style: italic;
}

.form-actions {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 1rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--kaptio-grey-100);
}

/* ============================================
   Buttons
   ============================================ */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  border-radius: 0.5rem;
  font-weight: 500;
  font-size: 0.875rem;
  cursor: pointer;
  border: none;
  transition: all var(--transition-standard);
  box-shadow: var(--shadow-button);
  font-family: 'Lexend', sans-serif;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.btn:active {
  transform: scale(0.98);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

.btn-primary {
  background: var(--kaptio-yellow-400);
  color: var(--kaptio-black);
}

.btn-primary:hover {
  background: var(--kaptio-yellow-300);
}

.btn-secondary {
  background: var(--kaptio-primary-400);
  color: var(--kaptio-white);
}

.btn-secondary:hover {
  background: var(--kaptio-primary-300);
}

.btn-success {
  background: var(--kaptio-success);
  color: var(--kaptio-white);
}

.btn-ghost {
  background: transparent;
  color: var(--kaptio-primary-400);
  box-shadow: none;
}

.btn-ghost:hover {
  background: var(--kaptio-primary-50);
}

.btn-block {
  width: 100%;
  justify-content: center;
}

.btn-icon {
  width: 18px;
  height: 18px;
  stroke-width: 2;
}

/* ============================================
   Right Sidebar - AI Assistant
   ============================================ */

.sidebar-right {
  background: var(--kaptio-white);
  border-left: 1px solid var(--kaptio-grey-100);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-right.collapsed {
  display: none;
}

.ai-header {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--kaptio-grey-100);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}

.ai-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--kaptio-primary-800);
  margin: 0;
}

.ai-icon {
  width: 20px;
  height: 20px;
  stroke-width: 2;
  color: var(--kaptio-primary-400);
}

.ai-mode-switcher {
  display: flex;
  background: var(--kaptio-background);
  border-radius: 0.375rem;
  padding: 0.25rem;
}

.ai-mode-btn {
  padding: 0.375rem 0.75rem;
  border: none;
  background: transparent;
  border-radius: 0.25rem;
  font-family: 'Lexend', sans-serif;
  font-weight: 500;
  font-size: 0.75rem;
  color: var(--kaptio-grey-300);
  cursor: pointer;
  transition: all var(--transition-standard);
}

.ai-mode-btn.active {
  background: var(--kaptio-white);
  color: var(--kaptio-primary-800);
  box-shadow: var(--shadow-card);
}

.ai-close-btn {
  padding: 0.375rem;
  background: transparent;
  border: none;
  color: var(--kaptio-grey-300);
  cursor: pointer;
  border-radius: 0.25rem;
  transition: all var(--transition-standard);
}

.ai-close-btn:hover {
  background: var(--kaptio-primary-50);
  color: var(--kaptio-primary-400);
}

.ai-close-btn svg {
  width: 20px;
  height: 20px;
  stroke-width: 2;
}

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

.ai-mode-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.ai-mode-content.hidden {
  display: none;
}

/* Ask Mode */
.ai-intro {
  padding: 1.5rem;
  flex-shrink: 0;
}

.ai-intro-text {
  font-size: 0.875rem;
  color: var(--kaptio-grey-300);
  margin-bottom: 1rem;
}

.ai-examples {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.ai-examples-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--kaptio-grey-300);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.25rem;
}

.ai-example-btn {
  text-align: left;
  padding: 0.5rem;
  background: transparent;
  border: none;
  color: var(--kaptio-primary-400);
  font-size: 0.75rem;
  font-family: 'Lexend', sans-serif;
  cursor: pointer;
  border-radius: 0.25rem;
  transition: all var(--transition-standard);
}

.ai-example-btn:hover {
  background: var(--kaptio-primary-50);
}

.ai-chat-history {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.chat-message {
  display: flex;
  gap: 0.75rem;
}

.chat-message.user {
  justify-content: flex-end;
}

.chat-bubble {
  max-width: 80%;
  padding: 0.75rem 1rem;
  border-radius: 0.75rem;
  font-size: 0.875rem;
  line-height: 1.4;
}

.chat-message.ai .chat-bubble {
  background: var(--kaptio-primary-100);
  color: var(--kaptio-primary-800);
}

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

.ai-input-container {
  display: flex;
  gap: 0.5rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--kaptio-grey-100);
  flex-shrink: 0;
}

.ai-input {
  flex: 1;
  padding: 0.75rem 1rem;
  border: 1px solid var(--kaptio-grey-100);
  border-radius: 0.5rem;
  font-family: 'Lexend', sans-serif;
  font-weight: 300;
  font-size: 0.875rem;
  color: var(--kaptio-black);
  background: var(--kaptio-white);
  transition: all var(--transition-standard);
}

.ai-input:focus {
  outline: none;
  border-color: var(--kaptio-primary-400);
  box-shadow: 0 0 0 3px var(--kaptio-primary-100);
}

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

.ai-send-btn:hover {
  background: var(--kaptio-primary-600);
}

.ai-send-btn svg {
  width: 20px;
  height: 20px;
  stroke-width: 2;
}

/* Edit Mode */
.ai-suggestions {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.ai-suggestions-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 1rem;
}

.ai-suggestion-item {
  background: var(--kaptio-background);
  border: 1px solid var(--kaptio-grey-100);
  border-radius: 0.5rem;
  padding: 0.75rem;
}

.ai-suggestion-type {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--kaptio-primary-400);
  text-transform: uppercase;
  margin-bottom: 0.5rem;
}

.ai-suggestion-text {
  font-size: 0.75rem;
  color: var(--kaptio-grey-300);
  margin-bottom: 0.5rem;
}

.ai-suggestion-change {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.75rem;
  margin-bottom: 0.5rem;
}

.ai-suggestion-original {
  color: var(--kaptio-error);
  text-decoration: line-through;
}

.ai-suggestion-new {
  color: var(--kaptio-success);
  font-weight: 500;
}

.ai-suggestion-actions {
  display: flex;
  gap: 0.5rem;
}

.ai-suggestion-btn {
  padding: 0.375rem 0.75rem;
  background: var(--kaptio-primary-400);
  color: var(--kaptio-white);
  border: none;
  border-radius: 0.25rem;
  font-family: 'Lexend', sans-serif;
  font-weight: 500;
  font-size: 0.75rem;
  cursor: pointer;
  transition: all var(--transition-standard);
}

.ai-suggestion-btn:hover {
  background: var(--kaptio-primary-600);
}

.ai-quick-actions {
  padding: 1.5rem;
  border-top: 1px solid var(--kaptio-grey-100);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.ai-section-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--kaptio-grey-300);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.ai-tone-btn {
  padding: 0.625rem 1rem;
  background: var(--kaptio-background);
  border: 1px solid var(--kaptio-grey-100);
  border-radius: 0.375rem;
  font-family: 'Lexend', sans-serif;
  font-weight: 500;
  font-size: 0.75rem;
  color: var(--kaptio-primary-800);
  cursor: pointer;
  transition: all var(--transition-standard);
  text-align: left;
}

.ai-tone-btn:hover {
  background: var(--kaptio-primary-50);
  border-color: var(--kaptio-primary-200);
}

/* AI Toggle Button (Collapsed State) */
.ai-toggle {
  position: fixed;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  background: var(--kaptio-primary-400);
  color: var(--kaptio-white);
  border: none;
  border-radius: 0.5rem 0 0 0.5rem;
  padding: 1rem 0.75rem;
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  box-shadow: -2px 2px 8px rgba(0,0,0,0.15);
  transition: all var(--transition-standard);
  z-index: 100;
}

.ai-toggle:hover {
  background: var(--kaptio-primary-600);
  padding-right: 1rem;
}

.ai-toggle-icon {
  width: 24px;
  height: 24px;
  stroke-width: 2;
}

.ai-toggle span {
  font-size: 0.75rem;
  font-weight: 600;
  writing-mode: vertical-rl;
  text-orientation: mixed;
}

/* ============================================
   Success Screen
   ============================================ */

.success-screen {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--kaptio-white);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 2rem;
  z-index: 1000;
}

.success-icon {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--kaptio-success);
  color: var(--kaptio-white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
  animation: successPulse 0.5s ease-out;
}

@keyframes successPulse {
  0% {
    transform: scale(0.8);
    opacity: 0;
  }
  50% {
    transform: scale(1.1);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.success-screen h2 {
  font-size: 1.75rem;
  margin-bottom: 0.5rem;
  color: var(--kaptio-primary-800);
}

.success-screen p {
  color: var(--kaptio-grey-300);
  font-size: 1rem;
  margin-bottom: 2rem;
  text-align: center;
  max-width: 500px;
}

.success-actions {
  display: flex;
  gap: 1rem;
}

/* ============================================
   Configuration Screen
   ============================================ */

.config-screen {
  position: fixed;
  top: 60px;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(3, 46, 54, 0.6);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 999;
  padding: 2rem;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.config-screen.hidden {
  display: none;
}

.config-card {
  background: var(--kaptio-white);
  border-radius: 0.75rem;
  box-shadow: var(--shadow-kaptio);
  padding: 2.5rem;
  max-width: 600px;
  max-height: calc(100vh - 120px);
  width: 100%;
  display: flex;
  flex-direction: column;
  animation: slideUpFade 0.4s ease-out;
  overflow: hidden;
}

@keyframes slideUpFade {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.config-header {
  text-align: center;
  margin-bottom: 2rem;
  flex-shrink: 0;
}

.config-icon {
  width: 48px;
  height: 48px;
  color: var(--kaptio-primary-400);
  margin: 0 auto 1rem;
  stroke-width: 2;
}

.config-header h2 {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
  color: var(--kaptio-primary-800);
}

.config-description {
  font-size: 0.875rem;
  color: var(--kaptio-grey-300);
}

.config-form {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  padding-right: 0.5rem;
  scroll-behavior: smooth;
}

/* Custom scrollbar for config form */
.config-form::-webkit-scrollbar {
  width: 8px;
}

.config-form::-webkit-scrollbar-track {
  background: var(--kaptio-primary-50);
  border-radius: 4px;
}

.config-form::-webkit-scrollbar-thumb {
  background: var(--kaptio-primary-300);
  border-radius: 4px;
}

.config-form::-webkit-scrollbar-thumb:hover {
  background: var(--kaptio-primary-400);
}

.form-terms {
  margin-top: 0.75rem;
  padding: 1rem;
  background: var(--kaptio-primary-50);
  border-left: 3px solid var(--kaptio-primary-400);
  border-radius: 0.375rem;
  font-size: 0.75rem;
  line-height: 1.5;
  color: var(--kaptio-primary-800);
}

.checkbox-label {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  cursor: pointer;
}

.form-checkbox {
  width: 18px;
  height: 18px;
  margin-top: 0.125rem;
  cursor: pointer;
  accent-color: var(--kaptio-primary-400);
}

.checkbox-text {
  font-weight: 500;
  color: var(--kaptio-primary-800);
  font-size: 0.875rem;
}

.config-actions {
  margin-top: 1rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--kaptio-grey-100);
  flex-shrink: 0;
}

.btn-large {
  padding: 1rem 2rem;
  font-size: 1rem;
  width: 100%;
  justify-content: center;
}

/* ============================================
   Messages
   ============================================ */

.message-container {
  position: fixed;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10000;
  max-width: 600px;
  width: 90%;
}

.message {
  padding: 1rem 1.5rem;
  border-radius: 0.5rem;
  font-weight: 500;
  box-shadow: var(--shadow-kaptio);
  animation: slideDown 0.3s ease-out;
}

.message-error {
  background: #FEE2E2;
  color: var(--kaptio-error);
  border-left: 4px solid var(--kaptio-error);
}

.message-success {
  background: #D1FAE5;
  color: var(--kaptio-success);
  border-left: 4px solid var(--kaptio-success);
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ============================================
   Performance Banner
   ============================================ */

.performance-banner {
  position: fixed;
  top: 60px; /* Below header */
  left: 0;
  right: 0;
  z-index: 9999;
  transform: translateY(-100%);
  opacity: 0;
  transition: transform 0.3s ease-out, opacity 0.3s ease-out;
}

.performance-banner:not(.hidden) {
  transform: translateY(0);
  opacity: 1;
}

.performance-banner.fade-out {
  transform: translateY(-20px);
  opacity: 0;
  transition: transform 0.5s ease-in, opacity 0.5s ease-in;
}

.performance-banner-content {
  background: #D1FAE5; /* Light green */
  border-bottom: 2px solid var(--kaptio-success);
  padding: 0.875rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.performance-main {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}

.performance-icon {
  font-size: 1.5rem;
  line-height: 1;
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.8;
    transform: scale(1.1);
  }
}

.performance-time {
  font-size: 0.9375rem;
  color: var(--kaptio-primary-800);
  font-weight: 400;
}

.performance-time strong {
  font-weight: 700;
  color: var(--kaptio-success);
}

.performance-details {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  flex: 1;
  flex-wrap: wrap;
}

.performance-stat {
  font-size: 0.8125rem;
  color: var(--kaptio-primary-600);
  font-weight: 500;
}

.performance-separator {
  color: var(--kaptio-grey-300);
  font-weight: 300;
}

.performance-close {
  background: transparent;
  border: none;
  color: var(--kaptio-primary-600);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  width: 1.5rem;
  height: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: all var(--transition-standard);
  flex-shrink: 0;
}

.performance-close:hover {
  background: rgba(16, 185, 129, 0.1);
  color: var(--kaptio-success);
}

.performance-close:active {
  transform: scale(0.95);
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .performance-banner-content {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
  }
  
  .performance-details {
    flex-wrap: wrap;
  }
  
  .performance-close {
    position: absolute;
    top: 0.75rem;
    right: 1rem;
  }
}

/* ============================================
   Loading States
   ============================================ */

.loading-spinner {
  display: inline-block;
  width: 24px;
  height: 24px;
  border: 3px solid var(--kaptio-primary-100);
  border-top-color: var(--kaptio-primary-400);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.typing-indicator {
  display: flex;
  gap: 0.25rem;
  padding: 0.75rem 1rem;
}

.typing-dot {
  width: 8px;
  height: 8px;
  background: var(--kaptio-primary-400);
  border-radius: 50%;
  animation: typingBounce 1.4s infinite;
}

.typing-dot:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typingBounce {
  0%, 60%, 100% {
    transform: translateY(0);
  }
  30% {
    transform: translateY(-8px);
  }
}

/* ============================================
   Enhanced Loading Timeline
   ============================================ */

.loading-card {
  max-width: 600px;
  margin: 0 auto;
}

.loading-timeline {
  margin: 2rem 0;
  padding: 0 1rem;
}

.timeline-phase {
  position: relative;
  padding-left: 3rem;
  padding-bottom: 1.5rem;
  transition: all var(--transition-standard);
}

.timeline-phase:not(:last-child)::before {
  content: '';
  position: absolute;
  left: 1rem;
  top: 2.5rem;
  bottom: 0;
  width: 2px;
  background: var(--kaptio-grey-100);
  transition: background var(--transition-standard);
}

.timeline-phase.active:not(:last-child)::before {
  background: var(--kaptio-primary-300);
}

.timeline-phase.completed:not(:last-child)::before {
  background: var(--kaptio-success);
}

.timeline-phase-header {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
}

.timeline-icon {
  position: absolute;
  left: 0;
  top: 0;
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--kaptio-white);
  border-radius: 50%;
  border: 2px solid var(--kaptio-grey-100);
  transition: all var(--transition-standard);
  z-index: 1;
}

.timeline-phase.active .timeline-icon {
  border-color: var(--kaptio-primary-400);
  background: var(--kaptio-primary-50);
}

.timeline-phase.completed .timeline-icon {
  border-color: var(--kaptio-success);
  background: var(--kaptio-success);
}

.timeline-phase.completed .timeline-icon::after {
  content: '✓';
  color: var(--kaptio-white);
  font-size: 1rem;
  font-weight: 700;
  animation: checkmarkPop 0.3s ease-out;
}

@keyframes checkmarkPop {
  0% {
    transform: scale(0);
  }
  50% {
    transform: scale(1.2);
  }
  100% {
    transform: scale(1);
  }
}

.timeline-dot {
  width: 8px;
  height: 8px;
  background: var(--kaptio-grey-200);
  border-radius: 50%;
  transition: all var(--transition-standard);
}

.timeline-phase.active .timeline-dot {
  background: var(--kaptio-primary-400);
}

.loading-spinner-small {
  width: 14px;
  height: 14px;
  border: 2px solid var(--kaptio-primary-100);
  border-top-color: var(--kaptio-primary-400);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.timeline-phase.completed .loading-spinner-small {
  display: none;
}

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

.timeline-phase-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--kaptio-primary-800);
  margin: 0 0 0.25rem 0;
  transition: color var(--transition-standard);
}

.timeline-phase.pending .timeline-phase-title {
  color: var(--kaptio-grey-300);
}

.timeline-phase.completed .timeline-phase-title {
  color: var(--kaptio-success);
}

.timeline-phase-description {
  font-size: 0.8rem;
  color: var(--kaptio-grey-300);
  margin: 0;
  transition: color var(--transition-standard);
}

.timeline-phase.active .timeline-phase-description {
  color: var(--kaptio-primary-600);
}

/* Substeps (for query details) */
.timeline-substeps {
  margin-top: 0.75rem;
  padding-left: 0;
  max-height: 200px;
  overflow-y: auto;
  overflow-x: hidden;
}

.timeline-substep {
  font-size: 0.75rem;
  padding: 0.5rem 0.75rem;
  margin-bottom: 0.5rem;
  background: var(--kaptio-primary-50);
  border-left: 2px solid var(--kaptio-primary-300);
  border-radius: 0 4px 4px 0;
  color: var(--kaptio-primary-800);
  animation: slideInLeft 0.3s ease-out;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.timeline-substep.cached {
  background: var(--kaptio-background);
  border-left-color: var(--kaptio-grey-200);
}

@keyframes slideInLeft {
  from {
    opacity: 0;
    transform: translateX(-10px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.substep-icon {
  flex-shrink: 0;
  font-size: 0.85rem;
}

.substep-text {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.substep-badge {
  flex-shrink: 0;
  padding: 0.125rem 0.375rem;
  background: var(--kaptio-success);
  color: var(--kaptio-white);
  font-size: 0.65rem;
  font-weight: 600;
  border-radius: 3px;
  text-transform: uppercase;
}

.substep-badge.cached {
  background: var(--kaptio-grey-300);
}

/* Loading Stats Footer */
.loading-stats {
  display: flex;
  justify-content: space-around;
  padding: 1.5rem 1rem 0.5rem;
  margin-top: 1.5rem;
  border-top: 1px solid var(--kaptio-grey-100);
  gap: 1rem;
}

.loading-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
}

.stat-label {
  font-size: 0.7rem;
  color: var(--kaptio-grey-300);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 500;
}

.stat-value {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--kaptio-primary-600);
  font-variant-numeric: tabular-nums;
}

/* Smooth transitions for phase states */
.timeline-phase.pending {
  opacity: 0.6;
}

.timeline-phase.active {
  opacity: 1;
}

.timeline-phase.completed {
  opacity: 1;
}

/* ============================================
   Responsive Design
   ============================================ */

@media (max-width: 1200px) {
  .editor-main {
    grid-template-columns: 280px 1fr;
  }
  
  .sidebar-right {
    position: fixed;
    right: 0;
    top: 60px;
    height: calc(100vh - 60px);
    z-index: 1000;
    box-shadow: -4px 0 12px rgba(0,0,0,0.15);
  }
  
  .ai-toggle {
    display: flex;
  }
}

@media (max-width: 768px) {
  .editor-main {
    grid-template-columns: 1fr;
  }
  
  .sidebar-left {
    position: fixed;
    left: 0;
    top: 60px;
    height: calc(100vh - 60px);
    width: 280px;
    z-index: 999;
    transform: translateX(-100%);
    transition: transform var(--transition-standard);
  }
  
  .sidebar-left.open {
    transform: translateX(0);
  }
  
  .header-right .badge {
    display: none;
  }
}

/* ============================================
   Utilities
   ============================================ */

.hidden {
  display: none !important;
}

.text-center {
  text-align: center;
}

.text-muted {
  color: var(--kaptio-grey-300);
}

/* ============================================
   AI Assistant - Hidden
   ============================================ */

/* Hide AI Assistant Panel */
#aiPanel,
.sidebar-right {
  display: none !important;
}

/* Hide AI Toggle Button */
#aiToggle,
.ai-toggle {
  display: none !important;
}

/* Adjust main content area to full width when AI is hidden */
.editor-main {
  margin-right: 0 !important;
}
