/* ═══════════════════════════════════════════════════════════════
   RESULT WINDOW STYLES

   Extracted from app.js - styles for the output window tabs:
   - Progress tab (timeline)
   - Report tab (markdown viewer)
   - Files tab (file browser)
   ═══════════════════════════════════════════════════════════════ */

/* ============================================
   BASE RESULT WINDOW
   ============================================ */
#result-box, #output-window .result-box {
  display: flex;
  flex-direction: column;
  background: #0a0a0a;
  border-radius: 12px;
  max-height: 90vh;
  overflow: hidden;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* ============================================
   TAB NAVIGATION
   ============================================ */
.tabs {
  display: flex;
  gap: 0;
  background: #111;
  border-bottom: 1px solid #1f1f1f;
  padding: 0 1rem;
}

#output-window .tab-btn {
  padding: 0.875rem 1.25rem;
}

#output-window .tab-btn:hover {
  color: #9ca3af;
}

#output-window .tab-btn.active {
  color: #9ca3af;
}

#output-window .tab-content {
  display: none;
  flex: 1;
  overflow: hidden;
}

#output-window .tab-content.active {
  display: flex;
  flex-direction: column;
}

/* ============================================
   PROGRESS TAB - CLEAN TIMELINE
   ============================================ */
#tab-progress {
  background: transparent;
}

.progress-logs {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  background: transparent;
}

/* Empty State */
.progress-logs .empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem 2rem;
  text-align: center;
  flex: 1;
}

.progress-logs .empty-state.hidden {
  display: none !important;
}

