/* ============================================
   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 - Side-by-Side Email Composer
   ============================================ */

.email-composer {
  flex: 1;
  display: grid;
  grid-template-columns: 380px 1fr;
  grid-template-rows: 1fr auto;
  height: 100%;
  min-height: 0;
  background: var(--kaptio-grey-50);
  position: relative;
  transition: grid-template-columns 0.3s ease;
}

/* Left Panel: Compose */
.email-compose-panel {
  grid-row: 1;
  grid-column: 1;
  display: flex;
  flex-direction: column;
  background: var(--kaptio-white);
  border-right: 1px solid var(--kaptio-grey-100);
  overflow-y: auto;
}

.email-compose-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--kaptio-grey-100);
  background: var(--kaptio-white);
  position: sticky;
  top: 0;
  z-index: 1;
}

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

.email-compose-fields {
  padding: 1rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* Compact Field Rows */
.email-field-row {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.email-field-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--kaptio-grey-500);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.email-field-input,
.email-field-textarea {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--kaptio-grey-100);
  border-radius: 0.375rem;
  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);
}

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

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

.email-field-textarea {
  resize: vertical;
  min-height: 80px;
  field-sizing: content; /* Auto-expand with content (modern browsers) */
  max-height: 200px;
}

/* Customize Section */
.email-customize-section {
  margin-top: 0.75rem;
  padding: 0.75rem;
  background: var(--kaptio-grey-50);
  border-radius: 0.5rem;
  border: 1px solid var(--kaptio-grey-100);
}

.email-section-header {
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--kaptio-grey-100);
}

.email-section-title {
  font-size: 0.6875rem;
  font-weight: 700;
  color: var(--kaptio-primary-600);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Field focus highlight */
.email-field-input:focus,
.email-field-textarea:focus {
  background: var(--kaptio-primary-50);
}

.email-field-row:focus-within .email-field-label {
  color: var(--kaptio-primary-600);
}

/* Character counter */
.email-field-with-counter {
  position: relative;
}

.email-char-counter {
  position: absolute;
  right: 0;
  top: 0;
  font-size: 0.625rem;
  color: var(--kaptio-grey-400);
  font-weight: 500;
}

.email-char-counter.warning {
  color: var(--kaptio-warning, #f59e0b);
}

.email-char-counter.error {
  color: var(--kaptio-error);
}

/* Reset button */
.email-reset-btn {
  padding: 0.25rem 0.5rem;
  font-size: 0.6875rem;
  color: var(--kaptio-grey-500);
  background: none;
  border: 1px solid var(--kaptio-grey-200);
  border-radius: 0.25rem;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.email-reset-btn:hover {
  background: var(--kaptio-grey-100);
  color: var(--kaptio-grey-700);
}

.email-reset-btn svg {
  width: 12px;
  height: 12px;
}

/* Collapsible panel */
.email-composer.collapsed .email-compose-panel {
  width: 0;
  min-width: 0;
  padding: 0;
  overflow: hidden;
  border-right: none;
}

.email-composer.collapsed {
  grid-template-columns: 0 1fr;
}

.email-composer.collapsed .email-compose-panel * {
  opacity: 0;
  pointer-events: none;
}

.collapse-panel-btn {
  position: absolute;
  left: 380px;
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 48px;
  background: var(--kaptio-white);
  border: 1px solid var(--kaptio-grey-200);
  border-left: none;
  border-radius: 0 0.375rem 0.375rem 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--kaptio-grey-400);
  z-index: 10;
  transition: all 0.3s ease;
}

.collapse-panel-btn:hover {
  background: var(--kaptio-grey-50);
  color: var(--kaptio-grey-600);
}

.email-composer.collapsed .collapse-panel-btn {
  left: 0;
  border-left: 1px solid var(--kaptio-grey-200);
  border-radius: 0 0.375rem 0.375rem 0;
}

.collapse-panel-btn svg {
  width: 14px;
  height: 14px;
  transition: transform 0.3s ease;
}

.email-composer.collapsed .collapse-panel-btn svg {
  transform: rotate(180deg);
}

/* Right Panel: Preview */
.email-preview-panel {
  grid-row: 1;
  grid-column: 2;
  display: flex;
  flex-direction: column;
  background: var(--kaptio-grey-50);
  min-height: 0;
}

.email-preview-header {
  padding: 0.5rem 1rem;
  background: var(--kaptio-white);
  border-bottom: 1px solid var(--kaptio-grey-100);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.email-preview-title {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--kaptio-grey-400);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.email-preview-controls {
  display: flex;
  gap: 0.25rem;
}

.preview-toggle-btn {
  padding: 0.375rem 0.5rem;
  border: 1px solid var(--kaptio-grey-200);
  background: var(--kaptio-white);
  border-radius: 0.25rem;
  cursor: pointer;
  color: var(--kaptio-grey-400);
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  transition: all 0.15s ease;
}

.preview-toggle-btn:hover {
  background: var(--kaptio-grey-50);
  color: var(--kaptio-grey-600);
}

.preview-toggle-btn.active {
  background: var(--kaptio-primary-100);
  border-color: var(--kaptio-primary-300);
  color: var(--kaptio-primary-700);
}

.preview-toggle-btn svg {
  width: 14px;
  height: 14px;
}

.email-preview-content {
  flex: 1;
  padding: 0.75rem;
  min-height: 0;
  display: flex;
  justify-content: center;
  overflow: auto;
}

.email-preview-iframe {
  width: 100%;
  max-width: 100%;
  height: 100%;
  border: none;
  border-radius: 0.5rem;
  background: #f9f5f2;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  transition: max-width 0.3s ease;
}

.email-preview-iframe.mobile-preview {
  max-width: 375px;
}

/* Footer Actions */
.email-composer-footer {
  grid-row: 2;
  grid-column: 1 / -1;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  background: var(--kaptio-white);
  border-top: 1px solid var(--kaptio-grey-100);
}

/* Legacy styles (kept for fallback/plain text mode) */
.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;
}

/* ============================================
   Quill WYSIWYG Email Editor
   ============================================ */

#emailQuillEditor {
  background: var(--kaptio-white);
  border-radius: 0.5rem;
  min-height: 200px;
}

#emailQuillEditor .ql-editor {
  font-family: 'Lexend', system-ui, -apple-system, sans-serif;
  font-size: 0.9375rem;
  font-weight: 300;
  line-height: 1.7;
  color: var(--kaptio-black);
  min-height: 180px;
  padding: 1rem;
}

