/* Basic scrollbar styling */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: #1e293b; }
::-webkit-scrollbar-thumb { background: #475569; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #64748b; }

/* Default body styles */
body {
    background-color: #0f172a;
    color: #e2e8f0;
}

/* Shrink main content area when the pinned side panel is open */
main {
    transition: padding-right 300ms ease;
}

/* Tab content visibility */
.tab-content {
    display: none;
}

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

/* A simple class for hidden elements */
.hidden {
    display: none !important;
}

/* Loading Overlay Styles */
#app-loading-overlay {
    transition: opacity 0.3s ease-out;
}

/* Loading spinner animation */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.animate-spin {
    animation: spin 1s linear infinite;
}

/* Pulse animation for logo */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.animate-pulse {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* Workflow Progress Indicator */
.step-indicator {
    transition: all 0.3s ease;
}

.step-indicator.active .step-number {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: white;
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.5);
}

.step-indicator.active .step-label {
    color: #e2e8f0;
    font-weight: 600;
}

.step-indicator.completed .step-number {
    background: #10b981;
    color: white;
}

.step-indicator.completed .step-label {
    color: #10b981;
}

/* Excel Viewer Integration Styles */
#excelViewerContainer {
    margin: 16px 0;
    border: 1px solid #374151;
    border-radius: 12px;
    background: #0f172a;
    overflow: hidden;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.excel-file-detail h4 {
    color: #f1f5f9;
    margin: 0 0 8px 0;
    padding: 20px 20px 0 20px;
    font-size: 18px;
    font-weight: 700;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.help-text {
    color: #94a3b8;
    font-size: 14px;
    margin: 0 0 20px 0;
    padding: 0 20px;
    line-height: 1.5;
}

.extraction-controls {
    padding: 20px;
    border-top: 1px solid #334155;
    background: linear-gradient(135deg, #0f172a, #1e293b);
}

.extraction-controls h5 {
    color: #f1f5f9;
    margin: 0 0 16px 0;
    font-size: 16px;
    font-weight: 600;
}

.extraction-actions {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
}

.extraction-actions .btn {
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 500;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.extraction-actions .btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.extraction-actions .btn-primary {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: white;
    box-shadow: 0 4px 14px 0 rgba(99, 102, 241, 0.3);
}

.extraction-actions .btn-primary:hover:not(:disabled) {
    background: linear-gradient(135deg, #5b21b6, #7c3aed);
    box-shadow: 0 6px 20px 0 rgba(99, 102, 241, 0.4);
    transform: translateY(-2px);
}

.extraction-actions .btn-secondary {
    background: linear-gradient(135deg, #475569, #64748b);
    color: white;
    box-shadow: 0 4px 14px 0 rgba(71, 85, 105, 0.3);
}

.extraction-actions .btn-secondary:hover:not(:disabled) {
    background: linear-gradient(135deg, #334155, #475569);
    box-shadow: 0 6px 20px 0 rgba(71, 85, 105, 0.4);
    transform: translateY(-2px);
}

.extraction-results {
    background: linear-gradient(135deg, #0f172a, #1e293b);
    border: 1px solid #334155;
    border-radius: 8px;
    padding: 16px;
    box-shadow: inset 0 2px 4px 0 rgba(0, 0, 0, 0.1);
}

.extraction-results h6 {
    color: #f1f5f9;
    margin: 0 0 12px 0;
    font-size: 14px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.extraction-results pre {
    margin: 0;
    font-size: 12px;
    line-height: 1.5;
    color: #cbd5e1;
    max-height: 400px;
    overflow-y: auto;
    background: #020617;
    padding: 12px;
    border-radius: 6px;
    border: 1px solid #1e293b;
}

.error {
    color: #ef4444;
    font-style: italic;
    padding: 20px;
    text-align: center;
    background: rgba(239, 68, 68, 0.1);
    border-radius: 8px;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

/* Excel Viewer Component Styles */
.excel-viewer {
    background: #0f172a !important;
    border: 1px solid #334155 !important;
    border-radius: 8px !important;
    overflow: hidden !important;
    margin: 0 20px 20px 20px !important;
}

.sheet-tabs {
    background: linear-gradient(135deg, #1e293b, #334155) !important;
    border-bottom: 1px solid #475569 !important;
    padding: 0 !important;
    display: flex !important;
}

.sheet-tab {
    background: transparent !important;
    border: none !important;
    border-right: 1px solid #475569 !important;
    color: #94a3b8 !important;
    padding: 12px 20px !important;
    cursor: pointer !important;
    transition: all 0.3s ease !important;
    font-weight: 500 !important;
    font-size: 14px !important;
}

.sheet-tab:hover {
    background: rgba(99, 102, 241, 0.1) !important;
    color: #c7d2fe !important;
}

.sheet-tab.active {
    background: linear-gradient(135deg, #6366f1, #8b5cf6) !important;
    color: white !important;
    box-shadow: inset 0 -2px 0 0 #a855f7 !important;
}

.viewer-toolbar {
    background: linear-gradient(135deg, #1e293b, #334155) !important;
    border-bottom: 1px solid #475569 !important;
    padding: 12px 16px !important;
    display: flex !important;
    align-items: center !important;
    gap: 12px !important;
}

.toolbar-button {
    background: linear-gradient(135deg, #6366f1, #8b5cf6) !important;
    color: white !important;
    border: none !important;
    padding: 8px 16px !important;
    border-radius: 6px !important;
    font-size: 13px !important;
    font-weight: 500 !important;
    cursor: pointer !important;
    transition: all 0.3s ease !important;
}

.toolbar-button:hover {
    background: linear-gradient(135deg, #5b21b6, #7c3aed) !important;
    transform: translateY(-1px) !important;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3) !important;
}

.toolbar-button.active {
    background: linear-gradient(135deg, #059669, #10b981) !important;
}

.grid-container {
    background: #020617 !important;
    overflow: auto !important;
    max-height: 25vh !important; /* Reduced to leave room for controls below */
}

/* Workflow area - no scrolling, just container */
#workflow-area {
    min-height: 0; /* Important for flex children */
    overflow: visible !important; /* Remove scrolling from workflow area */
}

#files-grid-view {
    min-height: 0; /* Important for flex children to scroll properly */
}

/* Each step container should have its own scrolling - fill most of viewport */
#step-1-select-sheet,
#step-2-select-table,
#step-3-configure-table,
#step-4-generate-code,
#step-5-preview-save {
    max-height: calc(100vh - 450px) !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    scrollbar-width: thin; /* Firefox */
    scrollbar-color: #4f46e5 #1e293b; /* Firefox - indigo thumb, dark track */
}

/* Webkit scrollbar styling for step containers */
#step-1-select-sheet::-webkit-scrollbar,
#step-2-select-table::-webkit-scrollbar,
#step-3-configure-table::-webkit-scrollbar,
#step-4-generate-code::-webkit-scrollbar,
#step-5-preview-save::-webkit-scrollbar {
    width: 12px;
}

#step-1-select-sheet::-webkit-scrollbar-track,
#step-2-select-table::-webkit-scrollbar-track,
#step-3-configure-table::-webkit-scrollbar-track,
#step-4-generate-code::-webkit-scrollbar-track,
#step-5-preview-save::-webkit-scrollbar-track {
    background: #1e293b;
    border-radius: 6px;
}

#step-1-select-sheet::-webkit-scrollbar-thumb,
#step-2-select-table::-webkit-scrollbar-thumb,
#step-3-configure-table::-webkit-scrollbar-thumb,
#step-4-generate-code::-webkit-scrollbar-thumb,
#step-5-preview-save::-webkit-scrollbar-thumb {
    background: #4f46e5;
    border-radius: 6px;
    border: 2px solid #1e293b;
}

#step-1-select-sheet::-webkit-scrollbar-thumb:hover,
#step-2-select-table::-webkit-scrollbar-thumb:hover,
#step-3-configure-table::-webkit-scrollbar-thumb:hover,
#step-4-generate-code::-webkit-scrollbar-thumb:hover,
#step-5-preview-save::-webkit-scrollbar-thumb:hover {
    background: #6366f1;
}

/* Excel viewer should have constrained height with scrolling */
.excel-viewer {
    max-height: 70vh !important; /* Increased to accommodate sheet, selections, and constants */
    min-height: 300px !important; /* Ensure it stays usable even with constants/selections */
    overflow: hidden !important;
    display: flex !important;
    flex-direction: column !important;
}

/* Sheet container - delegate scrolling to inner grid-scroll-wrapper to avoid double scrollbars */
.sheet-container.scrollable {
    min-height: 250px !important; /* Ensure the grid stays visible */
    max-height: none !important; /* Remove max-height - inner wrapper handles this */
    overflow: visible !important; /* No scrolling - inner wrapper handles it */
    flex: 1 !important;
}

/* The inner grid scroll wrapper handles all scrolling for virtual rendering */
.grid-scroll-wrapper {
    max-height: 50vh !important; /* Height constraint for the scrollable area */
    overflow: auto !important;
}

/* Table selections list - scrollable when many tables selected */
.table-selections-list {
    max-height: 300px !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
}

/* Constant attributes list - scrollable when many attributes added */
.constant-attr-list {
    max-height: 250px !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
}

/* Table configuration container in Step 3 - scrollable when many columns */
#table-configuration {
    max-height: calc(100vh - 450px) !important; /* Leave room for header, step header, workflow progress, etc. */
    overflow-y: auto !important;
    overflow-x: hidden !important;
    scrollbar-width: thin;
    scrollbar-color: #4f46e5 #1e293b;
}

#table-configuration::-webkit-scrollbar {
    width: 10px;
}

#table-configuration::-webkit-scrollbar-track {
    background: #1e293b;
    border-radius: 5px;
}

#table-configuration::-webkit-scrollbar-thumb {
    background: #4f46e5;
    border-radius: 5px;
    border: 2px solid #1e293b;
}

#table-configuration::-webkit-scrollbar-thumb:hover {
    background: #6366f1;
}

/* Column config list in Step 3 - let it expand naturally within scrollable parent */
#column-config-list {
    max-height: none !important;
    overflow-y: visible !important;
    overflow-x: hidden !important;
}



/* Advanced options section should not expand infinitely */
#step-2-select-table .bg-slate-800.rounded-lg {
    max-height: none; /* Let it expand naturally */
}