.empty-state .empty-icon {
  width: 64px;
  height: 64px;
  background: linear-gradient(135deg, #1a1a1a 0%, #252525 100%);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1.25rem;
  font-size: 1.75rem;
}

.empty-state .empty-title {
  font-size: 1rem;
  font-weight: 600;
  color: #e5e7eb;
  margin: 0 0 0.5rem 0;
}

.empty-state .empty-message {
  font-size: 0.8125rem;
  color: #6b7280;
  margin: 0;
  max-width: 280px;
  line-height: 1.5;
}

/* Timeline Container */
.timeline-container {
  position: relative;
  padding-left: 2rem;
}

.timeline-container::before {
  content: '';
  position: absolute;
  left: 7px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: linear-gradient(to bottom, #2a2a2a 0%, transparent 100%);
}

/* Step Group */
.step-group {
  position: relative;
  margin-bottom: 1.25rem;
  animation: fadeSlideIn 0.3s ease forwards;
}

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

/* Step Header */
.step-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
  position: relative;
}

.step-dot {
  position: absolute;
  left: -2rem;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #1a1a1a;
  border: 2px solid #3a3a3a;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
}

.step-dot.active {
  background: #D97758;
  border-color: #D97758;
  box-shadow: 0 0 0 4px rgba(217, 119, 88, 0.15);
  animation: pulse-dot 2s infinite;
}

.step-dot.success {
  background: #808080;
  border-color: #808080;
}

.step-dot.success::after {
  content: '✓';
  font-size: 9px;
  color: white;
  font-weight: bold;
}

.step-dot.error {
  background: #ef4444;
  border-color: #ef4444;
}

.step-dot.error::after {
  content: '×';
  font-size: 12px;
  color: white;
  font-weight: bold;
}

@keyframes pulse-dot {
  0%, 100% {
    box-shadow: 0 0 0 4px rgba(217, 119, 88, 0.15);
  }
  50% {
    box-shadow: 0 0 0 8px rgba(217, 119, 88, 0.08);
  }
}

.step-name {
  font-size: 0.8125rem;
  font-weight: 600;
  color: #e5e7eb;
}

.step-name.active {
  color: #e5e7eb;
}

.step-time {
  font-size: 0.6875rem;
  color: #4b5563;
  font-family: 'SF Mono', 'Monaco', monospace;
}

/* Log Lines */
.step-logs {
  padding-left: 0;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.log-line {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.375rem 0.75rem;
  background: rgba(255, 255, 255, 0.02);
  border-radius: 6px;
  font-size: 0.75rem;
  line-height: 1.5;
  transition: background 0.15s ease;
}

.log-line:hover {
  background: rgba(255, 255, 255, 0.04);
}

.log-time {
  color: #4b5563;
  font-family: 'SF Mono', 'Monaco', monospace;
  font-size: 0.6875rem;
  flex-shrink: 0;
  min-width: 70px;
}

.log-msg {
  color: #9ca3af;
  word-break: break-word;
}

.log-line.success .log-msg {
  color: #9ca3af;
}

.log-line.error .log-msg {
  color: #fca5a5;
}

.log-line.warn .log-msg {
  color: #fcd34d;
}

/* ============================================
   REPORT TAB
   ============================================ */
#tab-report {
  background: transparent;
  overflow: hidden;
}

.report-view {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.report-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  background: linear-gradient(180deg, #111 0%, #0a0a0a 100%);
  border-bottom: 1px solid #1f1f1f;
  flex-shrink: 0;
}

.report-meta {
  display: flex;
  align-items: center;
  gap: 0.875rem;
}

.report-icon {
  width: 36px;
  height: 36px;
  background: rgba(217, 119, 88, 0.1);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #D97758;
}

.report-info {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}

.report-title {
  font-size: 1rem;
  font-weight: 600;
  color: #f3f4f6;
  margin: 0;
}

.report-subtitle {
  font-size: 0.6875rem;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

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

.report-action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid #2a2a2a;
  border-radius: 8px;
  color: #9ca3af;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
}

.report-action-btn:hover {
  background: #D97758;
  border-color: #D97758;
  color: #0a0a0a;
}

/* Report Body - Markdown Content */
.report-body {
  flex: 1;
  overflow-y: auto;
  padding: 2rem;
  color: #d1d5db;
  font-size: 0.875rem;
  line-height: 1.7;
}

.report-body h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: #f3f4f6;
  margin: 2rem 0 1rem 0;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid #1f1f1f;
}

.report-body h1:first-child {
  margin-top: 0;
}

.report-body h2 {
  font-size: 1.25rem;
  font-weight: 600;
  color: #e5e7eb;
  margin: 1.5rem 0 0.75rem 0;
}

.report-body h3 {
  font-size: 1rem;
  font-weight: 600;
  color: #d1d5db;
  margin: 1.25rem 0 0.5rem 0;
}

.report-body p {
  margin: 0.75rem 0;
}

.report-body ul, .report-body ol {
  margin: 0.75rem 0;
  padding-left: 1.5rem;
}

.report-body li {
  margin: 0.375rem 0;
}

.report-body code {
  background: rgba(217, 119, 88, 0.1);
  color: #D97758;
  padding: 0.125rem 0.375rem;
  border-radius: 4px;
  font-family: 'SF Mono', 'Monaco', monospace;
  font-size: 0.8125em;
}

.report-body pre {
  background: #111;
  border: 1px solid #1f1f1f;
  border-radius: 8px;
  padding: 1rem;
  margin: 1rem 0;
  overflow-x: auto;
}

.report-body pre code {
  background: none;
  padding: 0;
  color: #9ca3af;
}

.report-body table {
  width: 100%;
  margin: 1rem 0;
  border-collapse: collapse;
  font-size: 0.8125rem;
}

.report-body th {
  background: #151515;
  color: #e5e7eb;
  padding: 0.625rem 0.75rem;
  text-align: left;
  font-weight: 600;
  border-bottom: 1px solid #2a2a2a;
}

.report-body td {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid #1a1a1a;
}

.report-body tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

/* Image Gallery in Report */
.report-images {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid #1f1f1f;
}

.report-images h3 {
  font-size: 0.875rem;
  font-weight: 600;
  color: #9ca3af;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 0 0 1rem 0;
}

.image-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
}

.image-item {
  background: #111;
  border: 1px solid #1f1f1f;
  border-radius: 10px;
  overflow: hidden;
  transition: all 0.2s ease;
}

