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

.scrolling-banner {
    background: rgba(0,0,0,0.8);
    color: white;
    padding: 8px 0;
    overflow: hidden;
    white-space: nowrap;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    font-size: 14px;
}

.banner-content {
    display: inline-block;
    animation: scroll-left 60s linear infinite;
}

@keyframes scroll-left {
    0% { transform: translateX(0); }
    100% { transform: translateX(-50%); }
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
    padding-top: 40px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

header {
    text-align: center;
    margin-bottom: 40px;
    color: white;
}

header h1 {
    font-size: 3rem;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

header p {
    font-size: 1.2rem;
    opacity: 0.9;
}

main {
    display: grid;
    gap: 30px;
}

section {
    background: white;
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.1);
}

section h2 {
    margin-bottom: 20px;
    color: #4a5568;
    font-size: 1.5rem;
}

/* Upload Section */
.upload-area {
    border: 3px dashed #cbd5e0;
    border-radius: 8px;
    padding: 40px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

.upload-area:hover {
    border-color: #667eea;
    background: #f7fafc;
}

.upload-area.dragover {
    border-color: #667eea;
    background: #ebf8ff;
}

#fileInput {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.upload-text p {
    font-size: 1.1rem;
    margin-bottom: 8px;
    color: #4a5568;
}

.upload-text small {
    color: #718096;
}

.file-list {
    margin-top: 20px;
}

/* Scrollable Results Container */
.results-table-container {
    max-height: 500px;
    overflow-y: auto;
    border: 1px solid #ddd;
    border-radius: 6px;
    margin: 10px 0;
}

.results-table-container table {
    width: 100%;
    border-collapse: collapse;
    margin: 0;
}

.results-table-container thead {
    position: sticky;
    top: 0;
    background: #f8f9fa;
    z-index: 10;
}

.results-table-container th {
    background: #f8f9fa;
    border-bottom: 2px solid #dee2e6;
    padding: 12px 8px;
    text-align: left;
    font-weight: 600;
    color: #495057;
}

.results-table-container td {
    padding: 8px;
    border-bottom: 1px solid #dee2e6;
    vertical-align: top;
}

.results-table-container tr:hover {
    background-color: #f8f9fa;
}

/* Inline Pagination Controls */
.pagination-controls-inline {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-right: 20px;
    padding-right: 20px;
    border-right: 1px solid #ddd;
}

.pagination-controls-inline button {
    background: #667eea;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.pagination-controls-inline button:hover:not(:disabled) {
    background: #5a6fd8;
}

.pagination-controls-inline button:disabled {
    background: #ccc;
    cursor: not-allowed;
    opacity: 0.6;
}

.file-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background: #f7fafc;
    border-radius: 6px;
    margin-bottom: 8px;
}

.file-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.file-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.delete-btn {
    background: #f8f9fa;
    color: #6c757d;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    width: 20px;
    height: 20px;
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    margin-left: 8px;
    line-height: 1;
    padding: 0;
}

.delete-btn:hover {
    background: #e74c3c;
    color: white;
    border-color: #e74c3c;
    transform: scale(1.1);
}

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

.file-status {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 500;
}

.file-status.success {
    background: #c6f6d5;
    color: #22543d;
}

.file-status.error {
    background: #fed7d7;
    color: #742a2a;
}

.file-status.processing {
    background: #fef5e7;
    color: #744210;
}

/* Query Section */
.query-controls {
    display: grid;
    gap: 15px;
}

#sqlQuery {
    width: 100%;
    min-height: 120px;
    padding: 15px;
    border: 2px solid #e2e8f0;
    border-radius: 6px;
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 14px;
    resize: vertical;
}

#sqlQuery:focus {
    outline: none;
    border-color: #667eea;
}

.query-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

button {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

button:hover {
    transform: translateY(-1px);
}

#validateBtn {
    background: #48bb78;
    color: white;
}

#validateBtn:hover {
    background: #38a169;
}

#executeBtn {
    background: #667eea;
    color: white;
}

#executeBtn:hover {
    background: #5a67d8;
}

#clearBtn {
    background: #e2e8f0;
    color: #4a5568;
}

#clearBtn:hover {
    background: #cbd5e0;
}

.query-status {
    padding: 12px;
    border-radius: 6px;
    margin-top: 15px;
    display: none;
}

.query-status.success {
    background: #c6f6d5;
    color: #22543d;
    border: 1px solid #9ae6b4;
}