/* Extraction controls */
#extractionControls {
    max-height: none; /* Let it expand naturally */
}

.grid-cell {
    background: #0f172a !important;
    border: 1px solid #334155 !important;
    color: #e2e8f0 !important;
    padding: 8px 12px !important;
    font-size: 13px !important;
    min-width: 80px !important;
    text-align: left !important;
    transition: all 0.2s ease !important;
}

.grid-cell:hover {
    background: #1e293b !important;
    border-color: #6366f1 !important;
}

.grid-cell.selected {
    background: rgba(99, 102, 241, 0.2) !important;
    border-color: #6366f1 !important;
    color: #c7d2fe !important;
}

.grid-cell.selecting {
    background: rgba(139, 92, 246, 0.3) !important;
    border-color: #8b5cf6 !important;
    color: #ddd6fe !important;
}

.selection-details {
    background: linear-gradient(135deg, #1e293b, #334155) !important;
    border-top: 1px solid #475569 !important;
    color: #e2e8f0 !important;
    padding: 16px !important;
}

.selection-details input,
.selection-details select {
    background: #0f172a !important;
    border: 1px solid #334155 !important;
    color: #e2e8f0 !important;
    padding: 6px 10px !important;
    border-radius: 4px !important;
    font-size: 13px !important;
}

.selection-details input:focus,
.selection-details select:focus {
    outline: none !important;
    border-color: #6366f1 !important;
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2) !important;
}

