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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background-color: #f5f5f5;
    color: #333;
    line-height: 1.6;
}

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

/* Header */
header {
    text-align: center;
    margin-bottom: 15px;
}

header h1 {
    color: #2c3e50;
    font-size: 1.5rem;
    margin-bottom: 5px;
}

header p {
    color: #666;
    font-size: 0.9rem;
}

header .notice-box {
    font-size: 0.85rem;
    margin-top: 10px;
    padding: 12px 20px;
    border-radius: 10px;
    text-align: center;
}

header .notice-box p {
    margin: 3px 0;
}

header .notice-box.danger {
    color: #c0392b;
    background: #fdecea;
}

/* Upload Section */
.upload-section {
    margin-bottom: 20px;
}

/* Version Selector */
.version-selector {
    background: #fff;
    border-radius: 8px;
    padding: 15px 20px;
    margin-bottom: 15px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.version-row {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.version-group {
    flex: 1;
    min-width: 200px;
}

.version-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: #555;
    margin-bottom: 6px;
}

.version-group select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 0.9rem;
    background: #fff;
    color: #333;
    cursor: pointer;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.version-group select:hover {
    border-color: #3498db;
}

.version-group select:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.15);
}

.version-info {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #eee;
}

.version-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    padding: 4px 12px;
    border-radius: 15px;
    background: linear-gradient(135deg, #e8f5e9 0%, #c8e6c9 100%);
    color: #2e7d32;
}

.version-badge.cloud {
    background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
    color: #1565c0;
}

.version-badge.onpremise {
    background: linear-gradient(135deg, #fff3e0 0%, #ffe0b2 100%);
    color: #e65100;
}

.version-badge::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
}

.upload-area {
    background: #fff;
    border: 2px dashed #ccc;
    border-radius: 8px;
    padding: 15px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
}

.upload-area:hover,
.upload-area.dragover {
    border-color: #3498db;
    background: #f8fbfe;
}

.upload-icon {
    font-size: 1.8rem;
    margin: 0;
}

.upload-text {
    color: #666;
    margin: 0;
    font-size: 0.9rem;
}

.upload-btn {
    background: #3498db;
    color: #fff;
    border: none;
    padding: 10px 25px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1rem;
    transition: background 0.3s ease;
}

.upload-btn:hover {
    background: #2980b9;
}

.upload-status {
    margin-top: 15px;
    text-align: center;
}

.upload-status.loading {
    color: #3498db;
}

.upload-status.error {
    color: #e74c3c;
}

.upload-status.success {
    color: #27ae60;
}

/* Main Content */
.main-content {
    display: flex;
    gap: 20px;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    min-height: 400px;
}

/* Sidebar */
.sidebar {
    width: 300px;
    border-right: 1px solid #eee;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    max-height: 100vh;
    align-self: flex-start;
}

.sidebar-header {
    padding: 15px;
    border-bottom: 1px solid #eee;
}

.sidebar-header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.sidebar-header h2 {
    font-size: 1rem;
    color: #2c3e50;
    margin: 0;
}

/* Export Button */
.export-btn {
    background: linear-gradient(135deg, #27ae60 0%, #2ecc71 100%);
    color: #fff;
    border: none;
    padding: 6px 12px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 4px;
}

.export-btn:hover {
    background: linear-gradient(135deg, #219a52 0%, #27ae60 100%);
    transform: translateY(-1px);
}

.export-btn:active {
    transform: translateY(0);
}

.export-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

.search-input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 0.9rem;
}

.search-input:focus {
    outline: none;
    border-color: #3498db;
}

.component-tree {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    min-height: 0; /* Important for flex child scrolling */
}

/* Custom scrollbar for component tree */
.component-tree::-webkit-scrollbar {
    width: 8px;
}

.component-tree::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.component-tree::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

.component-tree::-webkit-scrollbar-thumb:hover {
    background: #a1a1a1;
}

/* Tree Node */
.tree-group {
    margin-bottom: 5px;
}

.tree-group-header {
    display: flex;
    align-items: center;
    padding: 5px 8px;
    cursor: pointer;
    border-radius: 4px;
    font-weight: 600;
    color: #555;
    font-size: 0.85rem;
}

.tree-group-header:hover {
    background: #f5f5f5;
}

.tree-group-header .arrow {
    margin-right: 5px;
    transition: transform 0.2s ease;
}

.tree-group-header.collapsed .arrow {
    transform: rotate(-90deg);
}

.tree-group-items {
    padding-left: 15px;
}

.tree-group-items.collapsed {
    display: none;
}

.tree-item {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    cursor: pointer;
    border-radius: 4px;
    font-size: 0.9rem;
    transition: background 0.2s ease;
}

.tree-item:hover {
    background: #f0f7ff;
}

.tree-item.selected {
    background: #3498db;
    color: #fff;
}

.tree-item .icon {
    margin-right: 8px;
}

/* Content Area */
.content-area {
    flex: 1;
    min-width: 0;
}

/* Content Scroll Container */
.content-scroll {
    padding: 20px;
}


/* Section Title */
.section-title {
    font-size: 1rem;
    font-weight: 600;
    color: #2c3e50;
    margin: 20px 0 12px 0;
    padding-bottom: 8px;
    border-bottom: 2px solid #3498db;
}

.section-title:first-of-type {
    margin-top: 0;
}

/* Component Info */
.component-info {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 20px;
}

.component-info h3 {
    color: #2c3e50;
    margin-bottom: 10px;
    font-size: 1.1rem;
}

.component-info .meta {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    font-size: 0.85rem;
    color: #666;
}

.component-info .meta-item {
    display: flex;
    align-items: center;
    gap: 5px;
}

.component-info .meta-item strong {
    color: #555;
}

/* JSON Viewer */
.json-viewer {
    background: #282c34;
    border-radius: 8px;
    overflow: hidden;
}

.json-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    background: #21252b;
    color: #abb2bf;
    font-size: 0.85rem;
}

