* {
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    margin: 0;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

.container {
    width: 100%;
    max-width: 800px; /* Wider for better editor experience */
    background: #fff;
    padding: 30px;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    text-align: center;
    /* Use min-height instead of max-height to allow growing */
    min-height: 50vh; 
    max-height: 95vh;
    display: flex;
    flex-direction: column;
    overflow: hidden; /* clean edges */
}

.header {
    margin-bottom: 30px;
}

h1 {
    margin: 0 0 10px 0;
    color: #333;
    font-size: 28px;
    font-weight: 600;
}

.subtitle {
    color: #666;
    font-size: 14px;
    margin: 0;
}

/* Message Container */
.message-container {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 14px;
    animation: slideDown 0.3s ease-out;
}

.message-success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.message-error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

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

/* Form Groups */
.form-group {
    margin-bottom: 24px;
    text-align: left;
}

.form-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #333;
    font-size: 14px;
}

.section-description {
    color: #666;
    font-size: 14px;
    margin-bottom: 20px;
    line-height: 1.5;
    text-align: left;
}

/* File Input */
.file-input-wrapper {
    margin-bottom: 24px;
}

.file-label {
    display: block;
    padding: 40px 20px;
    border: 2px dashed #ddd;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    background-color: #fafafa;
}

.file-label:hover {
    border-color: #667eea;
    background-color: #f0f0ff;
}

.file-label.dragover {
    border-color: #667eea;
    background-color: #f0f0ff;
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.15);
}

.file-label input[type="file"] {
    display: none;
}

.upload-icon {
    width: 48px;
    height: 48px;
    color: #667eea;
    margin: 0 auto 16px;
    display: block;
}

.file-name {
    display: block;
    color: #666;
    font-size: 14px;
    transition: color 0.3s ease;
}

.file-name.has-file {
    color: #667eea;
    font-weight: 500;
}

/* Buttons */
.button-group {
    margin-bottom: 24px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    min-width: 180px;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-primary {
    background-color: #667eea;
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background-color: #5568d3;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background-color: #6c757d;
    color: white;
    padding: 8px 16px;
    font-size: 14px;
    min-width: auto;
}

.btn-secondary:hover:not(:disabled) {
    background-color: #5a6268;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(108, 117, 125, 0.3);
}

.btn-success {
    background-color: #28a745;
    color: white;
}

.btn-success:hover {
    background-color: #218838;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.4);
}

.download-icon {
    width: 20px;
    height: 20px;
}

/* Loading Spinner */
.btn-loader {
    display: flex;
    align-items: center;
    gap: 8px;
}

.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Progress Steps - Compact */
.progress-container {
    margin: 8px 0;
    padding: 0;
    flex: 0 0 auto;
}

.progress-steps {
    display: flex;
    justify-content: space-between;
    position: relative;
    padding: 0 30px;
    max-width: 400px; /* Reduced max-width for tighter layout */
    margin: 0 auto;
}

.progress-steps::before {
    content: '';
    position: absolute;
    top: 19px; /* Centered with 40px icons (40/2 - 2/2 = 19) */
    left: 40px;
    right: 40px;
    height: 2px;
    background-color: #e0e0e0;
    z-index: 0;
}

.step {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    z-index: 1;
    flex: 1;
}

.step-icon {
    width: 40px;
    height: 40px;
    font-size: 14px;
    margin-bottom: 8px;
    border-radius: 50%;
    background-color: #e0e0e0;
    color: #999;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.step.active .step-icon {
    background-color: #667eea;
    color: white;
    animation: pulse 2s infinite;
}

#step-complete.active .step-icon {
    background-color: #28a745;
    animation: none;
}

.step.completed .step-icon {
    background-color: #6c757d;
    color: white;
}

.progress-steps .step:last-child.completed .step-icon {
    background-color: #28a745;
}

.step.completed .step-icon::after {
    content: '✓';
    font-size: 16px;
}

.step-label {
    font-size: 12px;
    color: #999;
    transition: color 0.3s ease;
    font-weight: 500;
}

.step.active .step-label {
    color: #667eea;
    font-weight: 500;
}

#step-complete.active .step-label {
    color: #28a745;
}

.step.completed .step-label {
    color: #6c757d;
}

.progress-steps .step:last-child.completed .step-label {
    color: #28a745;
}

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(102, 126, 234, 0.7);
    }
    50% {
        box-shadow: 0 0 0 4px rgba(102, 126, 234, 0);
    }
}

/* Tabs */
.tabs {
    display: flex;
    width: 100%;
    margin-bottom: 24px;
    border-bottom: 2px solid #e0e0e0;
    flex: 0 0 auto;
}

.tab-btn {
    flex: 1;
    text-align: center;
    padding: 12px 24px;
    border: none;
    background: transparent;
    color: #666;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: all 0.3s ease;
    margin-bottom: -2px;
}

