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

:root {
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-tertiary: #f1f5f9;
    --bg-hover: #e2e8f0;
    --bg-elevated: #262c36;
    
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #656d76;
    --text-accent: #58a6ff;
    
    --accent-primary: #0f4ba5;
    --accent-secondary: #1f6feb;
    --accent-danger: #da3633;
    --accent-warning: #d29922;
    
    --border-primary: #e2e8f0;
    --border-secondary: #f1f5f9;
    --border-accent: #388bfd;
    
    --json-key: #79c0ff;
    --json-string: #a5d6ff;
    --json-number: #79c0ff;
    --json-boolean: #ff7b72;
    --json-null: #8b949e;
    
    --success-bg: rgba(35, 134, 54, 0.15);
    --error-bg: rgba(218, 54, 51, 0.15);
    --warning-bg: rgba(210, 153, 34, 0.15);
    --info-bg: rgba(56, 139, 253, 0.15);
    
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.16), 0 2px 4px rgba(0, 0, 0, 0.12);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.2), 0 6px 10px rgba(0, 0, 0, 0.16);
    
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans', Helvetica, Arial, sans-serif;
    background: linear-gradient(135deg, var(--bg-primary) 0%, #ffffff 100%);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

header {
    text-align: center;
    margin-bottom: 40px;
    padding: 30px 0;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-primary);
    box-shadow: var(--shadow-md);
}

header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--text-accent) 0%, var(--json-string) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 10px;
    letter-spacing: -0.5px;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1.1rem;
    font-weight: 400;
}

main {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 30px;
}

/* Generator Container Layout */
.generator-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    margin-bottom: 30px;
}

.input-section,
.output-section {
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-lg);
    padding: 25px;
    box-shadow: var(--shadow-md);
    transition: var(--transition);
}

.input-section:hover,
.output-section:hover {
    border-color: var(--border-accent);
    box-shadow: var(--shadow-lg);
}

.input-group {
    margin-bottom: 20px;
}

.input-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.input-with-actions {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.json-textarea {
    width: 100%;
    min-height: 300px;
    background: var(--bg-primary);
    border: 2px solid var(--border-primary);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    padding: 16px;
    font-family: 'Cascadia Code', 'Fira Code', 'Consolas', 'Monaco', monospace;
    font-size: 14px;
    line-height: 1.6;
    resize: vertical;
    transition: var(--transition);
}

.json-textarea:focus {
    outline: none;
    border-color: var(--border-accent);
    box-shadow: 0 0 0 3px rgba(56, 139, 253, 0.1);
}

.json-textarea::placeholder {
    color: var(--text-muted);
    font-style: italic;
}

.input-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.btn {
    padding: 10px 18px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    transition: left 0.5s;
}

.btn:hover::before {
    left: 100%;
}

.btn-primary {
    background: var(--accent-primary);
    color: white;
    border-color: var(--accent-primary);
}

.btn-primary:hover {
    background: #2ea043;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-color: var(--border-primary);
}

.btn-secondary:hover {
    background: var(--bg-hover);
    border-color: var(--border-accent);
    transform: translateY(-1px);
}

.btn-danger {
    background: var(--accent-danger);
    color: white;
    border-color: var(--accent-danger);
}

.btn-danger:hover {
    background: #b91c1c;
    transform: translateY(-2px);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.85rem;
}

.char-count {
    text-align: right;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 8px;
}

/* Options Group */
.options-group {
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    padding: 20px;
    margin-top: 20px;
}

.options-group h3 {
    margin-bottom: 15px;
    color: var(--text-secondary);
    font-size: 1.1rem;
    font-weight: 600;
    border-bottom: 2px solid var(--border-primary);
    padding-bottom: 8px;
}

.format-controls {
    display: grid;
    gap: 15px;
}

.option-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-primary);
    transition: var(--transition);
}

.option-item:hover {
    border-color: var(--border-accent);
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 0.95rem;
    color: var(--text-primary);
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent-primary);
    cursor: pointer;
}

.option-select {
    background: var(--bg-primary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    padding: 6px 10px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: var(--transition);
}

.option-select:focus {
    outline: none;
    border-color: var(--border-accent);
}

/* Output Section */
.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid var(--border-primary);
}

.panel-header h3 {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.panel-actions {
    display: flex;
    gap: 8px;
}

.json-output {
    min-height: 300px;
    background: var(--bg-primary);
    border: 2px solid var(--border-primary);
    border-radius: var(--radius-md);
    padding: 20px;
    font-family: 'Cascadia Code', 'Fira Code', 'Consolas', 'Monaco', monospace;
    font-size: 14px;
    line-height: 1.6;
    overflow: auto;
    position: relative;
}

.json-output::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

.json-output::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

.json-output::-webkit-scrollbar-thumb {
    background: var(--bg-hover);
    border-radius: 5px;
}

.json-output::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

.text-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 250px;
    color: var(--text-muted);
    text-align: center;
    font-style: italic;
}