.query-status.error {
    background: #fed7d7;
    color: #742a2a;
    border: 1px solid #fc8181;
}

/* Results Section */
.results-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 15px;
}

.results-info {
    color: #718096;
    font-size: 0.9rem;
}

.export-buttons {
    display: flex;
    gap: 8px;
}

.export-buttons button {
    background: #4299e1;
    color: white;
    padding: 8px 16px;
    font-size: 0.9rem;
}

.export-buttons button:hover {
    background: #3182ce;
}

.results-table-container {
    /* Fixed container width that doesn't expand */
    display: block;
    overflow-x: auto;
    overflow-y: auto;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    width: calc(100vw - 80px); /* Fixed width based on viewport, accounting for margins */
    max-width: 1200px; /* Maximum width limit */
    min-width: 600px; /* Minimum width for usability */
    height: auto;
    max-height: 500px;
    /* Smooth scrolling */
    scroll-behavior: smooth;
    /* Better scrollbar styling */
    scrollbar-width: thin;
    scrollbar-color: #cbd5e0 #f7fafc;
}

/* Webkit scrollbar styling */
.results-table-container::-webkit-scrollbar {
    height: 12px;
    width: 8px;
}

.results-table-container::-webkit-scrollbar-track {
    background: #f7fafc;
    border-radius: 4px;
}

.results-table-container::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 4px;
}

.results-table-container::-webkit-scrollbar-thumb:hover {
    background: #a0aec0;
}

#resultsTable {
    /* Table can be wider than the fixed container */
    width: max-content;
    min-width: 100%;
    border-collapse: collapse;
    table-layout: auto;
}

/* Columns that will trigger horizontal scroll */
.results-table-container th {
    min-width: 120px;
    padding: 8px 12px;
    white-space: nowrap;
    background: #f8f9fa;
    border-bottom: 2px solid #dee2e6;
    font-weight: 600;
    text-align: left;
}

.results-table-container td {
    min-width: 120px;
    padding: 8px 12px;
    white-space: nowrap;
    border-bottom: 1px solid #dee2e6;
}

#resultsTable th,
#resultsTable td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #e2e8f0;
}

#resultsTable th {
    background: #f7fafc;
    font-weight: 600;
    color: #4a5568;
    position: sticky;
    top: 0;
}

#resultsTable tr:hover {
    background: #f7fafc;
}

/* Tables Section */
.table-item {
    background: #f7fafc;
    padding: 15px;
    border-radius: 6px;
    margin-bottom: 10px;
}

.table-name {
    font-weight: 600;
    color: #4a5568;
    margin-bottom: 5px;
}

.table-info {
    font-size: 0.9rem;
    color: #718096;
}


/* Loading Overlay */
.loading {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.7);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    color: white;
    text-align: center;
}

.loading.show {
    display: flex;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255,255,255,0.3);
    border-top: 4px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 15px;
}

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

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 15px;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    .results-controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    .export-buttons {
        justify-content: center;
    }
    
    .query-buttons {
        justify-content: center;
    }
}
/* File actions with skip lines */
.file-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.skip-lines-control {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    color: #666;
    white-space: nowrap;
}

.skip-lines-control label {
    font-weight: 500;
}

.skip-lines-input {
    width: 50px;
    padding: 2px 4px;
    border: 1px solid #ddd;
    border-radius: 3px;
    text-align: center;
    font-size: 12px;
}

.delete-btn {
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 3px;
    width: 24px;
    height: 24px;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.delete-btn:hover {
    background: #c82333;
}
/* Collapsible sections */
.section-minimized {
    max-height: 60px;
    overflow: hidden;
    transition: max-height 0.3s ease;
    display: flex;
    align-items: center;
}

.section-minimized .section-content {
    display: none;
}

.section-header {
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    min-height: 60px;
    padding: 0;
    margin: 0;
    background: white;
    position: relative;
    z-index: 1;
}

.section-header h2 {
    margin: 0;
    flex: 1;
}

.section-toggle {
    font-size: 1.2em;
    color: #667eea;
    transition: transform 0.3s ease;
    margin-left: 10px;
}

.section-minimized .section-toggle {
    transform: rotate(180deg);
}

/* Override default section h2 margin when in header */
section .section-header h2 {
    margin-bottom: 0;
}

/* Add padding to section content when expanded */
.section-content {
    padding-top: 15px;
}