.tab-btn:hover {
    color: #667eea;
    background-color: #f8f9ff;
}

.tab-btn.active {
    color: #667eea;
    border-bottom-color: #667eea;
}

.tab-content {
    display: none;
    /* Allow tab content to scroll without growing the outer card */
    overflow-y: auto;
    flex: 1 1 auto;
    min-height: 0; /* required for overflow in flex children */
    padding-right: 10px; /* Space between content and scrollbar */
}

/* Custom Scrollbar for Tab Content */
.tab-content::-webkit-scrollbar {
    width: 6px;
}

.tab-content::-webkit-scrollbar-track {
    background: transparent;
}

.tab-content::-webkit-scrollbar-thumb {
    background-color: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
}

.tab-content::-webkit-scrollbar-thumb:hover {
    background-color: rgba(0, 0, 0, 0.3);
}

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

/* Edit JSON tab: standard scrolling */
#editor-tab.tab-content {
    overflow-y: auto;
    display: none;
}

#editor-tab.active {
    display: block;
}

#editor-tab .editor-wrapper {
    display: block;
    margin-bottom: 24px;
}

/* Fixed height editor to avoid scroll conflicts */
#editor-tab .json-editor-container {
    height: 500px; /* Fixed height */
    min-height: 0;
    max-height: none;
    flex: none;
}

#multimodal-tab .json-editor-container {
    height: 300px; /* Fixed height for minimal config */
    min-height: 0;
    max-height: none;
    flex: none;
}

#editor-tab .button-group {
    margin-bottom: 0;
}

/* Log Generator Tab */
#log-gen-tab.tab-content {
    overflow-y: auto;
    display: none;
}

#log-gen-tab.active {
    display: block !important;
}

/* JSON Editor */
.editor-wrapper {
    margin-bottom: 24px;
}

/* Editor Toolbar */
.editor-header {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
    justify-content: flex-end; /* Align to right */
    flex-wrap: wrap; /* Allow wrapping on smaller screens */
}

.json-editor-container {
    width: 100%;
    /* Constrain editor height */
    height: 50vh;
    border: 2px solid #ddd;
    border-radius: 8px;
    overflow: hidden;
    transition: border-color 0.3s ease;
    text-align: left;
}

.json-editor-container:focus-within {
    border-color: #667eea;
}

/* Ensure Monaco editor content is left-aligned */
.json-editor-container .monaco-editor {
    text-align: left;
}

.json-editor-container .monaco-editor .view-lines {
    text-align: left;
}

.json-error {
    color: #721c24;
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 13px;
    margin-top: 8px;
}

.editor-footer {
    margin-top: 8px;
}

/* Download Container */
.download-container {
    margin-top: 16px;
    animation: fadeIn 0.5s ease-out;
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: center;
}

#download-bundle-link {
    padding: 10px 24px;
    font-size: 15px;
    min-width: 200px; /* Consistent with other primary actions */
    box-shadow: 0 4px 6px rgba(40, 167, 69, 0.2);
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    display: none;
    justify-content: center;
    align-items: center;
    padding: 20px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal-overlay.show {
    opacity: 1;
}

.modal-content {
    background-color: #fff;
    border-radius: 12px;
    max-width: 800px;
    width: 100%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    position: relative;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    transform: translateY(20px);
    transition: transform 0.3s ease;
    text-align: left;
}

.modal-header {
    padding: 20px 30px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex: 0 0 auto;
}

.modal-body {
    padding: 30px;
    overflow-y: auto;
    flex: 1 1 auto;
}

.modal-overlay.show .modal-content {
    transform: translateY(0);
}