.placeholder-icon {
    font-size: 3rem;
    margin-bottom: 15px;
    opacity: 0.5;
}

.placeholder-text {
    font-size: 0.9rem;
    margin-top: 5px;
}

/* Validation Panel */
.validation-panel {
    margin-top: 20px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
    padding: 20px;
}

.validation-panel h3 {
    margin-bottom: 15px;
    color: var(--text-secondary);
    font-size: 1.1rem;
    font-weight: 600;
}

.validation-status {
    padding: 15px;
    border-radius: var(--radius-sm);
    border: 1px solid;
    font-size: 0.95rem;
}

.validation-status.valid {
    background: var(--success-bg);
    border-color: var(--accent-primary);
    color: #3fb950;
}

.validation-status.invalid {
    background: var(--error-bg);
    border-color: var(--accent-danger);
    color: #f85149;
}

/* Tools Section */
.tools-section,
.templates-section {
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-lg);
    padding: 25px;
    box-shadow: var(--shadow-md);
}

.tools-grid,
.templates-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.tool-btn,
.template-btn {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 20px;
    background: var(--bg-tertiary);
    border: 2px solid var(--border-primary);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
    text-align: left;
    width: 100%;
}

.tool-btn:hover,
.template-btn:hover {
    border-color: var(--border-accent);
    background: var(--bg-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.tool-icon,
.template-icon {
    font-size: 2rem;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
    border-radius: var(--radius-sm);
    flex-shrink: 0;
}

.tool-info,
.template-info h4 {
    color: var(--text-primary);
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 5px;
}

.tool-info p,
.template-info p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.4;
}

/* JSON Syntax Highlighting */
.json-key {
    color: var(--json-key);
    font-weight: 600;
}

.json-string {
    color: var(--json-string);
}

.json-number {
    color: var(--json-number);
    font-weight: 500;
}

.json-boolean {
    color: var(--json-boolean);
    font-weight: 600;
}

.json-null {
    color: var(--json-null);
    font-style: italic;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(4px);
}

.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    max-width: 800px;
    width: 90%;
    max-height: 80vh;
    overflow: hidden;
    animation: modalSlideIn 0.3s ease-out;
}

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

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid var(--border-primary);
    background: var(--bg-tertiary);
}

.modal-header h3 {
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--text-primary);
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-muted);
    cursor: pointer;
    padding: 5px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.modal-close:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.modal-body {
    padding: 25px;
    max-height: 60vh;
    overflow-y: auto;
}

.schema-textarea,
.compare-textarea {
    width: 100%;
    min-height: 200px;
    background: var(--bg-primary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    padding: 15px;
    font-family: 'Cascadia Code', 'Fira Code', 'Consolas', 'Monaco', monospace;
    font-size: 14px;
    resize: vertical;
    margin-bottom: 15px;
}

.compare-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

.compare-column {
    display: flex;
    flex-direction: column;
}

.compare-column label {
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-secondary);
}

.schema-results,
.compare-results {
    margin-top: 20px;
    padding: 15px;
    background: var(--bg-primary);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-primary);
    min-height: 100px;
}

footer {
    text-align: center;
    padding: 20px;
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-top: 40px;
    border-top: 1px solid var(--border-primary);
}

/* Responsive Design */
@media (max-width: 1024px) {
    .generator-container {
        grid-template-columns: 1fr;
    }
    
    .tools-grid,
    .templates-grid {
        grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    }
    
    .compare-container {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 15px;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    .input-actions {
        justify-content: center;
    }
    
    .modal-content {
        width: 95%;
        margin: 20px;
    }
    
    .tools-grid,
    .templates-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 10px;
    }
    
    header {
        padding: 20px 15px;
    }
    
    header h1 {
        font-size: 1.8rem;
    }
    
    .input-section,
    .output-section,
    .tools-section,
    .templates-section {
        padding: 15px;
    }
    
    .json-textarea {
        min-height: 200px;
        padding: 12px;
    }
    
    .btn {
        padding: 8px 14px;
        font-size: 0.85rem;
    }
    
    .tool-btn,
    .template-btn {
        padding: 15px;
        gap: 12px;
    }
    
    .tool-icon,
    .template-icon {
        font-size: 1.5rem;
        width: 40px;
        height: 40px;
    }
}

/* Smooth scrolling */
html {
    scroll-behavior: smooth;
}

/* Focus styles for accessibility */
.btn:focus,
input:focus,
textarea:focus,
select:focus {
    outline: 2px solid var(--border-accent);
    outline-offset: 2px;
}

/* Loading animation */
.loading {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid var(--border-primary);
    border-radius: 50%;
    border-top-color: var(--accent-primary);
    animation: spin 1s ease-in-out infinite;
}

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