#emailQuillEditor .ql-editor.ql-blank::before {
  font-style: italic;
  color: var(--kaptio-grey-300);
}

#emailQuillEditor .ql-toolbar.ql-snow {
  border: 1px solid var(--kaptio-grey-100);
  border-radius: 0.5rem 0.5rem 0 0;
  background: var(--kaptio-primary-50);
  font-family: 'Lexend', sans-serif;
}

#emailQuillEditor .ql-container.ql-snow {
  border: 1px solid var(--kaptio-grey-100);
  border-top: none;
  border-radius: 0 0 0.5rem 0.5rem;
}

/* ============================================
   Email Preview (Iframe for HTML templates)
   ============================================ */

.email-preview-container {
  border: 1px solid var(--kaptio-grey-100);
  border-radius: 0.5rem;
  overflow: hidden;
  background: #f9f5f2;
}

.email-preview-frame {
  width: 100%;
  min-height: 400px;
  border: none;
  display: block;
}

.email-preview-label {
  display: block;
  padding: 0.75rem 1rem;
  background: var(--kaptio-primary-50);
  border-bottom: 1px solid var(--kaptio-grey-100);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--kaptio-grey-500);
}

#emailQuillEditor .ql-toolbar .ql-stroke {
  stroke: var(--kaptio-primary-600);
}

#emailQuillEditor .ql-toolbar .ql-fill {
  fill: var(--kaptio-primary-600);
}

#emailQuillEditor .ql-toolbar button:hover .ql-stroke,
#emailQuillEditor .ql-toolbar button.ql-active .ql-stroke {
  stroke: var(--kaptio-primary-400);
}

#emailQuillEditor .ql-toolbar button:hover .ql-fill,
#emailQuillEditor .ql-toolbar button.ql-active .ql-fill {
  fill: var(--kaptio-primary-400);
}

/* Focus state for Quill editor */
#emailQuillEditor .ql-container.ql-snow:focus-within {
  border-color: var(--kaptio-primary-400);
  box-shadow: 0 0 0 3px var(--kaptio-primary-100);
}

.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;
  width: 0 !important;
  min-width: 0 !important;
  max-width: 0 !important;
  overflow: hidden !important;
}

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

/* Adjust grid to 2-column layout when AI is hidden */
.editor-main {
  margin-right: 0 !important;
  grid-template-columns: 280px 1fr !important;
}

/* ============================================
   Validation Card - On-brand error display
   Uses config-card pattern for consistency
   ============================================ */

/* Validation card specific styling */
.validation-card {
  max-width: 580px;
}

.validation-card .config-header {
  border-bottom: none;
  padding-bottom: 0;
}