.image-item:hover {
  border-color: #3a3a3a;
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.image-item a {
  display: block;
}

.image-item img {
  width: 100%;
  height: 140px;
  object-fit: cover;
  display: block;
}

.image-item .caption {
  padding: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.75rem;
  color: #9ca3af;
  background: #0a0a0a;
}

.image-item .caption .filename {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.image-item .download-btn {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: #6b7280;
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.15s ease;
}

.image-item .download-btn:hover {
  background: rgba(217, 119, 88, 0.1);
  color: #D97758;
}

/* ============================================
   FILES TAB
   ============================================ */
#tab-files {
  background: transparent;
}

.files-container {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.files-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  background: #111;
  border-bottom: 1px solid #1f1f1f;
  flex-shrink: 0;
}

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

.files-header h3 {
  font-size: 0.875rem;
  font-weight: 600;
  color: #e5e7eb;
  margin: 0;
}

.files-count {
  font-size: 0.75rem;
  color: #6b7280;
  background: #1a1a1a;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
}

.refresh-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid #2a2a2a;
  border-radius: 8px;
  color: #6b7280;
  cursor: pointer;
  transition: all 0.15s ease;
}

.refresh-btn:hover {
  background: rgba(217, 119, 88, 0.1);
  border-color: #D97758;
  color: #D97758;
}

.refresh-btn:active svg {
  animation: spin-refresh 0.5s ease;
}

@keyframes spin-refresh {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* Files List */
.files-list {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
}

.files-loading, .files-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem;
  text-align: center;
  color: #6b7280;
  font-size: 0.875rem;
}

/* File Groups */
.file-group {
  margin-bottom: 1.5rem;
}

.file-group:last-child {
  margin-bottom: 0;
}

.file-group-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0;
  font-size: 0.6875rem;
  font-weight: 600;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid #1a1a1a;
  margin-bottom: 0.5rem;
}

.file-group-header::before {
  content: '📁';
  font-size: 0.875rem;
}

/* File Items - Grid Layout */
.file-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.75rem;
}

.file-item {
  display: flex;
  flex-direction: column;
  background: #111;
  border: 1px solid #1f1f1f;
  border-radius: 10px;
  padding: 1rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.file-item:hover {
  background: #151515;
  border-color: #2a2a2a;
  transform: translateY(-1px);
}

.file-item-icon {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, #1a1a1a 0%, #252525 100%);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 0.75rem;
  font-size: 1.25rem;
}

.file-item-icon.image {
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.2) 0%, rgba(139, 92, 246, 0.1) 100%);
}

.file-item-icon.data {
  background: linear-gradient(135deg, rgba(34, 197, 94, 0.2) 0%, rgba(34, 197, 94, 0.1) 100%);
}

.file-item-icon.report {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.2) 0%, rgba(59, 130, 246, 0.1) 100%);
}

.file-item-name {
  font-size: 0.8125rem;
  font-weight: 500;
  color: #e5e7eb;
  margin-bottom: 0.25rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-item-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.6875rem;
  color: #6b7280;
}

.file-item-meta span {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.file-item-actions {
  display: flex;
  gap: 0.375rem;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid #1f1f1f;
}

.file-action-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  padding: 0.5rem;
  background: rgba(255, 255, 255, 0.03);
  border: none;
  border-radius: 6px;
  color: #9ca3af;
  font-size: 0.6875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.file-action-btn:hover {
  background: rgba(217, 119, 88, 0.1);
  color: #D97758;
}

/* List view alternative */
.files-list-view .file-item {
  flex-direction: row;
  align-items: center;
  padding: 0.75rem 1rem;
  gap: 0.875rem;
}

.files-list-view .file-item-icon {
  width: 36px;
  height: 36px;
  margin-bottom: 0;
  flex-shrink: 0;
}

.files-list-view .file-item-info {
  flex: 1;
  min-width: 0;
}

.files-list-view .file-item-actions {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
  flex-shrink: 0;
}

/* ============================================
   IMAGE MODAL
   ============================================ */
.image-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.9);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  animation: fadeIn 0.2s ease;
}

.image-modal-content {
  background: #0a0a0a;
  border: 1px solid #1f1f1f;
  border-radius: 12px;
  max-width: 90vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5);
}

.image-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  background: #111;
  border-bottom: 1px solid #1f1f1f;
}

