/* Root variables for consistent theming */
:root {
    --primary-color: #4F46E5;
    --primary-hover: #4338CA;
    --sidebar-width: 16rem;
    --header-height: 4rem;
    --filter-bg: #F9FAFB;
    --table-border: #E5E7EB;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --border-radius: 0.5rem;
    --spacing-1: 0.25rem;
    --spacing-2: 0.5rem;
    --spacing-3: 0.75rem;
    --spacing-4: 1rem;
    --spacing-6: 1.5rem;
}

/* Layout classes */
.view-container {
    max-width: 100%;
    padding: var(--spacing-6);
}

/* Navigation styling */
#sidebar {
    width: var(--sidebar-width);
    min-height: 100vh;
}

.nav-item {
    transition: all 0.2s ease-in-out;
    border-left: 3px solid transparent;
}

.nav-item:hover {
    border-left-color: var(--primary-color);
}

.nav-item.active {
    background-color: #374151;
    border-left-color: var(--primary-color);
    color: white;
}

/* Header styling */
#header {
    height: var(--header-height);
    display: flex;
    align-items: center;
}

/* Filter section styling */
.filter-section {
    background: var(--filter-bg);
    padding: var(--spacing-4);
    border-radius: var(--border-radius);
    margin-bottom: var(--spacing-6);
    border: 1px solid var(--table-border);
}

.filter-section h4 {
    font-size: 0.875rem;
    font-weight: 500;
    color: #374151;
    margin-bottom: var(--spacing-3);
}

.filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: var(--spacing-4);
}

.filter-input,
.filter-select {
    width: 100%;
    padding: var(--spacing-2) var(--spacing-3);
    border: 1px solid var(--table-border);
    border-radius: calc(var(--border-radius) - 2px);
    box-shadow: var(--shadow-sm);
    font-size: 0.875rem;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.filter-input:focus,
.filter-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.filter-label {
    display: block;
    font-size: 0.75rem;
    font-weight: 500;
    color: #6B7280;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: var(--spacing-1);
}

/* Date range filter styling */
.date-range-filter {
    grid-column: span 2;
}

.date-range-filter .date-range-inputs {
    display: flex;
    gap: var(--spacing-3);
    align-items: center;
}

.date-range-filter .date-input-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    gap: var(--spacing-2);
}

.date-range-filter .date-inline-label {
    font-size: 0.875rem;
    color: #6B7280;
    text-transform: none;
    letter-spacing: normal;
    white-space: nowrap;
    font-weight: 500;
    min-width: 40px;
}

.date-range-filter .filter-input {
    flex: 1;
}

/* Responsive adjustment for date range filter */
@media (max-width: 768px) {
    .date-range-filter {
        grid-column: span 1;
    }
}

/* Data table styling */
.data-table {
    background: white;
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--table-border);
}

.data-table table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th {
    background-color: #F9FAFB;
    padding: var(--spacing-3) var(--spacing-4);
    text-align: left;
    font-size: 0.75rem;
    font-weight: 500;
    color: #374151;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--table-border);
}

.data-table td {
    padding: var(--spacing-4);
    border-bottom: 1px solid var(--table-border);
    font-size: 0.875rem;
    color: #374151;
}

.data-table tr:hover {
    background-color: #F9FAFB;
}

.data-table tr:last-child td {
    border-bottom: none;
}