.validation-icon-wrapper {
  width: 64px;
  height: 64px;
  background: linear-gradient(135deg, #FEF3C7 0%, #FDE68A 100%);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1.5rem auto;
}

.validation-icon {
  width: 32px;
  height: 32px;
  color: #D97706;
}

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

/* Required Information Section */
.validation-errors-section {
  background: linear-gradient(135deg, #FEF2F2 0%, #FEE2E2 100%);
  border: 1px solid #FECACA;
  border-radius: 12px;
  padding: 1.25rem;
  margin-bottom: 1.25rem;
  text-align: left;
}

.validation-errors-section h3 {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: #DC2626;
  font-size: 0.95rem;
  font-weight: 600;
  margin: 0 0 1rem 0;
}

.validation-errors-section h3 svg {
  color: #DC2626;
  flex-shrink: 0;
}

.error-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.validation-error-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.75rem;
  background: rgba(255, 255, 255, 0.6);
  border-radius: 8px;
  margin-bottom: 0.5rem;
}

.validation-error-item:last-child {
  margin-bottom: 0;
}

.error-icon-svg {
  color: #DC2626;
  flex-shrink: 0;
  margin-top: 2px;
}

.validation-error-item .error-message {
  color: var(--kaptio-black);
  font-size: 0.9rem;
  line-height: 1.5;
  flex-grow: 1;
}

/* Warnings Section */
.validation-warnings-section {
  background: linear-gradient(135deg, #FFFBEB 0%, #FEF3C7 100%);
  border: 1px solid #FDE68A;
  border-radius: 12px;
  padding: 1.25rem;
  margin-bottom: 1.25rem;
  text-align: left;
}

.validation-warnings-section h4 {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: #B45309;
  font-size: 0.9rem;
  font-weight: 600;
  margin: 0 0 0.75rem 0;
}

.validation-warnings-section h4 svg {
  color: #D97706;
  flex-shrink: 0;
}

.validation-warnings-section ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.validation-warning-item {
  padding: 0.5rem 0.75rem;
  background: rgba(255, 255, 255, 0.5);
  border-radius: 6px;
  margin-bottom: 0.5rem;
  color: #92400E;
  font-size: 0.875rem;
  line-height: 1.4;
}

.validation-warning-item:last-child {
  margin-bottom: 0;
}

/* Guidance Section */
.validation-guidance {
  background: var(--kaptio-primary-100);
  border-radius: 12px;
  padding: 1.25rem;
  margin-bottom: 1.5rem;
  text-align: left;
}

.validation-guidance h4 {
  color: var(--kaptio-primary-800);
  font-size: 0.9rem;
  font-weight: 600;
  margin: 0 0 0.75rem 0;
}

.validation-guidance ol {
  margin: 0;
  padding-left: 1.5rem;
  color: var(--kaptio-primary-600);
}

.validation-guidance li {
  padding: 0.35rem 0;
  font-size: 0.9rem;
  line-height: 1.5;
}

.validation-guidance strong {
  color: var(--kaptio-primary-800);
}

/* Badge warning state */
.badge-warning {
  background: linear-gradient(135deg, #FEF3C7 0%, #FDE68A 100%) !important;
  color: #B45309 !important;
}

/* ═══════════════════════════════════════════════════════════════════════════
   Publish Page - Combined streaming progress + success view
   ═══════════════════════════════════════════════════════════════════════════ */

.publish-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100%;
  padding: 2rem;
  background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
}

.publish-container {
  width: 100%;
  max-width: 480px;
  background: white;
  border-radius: 16px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
  padding: 1.5rem;
}

.publish-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--kaptio-primary-100);
}

.publish-title {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--kaptio-primary-800);
  margin: 0;
}

.publish-timer {
  font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--kaptio-primary-600);
  background: linear-gradient(135deg, #EEF2FF 0%, #E0E7FF 100%);
  padding: 0.4rem 0.9rem;
  border-radius: 8px;
  min-width: 72px;
  text-align: center;
  transition: all 0.3s ease;
}