.close-modal {
    background: transparent;
    border: none;
    cursor: pointer;
    color: #999;
    padding: 5px;
    border-radius: 50%;
    transition: all 0.2s ease;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-modal:hover {
    background-color: #f1f1f1;
    color: #333;
}

.close-modal svg {
    width: 20px;
    height: 20px;
}

/* Schema Styles */
.schema-wrapper {
    text-align: left;
}

.schema-title {
    margin: 0 0 6px 0;
    font-size: 20px;
    color: #333;
}

.schema-subtitle {
    margin: 0 0 20px 0;
    font-size: 14px;
    color: #666;
}

.schema-section {
    margin: 20px 0;
}

.schema-section-title {
    font-size: 14px;
    font-weight: 600;
    color: #333;
    margin-bottom: 10px;
}

.schema-list {
    margin: 0;
    padding-left: 20px;
    color: #444;
    font-size: 14px;
}

.schema-note {
    font-size: 14px;
    color: #444;
    margin-bottom: 12px;
}

.schema-pre {
    background: #f7f7fb;
    border: 1px solid #e6e6ef;
    border-radius: 8px;
    padding: 16px;
    overflow: auto;
    font-size: 13px;
    line-height: 1.5;
    margin: 0;
    white-space: pre;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Form Input Styles */
.form-input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 16px;
    font-family: inherit;
    transition: all 0.3s ease;
    background-color: #fff;
}

.form-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-input:hover:not(:focus) {
    border-color: #bbb;
}

.form-input::placeholder {
    color: #999;
}

/* Number input adjustments */
input[type="number"].form-input {
    font-size: 16px;
}

input[type="number"].form-input::-webkit-outer-spin-button,
input[type="number"].form-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

input[type="number"].form-input {
    -moz-appearance: textfield;
}

/* Form Hint Text */
.form-hint {
    display: block;
    font-size: 13px;
    color: #999;
    margin-top: 6px;
}

/* Download Container - Enhanced for sections */
.download-container {
    margin-top: 24px;
    animation: fadeIn 0.5s ease-out;
    display: flex;
    flex-direction: column;
    gap: 24px;
    align-items: flex-start;
    width: 100%;
}

.download-section {
    width: 100%;
    padding: 20px;
    background-color: #f8f9ff;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    transition: all 0.3s ease;
}

.download-section:hover {
    border-color: #667eea;
    background-color: #f0f0ff;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);
}

.download-section .section-title {
    margin-top: 0;
    margin-bottom: 16px;
}

/* Log Generator Section */
.log-generator-section {
    width: 100%;
    padding: 24px;
    background-color: #f0f8ff;
    border: 2px solid #667eea;
    border-radius: 12px;
    transition: all 0.3s ease;
}

.log-generator-section:hover {
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.15);
}

.log-generator-section .section-title {
    margin-top: 0;
    color: #667eea;
    font-weight: 600;
    margin-bottom: 12px;
}

.log-generator-section .section-description {
    margin-bottom: 20px;
    color: #555;
}

/* Log Generator Container (Tab) */
.log-generator-container {
    padding: 20px 0;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.log-generator-container .section-description {
    margin-bottom: 12px;
    color: #555;
}

.log-generator-container .form-group {
    text-align: left;
    margin-bottom: 20px;
}

/* Section Titles */
.section-title {
    font-size: 16px;
    font-weight: 600;
    color: #333;
    margin: 20px 0 12px 0;
}

/* Message for Log Generator */
.log-gen-message {
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 14px;
    margin-top: 12px;
    animation: slideDown 0.3s ease-out;
}

.log-gen-message.message-success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.log-gen-message.message-error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

#download-bundle-link {
    padding: 10px 24px;
    font-size: 15px;
    min-width: 240px;
    box-shadow: 0 4px 6px rgba(40, 167, 69, 0.2);
}

#download-bundle-link:hover {
    box-shadow: 0 6px 12px rgba(40, 167, 69, 0.3);
}

#generate-logs-btn {
    width: 100%;
    padding: 14px 24px;
    font-size: 16px;
}

#generate-logs-btn:hover:not(:disabled) {
    box-shadow: 0 6px 16px rgba(102, 126, 234, 0.3);
}

#generate-logs-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

/* Responsive Design */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }
    
    .container {
        padding: 24px 20px;
    }
    
    h1 {
        font-size: 24px;
    }
    
    .subtitle {
        font-size: 13px;
    }
    
    .file-label {
        padding: 30px 15px;
    }
    
    .upload-icon {
        width: 40px;
        height: 40px;
    }
    
    .btn {
        width: 100%;
        min-width: auto;
    }
    
    .tab-btn {
        font-size: 14px;
        padding: 10px 16px;
    }
    
    .editor-header {
        flex-direction: column;
    }
    
    .json-editor-container {
        min-height: 300px;
    }

    #editor-tab .json-editor-container {
        min-height: 200px;
    }
    
    .progress-steps {
        padding: 0 10px;
    }
    
    .progress-steps::before {
        left: 30px;
        right: 30px;
    }
    
    .step-icon {
        width: 36px;
        height: 36px;
        font-size: 12px;
    }
    
    .step-label {
        font-size: 11px;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 20px 15px;
    }
    
    h1 {
        font-size: 20px;
    }
    
    .file-label {
        padding: 24px 12px;
    }
    
    .upload-icon {
        width: 36px;
        height: 36px;
        margin-bottom: 12px;
    }
    
    .tab-btn {
        font-size: 13px;
        padding: 8px 12px;
    }
    
    .json-editor-container {
        min-height: 250px;
    }

    #editor-tab .json-editor-container {
        min-height: 180px;
    }
    
    .step-icon {
        width: 32px;
        height: 32px;
    }
    
    .progress-steps::before {
        top: 16px;
        left: 24px;
        right: 24px;
    }
}