/* Button styling */
.btn-primary {
    background: var(--primary-color);
    color: white;
    padding: var(--spacing-2) var(--spacing-4);
    border-radius: calc(var(--border-radius) - 2px);
    border: none;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.15s ease-in-out;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

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

.btn-secondary {
    background: white;
    color: var(--primary-color);
    border: 1px solid var(--primary-color);
    padding: var(--spacing-2) var(--spacing-4);
    border-radius: calc(var(--border-radius) - 2px);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease-in-out;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

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

.btn-danger {
    background: #DC2626;
    color: white;
    padding: var(--spacing-2) var(--spacing-4);
    border-radius: calc(var(--border-radius) - 2px);
    border: none;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.15s ease-in-out;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-danger:hover {
    background: #B91C1C;
}

/* Modal styling */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10010;
}

.modal-content {
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    padding: var(--spacing-6);
    border-bottom: 1px solid var(--table-border);
    display: flex;
    align-items: center;
    justify-content: between;
}

.modal-header h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: #111827;
    flex: 1;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #6B7280;
    cursor: pointer;
    padding: var(--spacing-1);
}

.modal-close:hover {
    color: #374151;
}

.modal-body {
    padding: var(--spacing-6);
}

.modal-footer {
    padding: var(--spacing-4) var(--spacing-6);
    border-top: 1px solid var(--table-border);
    display: flex;
    justify-content: flex-end;
    gap: var(--spacing-3);
}

/* Status indicators */
.status-indicator {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.status-completed {
    background-color: #D1FAE5;
    color: #065F46;
}

.status-indexing {
    background-color: #FEF3C7;
    color: #92400E;
}

.status-pending {
    background-color: #E0E7FF;
    color: #3730A3;
}

.status-failed {
    background-color: #FEE2E2;
    color: #991B1B;
}

/* Utility classes */
.hidden {
    display: none !important;
}

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

.mt-2 {
    margin-top: var(--spacing-2);
}

.mt-4 {
    margin-top: var(--spacing-4);
}

.mb-2 {
    margin-bottom: var(--spacing-2);
}

.mb-4 {
    margin-bottom: var(--spacing-4);
}

.p-4 {
    padding: var(--spacing-4);
}

.px-4 {
    padding-left: var(--spacing-4);
    padding-right: var(--spacing-4);
}

.py-2 {
    padding-top: var(--spacing-2);
    padding-bottom: var(--spacing-2);
}

/* Responsive design */
@media (max-width: 768px) {
    #sidebar {
        width: 0;
        overflow: hidden;
        transition: width 0.3s ease-in-out;
    }

    #sidebar.mobile-open {
        width: var(--sidebar-width);
    }

    .filter-grid {
        grid-template-columns: 1fr;
    }

    .modal-content {
        width: 95%;
        margin: var(--spacing-4);
    }
}

/* Animation for smooth transitions */
.fade-in {
    animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Loading spinner */
.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(79, 70, 229, 0.3);
    border-radius: 50%;
    border-top-color: var(--primary-color);
    animation: spin 1s ease-in-out infinite;
}

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

/* ============================================
   Workflow Execution Animations
   ============================================ */

/* Marching stripes animation for running workflow blocks */
@keyframes border-march {
  0% {
    background-position: 0% 0%;
  }
  100% {
    background-position: 200% 0%;
  }
}

@keyframes pulse-glow {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.4);
  }
  50% {
    box-shadow: 0 0 0 10px rgba(59, 130, 246, 0);
  }
}

/* Running block state */
.workflow-block.block-running .block-content {
  position: relative;
  animation: pulse-glow 2s ease-in-out infinite;
}

.workflow-block.block-running .block-content::before {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 0.5rem;
  padding: 4px;
  background: repeating-linear-gradient(
    90deg,
    #06b6d4 0%,
    #3b82f6 12.5%,
    #8b5cf6 25%,
    #ec4899 37.5%,
    #06b6d4 50%
  );
  background-size: 200% 100%;
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  animation: border-march 3s linear infinite;
  z-index: -1;
  pointer-events: none;
}

/* Pending block state (queued for execution) */
.workflow-block.block-pending .block-content {
  border-color: #f59e0b !important;
  background-color: rgba(251, 191, 36, 0.1) !important;
}

/* Completed block state */
.workflow-block.block-completed .block-content {
  border-color: #10b981 !important;
  background-color: rgba(16, 185, 129, 0.1) !important;
}

/* Failed block state */
.workflow-block.block-failed .block-content {
  border-color: #ef4444 !important;
  background-color: rgba(239, 68, 68, 0.1) !important;
}

/* Processed block state (after execution completes) */
.workflow-block.block-processed .block-content {
  border-color: #06b6d4 !important;
  border-width: 3px !important;
  background-color: #cffafe !important; /* Solid cyan-100 - no transparency */
}

.workflow-block.block-processed .block-content::after {
  content: '✓';
  position: absolute;
  top: 8px;
  right: 8px;
  font-size: 14px;
  color: #06b6d4;
  font-weight: bold;
}

/* Workflow canvas layering:
   - Edges (SVG): z-index 1
   - Nodes (canvas-content): z-index 2
*/
#connections-svg {
  z-index: 1;
}

#canvas-content {
  z-index: 2;
}


/* Edge/Connection running state */
path[data-connection-id].edge-running {
  stroke: #3b82f6 !important;
  stroke-width: 3 !important;
  stroke-dasharray: 8 4;
  stroke-dashoffset: 0;
  animation: edge-dash-flow 0.5s linear infinite;
  /* Note: avoid filter/transform/opacity animations - they create new stacking contexts */
}

/* Bucket edges in running state - more visible */
path[data-connection-id].edge-running.bucket-edge {
  stroke: #60a5fa !important; /* Blue-400 for bucket edges - more visible during execution */
}

