/* CSS Tools - Main Styles */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

* {
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    margin: 0;
    padding: 40px;
    background-color: #f8f9fa;
    color: #333;
    line-height: 1.6;
}

#app {
    max-width: 1200px;
    margin: 0 auto;
}

/* Force wider layout for screenshots */
@media screen and (min-width: 1800px) {
    #app {
        max-width: 1600px !important;
        margin: 0 auto;
    }
    
    body {
        padding: 15px 20px;
        background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    }
}

/* Screenshot-optimized mode - wide layout for GitHub README */
@media screen and (min-width: 1600px) {
    body {
        padding: 15px 30px;
        background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    }
    
    #app {
        max-width: 98%;
        margin: 0 auto;
    }
    
    header {
        margin-bottom: 20px;
        padding: 15px 20px;
    }
    
    header h1 {
        font-size: 2.2em;
        margin-bottom: 8px;
    }
    
    header h2 {
        font-size: 1.3em;
        margin-bottom: 10px;
    }
    
    header p {
        font-size: 1em;
        margin-bottom: 15px;
    }
    
    .trust-indicators {
        margin-bottom: 15px;
        gap: 15px;
    }
    
    .workflow-step {
        margin-bottom: 15px;
        padding: 20px 25px;
    }
    
    .workflow-step h2 {
        font-size: 1.3em;
        margin-bottom: 15px;
    }
    
    .step-description {
        margin: 8px 0 15px 44px;
        font-size: 0.9em;
    }
    
    /* More compact file list for screenshots */
    .file-item {
        padding: 12px 15px;
        margin-bottom: 8px;
    }
    
    .file-stats {
        font-size: 0.85em;
    }
    
    /* Tighter SQL editor */
    .CodeMirror {
        height: 180px;
        font-size: 13px;
    }
    
    /* More compact results table */
    .results-table {
        font-size: 0.85em;
    }
    
    .results-table th,
    .results-table td {
        padding: 8px 6px;
    }
}