.image-modal-title {
  font-size: 0.875rem;
  font-weight: 500;
  color: #e5e7eb;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.image-modal-close {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 6px;
  color: #6b7280;
  cursor: pointer;
  transition: all 0.15s ease;
}

.image-modal-close:hover {
  background: #1a1a1a;
  color: #e5e7eb;
}

.image-modal-body {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: #000;
  min-height: 0;
  overflow: auto;
}

.image-modal-body img {
  max-width: 100%;
  max-height: 70vh;
  object-fit: contain;
  border-radius: 4px;
}

.image-modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.875rem 1.25rem;
  background: #111;
  border-top: 1px solid #1f1f1f;
}

.image-modal-info {
  font-size: 0.75rem;
  color: #6b7280;
  font-family: 'SF Mono', monospace;
}

.image-modal-download {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: #D97758;
  border: none;
  border-radius: 6px;
  color: #0a0a0a;
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.image-modal-download:hover {
  background: #6bc4b0;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ============================================
   INLINE PROGRESS BAR (in chat)
   ============================================ */
.task-progress-inline {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.625rem;
  padding: 0.5rem 0.75rem;
  background: rgba(255, 255, 255, 0.02);
  border-radius: 6px;
  border: 1px solid #2a2a2a;
}

.task-progress-bar {
  flex: 1;
  height: 3px;
  background: #1a1a1a;
  border-radius: 2px;
  overflow: hidden;
  max-width: 180px;
}

.task-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #D97758 0%, #C56548 100%);
  border-radius: 2px;
  transition: width 0.3s ease;
}

.task-progress-text {
  font-size: 0.6875rem;
  color: #6b7280;
  font-family: 'SF Mono', 'Monaco', monospace;
  white-space: nowrap;
  flex: 1;
}

/* Stop button */
.stop-task-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  background: transparent;
  border: 1px solid #3a3a3a;
  border-radius: 4px;
  color: #4a4a4a;
  cursor: pointer;
  transition: all 0.15s ease;
  padding: 0;
  flex-shrink: 0;
}

.stop-task-btn:hover {
  background: rgba(184, 74, 74, 0.15);
  border-color: #b84a4a;
  color: #b84a4a;
}

.stop-task-btn svg {
  width: 10px;
  height: 10px;
}

/* ============================================
   SCROLLBAR STYLING
   ============================================ */
.progress-logs::-webkit-scrollbar,
.report-body::-webkit-scrollbar,
.files-list::-webkit-scrollbar {
  width: 6px;
}

.progress-logs::-webkit-scrollbar-track,
.report-body::-webkit-scrollbar-track,
.files-list::-webkit-scrollbar-track {
  background: transparent;
}

.progress-logs::-webkit-scrollbar-thumb,
.report-body::-webkit-scrollbar-thumb,
.files-list::-webkit-scrollbar-thumb {
  background: #2a2a2a;
  border-radius: 3px;
}

.progress-logs::-webkit-scrollbar-thumb:hover,
.report-body::-webkit-scrollbar-thumb:hover,
.files-list::-webkit-scrollbar-thumb:hover {
  background: #3a3a3a;
}

/* ============================================
   THINKING ACCORDION - Minimal Style
   ============================================ */
.thinking-accordion {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid #2a2a2a;
  border-radius: 6px;
  margin: 0.5rem 0;
  overflow: hidden;
}

.thinking-header {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s ease;
}

.thinking-header:hover {
  background: rgba(255, 255, 255, 0.02);
}

.thinking-icon {
  font-size: 0.6875rem;
  color: rgb(183, 173, 165);
  transition: transform 0.2s ease;
}

.thinking-accordion.expanded .thinking-icon {
  transform: rotate(90deg);
}

.thinking-label {
  font-size: 0.6875rem;
  color: rgb(183, 173, 165);
  font-weight: 500;
}

.thinking-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
}

.thinking-accordion.expanded .thinking-content {
  max-height: 2000px;
}

.thinking-inner {
  padding: 0 0.75rem 0.625rem 0.75rem;
  font-size: 0.75rem;
  color: #B1ADA1;
  line-height: 1.5;
  border-top: 1px solid #1f1f1f;
  padding-top: 0.5rem;
}

.thinking-inner p {
  margin: 0.25rem 0;
}