/* Edge/Connection processed state */
path[data-connection-id].edge-processed {
  stroke: #67e8f9 !important; /* Lighter cyan instead of opacity - avoids stacking context issues */
  stroke-width: 2.5 !important;
  stroke-dasharray: none !important;
}

/* Bucket edges in processed state - slightly more visible than before */
path[data-connection-id].edge-processed.bucket-edge {
  stroke: #7dd3fc !important; /* Sky-300 for bucket edges - more visible after execution */
}

/* Filter edges in running state - teal-blue blend with animation */
path[data-connection-id].edge-running.filter-edge {
  stroke: #0891b2 !important; /* Cyan-600 - teal-blue blend for filter edges during execution */
}

/* Filter edges in processed state - light teal */
path[data-connection-id].edge-processed.filter-edge {
  stroke: #5eead4 !important; /* Teal-300 for filter edges after execution */
  stroke-width: 2.5 !important;
}

/* Edge pulse animation - removed, was causing stacking context issues */
@keyframes edge-pulse {
  0%, 100% {
    stroke-width: 3;
  }
  50% {
    stroke-width: 3.5;
  }
}

/* Edge dash flow animation - dashes moving along the path */
@keyframes edge-dash-flow {
  to {
    stroke-dashoffset: -12;
  }
}

/* Add a small spinner icon for running state - matches panel spinner style */
.workflow-block.block-running .block-content::after {
  content: '';
  position: absolute;
  top: 8px;
  right: 8px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid transparent;
  border-bottom-color: #3b82f6;
  animation: spin 1s linear infinite;
}

/* Bucket writing animation (data flowing IN) */
.workflow-block.bucket-writing .block-content {
  position: relative;
  animation: pulse-glow 2s ease-in-out infinite;
}

.workflow-block.bucket-writing .block-content::before {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 0.5rem;
  padding: 4px;
  background: repeating-linear-gradient(
    90deg,
    #10b981 0%,
    #14b8a6 25%,
    #06b6d4 50%,
    #10b981 75%,
    #10b981 100%
  );
  background-size: 200% 100%;
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  animation: border-march 2s linear infinite;
  z-index: 1;
}

.workflow-block.bucket-writing::after {
  content: '';
  position: absolute;
  top: 8px;
  right: 8px;
  width: 20px;
  height: 20px;
  z-index: 100;
  pointer-events: none;
  animation: bucketPulseIn 1.2s ease-in-out infinite;
  filter: drop-shadow(0 0 4px rgba(16, 185, 129, 0.5));
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="%2310b981" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 15V3"/><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><path d="m7 10 5 5 5-5"/></svg>');
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
}

/* Bucket reading animation (data flowing OUT) */
.workflow-block.bucket-reading .block-content {
  position: relative;
  animation: pulse-glow 2s ease-in-out infinite;
}

.workflow-block.bucket-reading .block-content::before {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 0.5rem;
  padding: 4px;
  background: repeating-linear-gradient(
    90deg,
    #3b82f6 0%,
    #8b5cf6 25%,
    #ec4899 50%,
    #3b82f6 75%,
    #3b82f6 100%
  );
  background-size: 200% 100%;
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  animation: border-march 2s linear infinite;
  z-index: 1;
}

.workflow-block.bucket-reading::after {
  content: '';
  position: absolute;
  top: 8px;
  right: 8px;
  width: 20px;
  height: 20px;
  z-index: 100;
  pointer-events: none;
  animation: bucketPulseOut 1.2s ease-in-out infinite;
  filter: drop-shadow(0 0 4px rgba(59, 130, 246, 0.5));
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="%233b82f6" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 3v12"/><path d="m17 8-5-5-5 5"/><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/></svg>');
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
}

@keyframes bucketPulseIn {
  0%, 100% {
    opacity: 0.3;
    transform: translateY(-2px);
  }
  50% {
    opacity: 1;
    transform: translateY(2px);
  }
}

@keyframes bucketPulseOut {
  0%, 100% {
    opacity: 0.3;
    transform: translateY(2px);
  }
  50% {
    opacity: 1;
    transform: translateY(-2px);
  }
}

/* Fade in animation for step completions */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.step-log-entry {
  animation: fadeInUp 0.3s ease-out;
}

/* Progress bar animation */
@keyframes progress-indeterminate {
  0% {
    left: -35%;
    right: 100%;
  }
  60% {
    left: 100%;
    right: -90%;
  }
  100% {
    left: 100%;
    right: -90%;
  }
}

.progress-indeterminate {
  position: relative;
  overflow: hidden;
}

.progress-indeterminate::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  background-color: #06b6d4;
  animation: progress-indeterminate 2s ease-in-out infinite;
}