header {
    text-align: center;
    margin-bottom: 40px;
    padding: 25px;
    background: #ffffff;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

header h1 {
    margin: 0 0 10px 0;
    color: #2c3e50;
    font-size: 2.8em;
    font-weight: 700;
}

header h2 {
    margin: 0 0 15px 0;
    color: #3498db;
    font-size: 1.4em;
    font-weight: 600;
}

header p {
    margin: 0 0 20px 0;
    color: #6c757d;
    font-size: 1.1em;
}

/* Trust indicators */
.trust-indicators {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.indicator {
    background: #f8f9fa;
    border: 2px solid #e9ecef;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.9em;
    font-weight: 600;
    color: #495057;
}

.indicator:first-child {
    border-color: #28a745;
    background: #d4edda;
    color: #155724;
}

/* Enhanced loading state */
.loading-state {
    margin-top: 20px;
    padding: 20px;
    background: linear-gradient(135deg, #e3f2fd, #f3e5f5);
    border-radius: 12px;
    text-align: center;
    border: 1px solid #bbdefb;
}

.loading-icon {
    font-size: 2.5em;
    margin-bottom: 10px;
    animation: bounce 2s infinite;
}

.loading-state h3 {
    margin: 0 0 10px 0;
    color: #1976d2;
    font-size: 1.2em;
    font-weight: 600;
}

.loading-state p {
    margin: 0 0 15px 0;
    color: #424242;
    font-size: 1em;
}

.loading-benefits {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.loading-benefits .benefit {
    background: rgba(255, 255, 255, 0.8);
    padding: 8px 12px;
    border-radius: 20px;
    font-size: 0.85em;
    color: #1976d2;
    font-weight: 500;
    border: 1px solid rgba(25, 118, 210, 0.2);
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-10px); }
    60% { transform: translateY(-5px); }
}

/* Progressive Workflow Design */
.workflow-step {
    background: white;
    margin-bottom: 25px;
    padding: 30px;
    border-radius: 12px;
    border: 2px solid #e9ecef;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
    transition: all 0.3s ease;
    position: relative;
}

.workflow-step.active {
    border-color: #3498db;
    box-shadow: 0 6px 12px rgba(52, 152, 219, 0.15);
}

.workflow-step.completed {
    border-color: #27ae60;
    background: linear-gradient(135deg, #ffffff, #f8fff9);
}

.workflow-step.disabled {
    opacity: 0.6;
    pointer-events: none;
}

.workflow-step.disabled .step-number {
    background: #95a5a6;
}

.workflow-step.completed .step-number {
    background: #27ae60;
}

.workflow-step.completed .step-number::after {
    content: "✓";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 0.8em;
    font-weight: bold;
}

.step-description {
    margin: 10px 0 20px 44px;
    color: #6c757d;
    font-size: 0.95em;
    font-style: italic;
}

.hidden {
    display: none;
}

h2 {
    margin: 0 0 20px 0;
    color: #2c3e50;
    font-size: 1.5em;
    border-bottom: 2px solid #ecf0f1;
    padding-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Step numbers */
.step-number {
    background: #3498db;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    font-weight: 600;
    flex-shrink: 0;
}

/* Dropzone Customization */
.dropzone {
    border: 2px dashed #3498db;
    border-radius: 8px;
    background: #f8f9fa;
    min-height: 80px;
    padding: 15px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.dropzone .dz-message {
    text-align: center;
    margin: 0;
}

.dropzone-icon {
    font-size: 3em;
    margin-bottom: 15px;
    display: block;
}

.dropzone .dz-message strong {
    display: block;
    font-size: 1.2em;
    color: #2c3e50;
    margin-bottom: 10px;
}

.dropzone .dz-message .note {
    font-size: 0.9em;
    color: #7f8c8d;
    margin-bottom: 15px;
    display: block;
}

/* Supported formats */
.supported-formats {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

.format {
    background: #e9ecef;
    color: #495057;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.8em;
    font-weight: 500;
}

.dropzone:hover,
.dropzone.dragover {
    border-color: #2980b9;
    background: #ecf0f1;
    transform: scale(1.02);
}

/* File List */
#file-list {
    margin-top: 20px;
}

.file-item {
    display: flex;
    justify-content: space-between;
    align-items: stretch;
    padding: 15px;
    margin-bottom: 10px;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 6px;
}

.file-details {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-grow: 1;
}

.file-controls {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 10px;
    margin-left: 20px;
}

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

.file-name {
    font-weight: 500;
    color: #2c3e50;
}

.table-alias {
    color: #3498db;
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 1.1em;
    font-weight: 700;
}

.file-stats {
    font-size: 0.9em;
    color: #6c757d;
    margin-left: 5px;
}

.file-item button {
    background: #e74c3c;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9em;
}

.file-item button:hover {
    background: #c0392b;
}

/* Header controls */
.header-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 0; /* Adjusted margin */
}

.header-toggle input[type="checkbox"] {
    margin: 0;
}

.header-toggle label {
    font-size: 0.9em;
    color: #555;
}

.file-headers {
    margin-top: 0; /* Adjusted margin */
    padding: 8px 12px;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 4px;
    font-size: 0.85em;
    width: 100%; /* Take full width */
}

.file-headers strong {
    color: #495057;
}

.header-list {
    color: #6c757d;
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 0.8em;
    margin-top: 4px;
}

/* Sheet selector for Excel files */
.additional-sheets {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 0; /* Adjusted margin */
}

.additional-sheets label {
    font-size: 0.9em;
    color: #555;
}

.additional-sheets select {
    padding: 4px 8px;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    background: white;
    font-size: 0.9em;
    min-width: 120px;
}

.sheet-info {
    margin-top: 0; /* Adjusted margin */
}

.sheet-name {
    font-size: 0.9em;
    color: #6c757d;
    font-style: italic;
}

.file-actions {
    margin-top: auto; /* Adjusted margin */
}

/* SQL Section */
.sql-header {
    margin-bottom: 15px;
}

.sql-help {
    margin-top: 8px;
    padding: 8px 12px;
    background: #f8f9fa;
    border-radius: 6px;
    border-left: 3px solid #3498db;
}

.help-text {
    font-size: 0.9em;
    color: #6c757d;
    font-weight: 500;
}

/* SQL Editor */
#sql-editor {
    border: 1px solid #dee2e6;
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 15px;
}

.CodeMirror {
    height: 200px;
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 14px;
}

.query-controls {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.run-btn.primary {
    background: linear-gradient(135deg, #3498db, #2980b9);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1em;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(52, 152, 219, 0.3);
}

.run-btn.primary:hover {
    background: linear-gradient(135deg, #2980b9, #1c5985);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(52, 152, 219, 0.4);
}

#run-query:disabled {
    background: #95a5a6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.shortcut-hint {
    color: #7f8c8d;
    font-size: 0.9em;
}

/* Results Table */
.results-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
    font-size: 0.9em;
}

.results-table th {
    background: #34495e;
    color: white;
    padding: 12px 8px;
    text-align: left;
    font-weight: 500;
    border-bottom: 2px solid #2c3e50;
}

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

.results-table tr:nth-child(even) {
    background: #f8f9fa;
}

.results-table tr:hover {
    background: #e3f2fd;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    margin: 20px 0;
}

.pagination button {
    background: #3498db;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
}

.pagination button:hover:not(:disabled) {
    background: #2980b9;
}

.pagination button:disabled {
    background: #95a5a6;
    cursor: not-allowed;
}

/* Export Controls */
.export-controls {
    text-align: center;
    margin-top: 20px;
}

#export-csv {
    background: #f39c12;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1em;
    font-weight: 500;
}

#export-csv:hover {
    background: #e67e22;
}

#export-csv:disabled {
    background: #95a5a6;
    cursor: not-allowed;
}

/* Error Messages */
.error-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #e74c3c;
    color: white;
    padding: 15px 20px;
    border-radius: 6px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    z-index: 1000;
    max-width: 400px;
}