.publish-timer.complete {
  background: linear-gradient(135deg, #ECFDF5 0%, #D1FAE5 100%);
  color: #059669;
}

/* Compact step layout */
.publish-steps {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.publish-step {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.75rem;
  border-radius: 8px;
  background: var(--kaptio-primary-50);
  transition: all 0.3s ease;
  transform: scale(1);
}

.publish-step.active {
  background: linear-gradient(135deg, #EEF2FF 0%, #E0E7FF 100%);
  transform: scale(1.02);
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.12);
}

.publish-step.complete {
  background: linear-gradient(135deg, #ECFDF5 0%, #D1FAE5 100%);
  transform: scale(1);
}

.publish-step.warning {
  background: linear-gradient(135deg, #FFFBEB 0%, #FEF3C7 100%);
}

.publish-step.error {
  background: linear-gradient(135deg, #FEF2F2 0%, #FEE2E2 100%);
}

/* Step icon */
.step-icon {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  position: relative;
}

.step-spinner {
  width: 22px;
  height: 22px;
  border: 2.5px solid var(--kaptio-primary-200);
  border-top-color: var(--kaptio-primary-500);
  border-radius: 50%;
  display: none;
}

.publish-step.active .step-spinner {
  display: block;
  animation: spin 0.8s linear infinite;
}

.step-check,
.step-error {
  width: 22px;
  height: 22px;
  display: none;
}

.publish-step.complete .step-check {
  display: block;
  stroke: #10B981;
  animation: checkPop 0.35s ease;
}

.publish-step.error .step-error {
  display: block;
  stroke: #EF4444;
}

.step-pending {
  width: 18px;
  height: 18px;
  border: 2px solid var(--kaptio-primary-300);
  border-radius: 50%;
  margin: 2px;
}

.publish-step.active .step-pending,
.publish-step.complete .step-pending,
.publish-step.error .step-pending {
  display: none;
}

/* Step info */
.step-info {
  flex: 1;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.step-name {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--kaptio-primary-700);
}

.publish-step.complete .step-name {
  color: #065F46;
}

.publish-step.error .step-name {
  color: #B91C1C;
}

.step-time {
  font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
  font-size: 0.8rem;
  color: #059669;
  font-weight: 500;
}

/* Result section - appears below steps */
.publish-result {
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--kaptio-primary-100);
  animation: fadeSlideUp 0.4s ease;
}

.publish-success-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  background: linear-gradient(135deg, #ECFDF5 0%, #D1FAE5 100%);
  color: #059669;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 1rem;
}

.publish-success-badge svg {
  width: 22px;
  height: 22px;
  stroke: #059669;
}

.publish-success-detail {
  text-align: center;
  color: var(--kaptio-primary-600);
  font-size: 0.9rem;
  margin: 0 0 1rem 0;
}

.publish-success-detail strong {
  color: var(--kaptio-primary-800);
}

.publish-viewer-url {
  background: var(--kaptio-primary-50);
  border-radius: 8px;
  padding: 0.75rem;
  margin-bottom: 1rem;
}

.publish-viewer-url label {
  display: block;
  font-size: 0.75rem;
  color: var(--kaptio-primary-500);
  margin-bottom: 0.35rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.url-row {
  display: flex;
  gap: 0.5rem;
  align-items: stretch;
}

.viewer-link {
  flex: 1;
  display: block;
  color: var(--kaptio-primary-600);
  font-size: 0.85rem;
  word-break: break-all;
  text-decoration: none;
  padding: 0.5rem 0.75rem;
  background: white;
  border-radius: 6px;
  border: 1px solid var(--kaptio-primary-200);
  transition: all 0.2s ease;
}

.viewer-link:hover {
  background: var(--kaptio-primary-100);
  border-color: var(--kaptio-primary-300);
}

.copy-url-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  background: white;
  border: 1px solid var(--kaptio-primary-200);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.copy-url-btn svg {
  width: 18px;
  height: 18px;
  stroke: var(--kaptio-primary-500);
}

.copy-url-btn:hover {
  background: var(--kaptio-primary-100);
  border-color: var(--kaptio-primary-300);
}

.copy-url-btn:active {
  transform: scale(0.95);
}

.copy-url-btn.copied {
  background: linear-gradient(135deg, #ECFDF5 0%, #D1FAE5 100%);
  border-color: #10B981;
}

.copy-url-btn.copied svg {
  stroke: #10B981;
  animation: checkPop 0.35s ease;
}

/* Action buttons */
.publish-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.publish-open-btn {
  flex: 1;
  justify-content: center;
}

.publish-return-btn {
  flex: 1;
  justify-content: center;
}

/* Error state */
.publish-error-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  background: linear-gradient(135deg, #FEF2F2 0%, #FEE2E2 100%);
  color: #DC2626;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 1rem;
}

.publish-error-badge svg {
  width: 22px;
  height: 22px;
  stroke: #DC2626;
}

.publish-error-detail {
  text-align: center;
  color: var(--kaptio-primary-600);
  font-size: 0.9rem;
  margin: 0 0 1rem 0;
}

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

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

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

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