.copy-btn {
    background: #3498db;
    color: #fff;
    border: none;
    padding: 5px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: background 0.2s ease;
}

.copy-btn:hover {
    background: #2980b9;
}

.copy-btn.copied {
    background: #27ae60;
}

#jsonOutput {
    padding: 15px;
    margin: 0;
    color: #abb2bf;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.85rem;
    line-height: 1.5;
    overflow-x: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* JSON Syntax Highlighting */
.json-key {
    color: #e06c75;
}

.json-string {
    color: #98c379;
}

.json-number {
    color: #d19a66;
}

.json-boolean {
    color: #56b6c2;
}

.json-null {
    color: #56b6c2;
}

/* Fields List */
.fields-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.field-card {
    background: #f8f9fa;
    border: 1px solid #eee;
    border-radius: 8px;
    padding: 15px;
}

.field-card.required {
    border-left: 3px solid #e74c3c;
}

.field-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 10px;
}

.field-name {
    font-weight: 600;
    color: #2c3e50;
    font-family: monospace;
    background: #e8e8e8;
    padding: 2px 8px;
    border-radius: 4px;
}

.field-type {
    background: #3498db;
    color: #fff;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    text-transform: uppercase;
}

.field-label {
    color: #555;
    margin-bottom: 8px;
}

.field-details {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    font-size: 0.85rem;
    color: #666;
}

.field-details .badge {
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
}

.badge.required {
    background: #fde8e8;
    color: #e74c3c;
}

.badge.optional {
    background: #e8f5e9;
    color: #27ae60;
}

/* Options List */
.field-options {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #eee;
}

.field-options h4 {
    font-size: 0.85rem;
    color: #555;
    margin-bottom: 8px;
}

.options-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.option-item {
    background: #fff;
    border: 1px solid #ddd;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.8rem;
}

.option-item .value {
    font-family: monospace;
    color: #e74c3c;
}

.option-item .text {
    color: #666;
    margin-left: 5px;
}

/* Multifield Children */
.multifield-children {
    margin-top: 10px;
    padding: 10px;
    background: #fff;
    border-radius: 4px;
    border: 1px dashed #ddd;
}

.multifield-children h4 {
    font-size: 0.85rem;
    color: #555;
    margin-bottom: 10px;
}

.child-field {
    padding: 8px;
    margin-bottom: 5px;
    background: #f5f5f5;
    border-radius: 4px;
    font-size: 0.85rem;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 40px;
    color: #999;
}

/* Loading Spinner */
.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 10px;
}

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

/* Core Component Based Tree Item */
.tree-item.core-based {
    color: #8e44ad;
}

.tree-item.core-based:hover {
    background: #f5eeff;
}

.tree-item.core-based.selected {
    background: #8e44ad;
    color: #fff;
}

/* Core Component Badge */
.core-component-badge {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-family: monospace;
}

/* Field Breakdown */
.field-breakdown {
    font-size: 0.8rem;
    color: #888;
}

.inherited-count {
    color: #8e44ad;
    font-weight: 600;
}

.custom-count {
    color: #27ae60;
    font-weight: 600;
}

/* Fields Section */
.fields-section {
    margin-bottom: 25px;
}

.fields-section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1rem;
    padding: 10px 15px;
    border-radius: 8px;
    margin-bottom: 15px;
}

.fields-section-title.inherited {
    background: linear-gradient(135deg, #f3e7ff 0%, #e8d4ff 100%);
    color: #6b21a8;
}

.fields-section-title.custom {
    background: linear-gradient(135deg, #e8f5e9 0%, #c8e6c9 100%);
    color: #2e7d32;
}

.fields-section-title .icon {
    font-size: 1.1rem;
}

.fields-section-title .count {
    background: rgba(255, 255, 255, 0.5);
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 0.85rem;
    margin-left: auto;
}

.fields-section-content {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Inherited Field Card */
.field-card.inherited {
    background: #faf5ff;
    border-color: #e9d5ff;
}

.field-card.inherited.required {
    border-left: 3px solid #8e44ad;
}

/* Field Badges */
.field-badges {
    display: flex;
    gap: 6px;
    align-items: center;
}

.field-inherited-badge {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    text-transform: uppercase;
    font-weight: 500;
}

/* Field Source */
.field-source {
    font-size: 0.75rem;
    color: #8e44ad;
    margin-bottom: 8px;
    font-family: monospace;
    background: #f3e8ff;
    padding: 4px 8px;
    border-radius: 4px;
    display: inline-block;
}

/* Supertype meta item */
.meta-item.supertype {
    width: 100%;
    margin-top: 5px;
}

/* Responsive */
@media (max-width: 768px) {
    .main-content {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid #eee;
        max-height: 300px;
        position: static;
        height: auto;
        min-height: auto;
    }
}