.column-type-selector {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    margin-bottom: 8px !important;
    font-size: 13px !important;
}

/* Preview Tab Styles */
.preview-loading,
.preview-error {
    text-align: center;
    padding: 40px 20px;
    color: #a0aec0;
}

.loading-spinner {
    font-size: 32px;
    margin-bottom: 15px;
    animation: spin 2s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.error-icon {
    font-size: 32px;
    margin-bottom: 15px;
}

.table-preview {
    background: #2d3748;
    border: 1px solid #4a5568;
    border-radius: 8px;
    margin-bottom: 20px;
    overflow: hidden;
}

.table-preview.error {
    border-color: #e53e3e;
    background: rgba(229, 62, 62, 0.1);
}

.table-header {
    background: #1a202c;
    padding: 15px;
    border-bottom: 1px solid #4a5568;
}

.table-header h5 {
    color: #63b3ed;
    margin: 0 0 8px 0;
    font-size: 16px;
}

.table-info {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.info-badge {
    background: #4a5568;
    color: #e2e8f0;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
}

.table-data-container {
    max-height: 400px;
    overflow: auto;
}

.preview-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.preview-table th,
.preview-table td {
    padding: 8px 12px;
    border: 1px solid #4a5568;
    text-align: left;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.preview-table th {
    background: #4a5568;
    color: #e2e8f0;
    font-weight: 600;
    position: sticky;
    top: 0;
    z-index: 10;
}

.preview-table td {
    background: #2d3748;
    color: #e2e8f0;
}

.preview-table .data-row:nth-child(even) td {
    background: #1a202c;
}

.preview-table .more-rows td {
    background: #4a5568;
    color: #a0aec0;
    font-style: italic;
    text-align: center;
}

.error-message {
    color: #fc8181;
    font-style: italic;
}