.error-message {
    background: #f8d7da;
    color: #721c24;
    padding: 12px 15px;
    border: 1px solid #f5c6cb;
    border-radius: 4px;
    margin-top: 15px;
}

/* Hide PyScript deprecation warnings */
.py-error {
    display: none !important;
}

/* Responsive Design */
@media (max-width: 768px) {
    body {
        padding: 15px;
    }
    
    #app {
        margin: 0;
    }
    
    header h1 {
        font-size: 2.2em;
    }

    header h2 {
        font-size: 1.2em;
    }

    header p {
        font-size: 1em;
    }

    .trust-indicators {
        gap: 10px;
    }

    .indicator {
        padding: 6px 12px;
        font-size: 0.8em;
    }

    .loading-benefits {
        gap: 8px;
    }

    .loading-benefits .benefit {
        padding: 6px 10px;
        font-size: 0.8em;
    }

    h2 {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .step-number {
        width: 28px;
        height: 28px;
        font-size: 0.9rem;
    }
    
    .file-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    
    .query-controls {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .run-btn.primary {
        width: 100%;
        padding: 14px 24px;
    }
    
    .results-table {
        font-size: 0.85em;
    }
    
    .results-table th,
    .results-table td {
        padding: 8px 6px;
    }

    .supported-formats {
        gap: 6px;
    }

    .sql-help {
        padding: 6px 10px;
    }

    .help-text {
        font-size: 0.85em;
    }
}

.version-badge {
    background: #f39c12;
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.8em;
    margin-left: 10px;
}

.loading-progress {
    width: 100%;
    height: 4px;
    background: #ecf0f1;
    border-radius: 2px;
    overflow: hidden;
    margin-top: 10px;
}

.loading-bar {
    height: 100%;
    background: linear-gradient(90deg, #3498db, #9b59b6);
    border-radius: 2px;
    transition: width 0.3s ease;
    width: 0%;
}

.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 15px 20px;
    border-radius: 6px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    z-index: 1000;
    max-width: 400px;
    word-wrap: break-word;
}

.notification.error {
    background-color: #e74c3c;
    color: white;
}

.notification.success {
    background-color: #27ae60;
    color: white;
}

.notification.info {
    background-color: #3498db;
    color: white;
}
