/* CSS Variables */
:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --secondary-color: #64748b;
    --success-color: #22c55e;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --info-color: #3b82f6;

    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;

    --added-color: #22c55e;
    --changed-color: #3b82f6;
    --deprecated-color: #f59e0b;
    --removed-color: #ef4444;
    --fixed-color: #8b5cf6;
    --security-color: #ec4899;

    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);

    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;

    --transition: all 0.2s ease;
}

/* Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

/* App Container */
.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Header */
.header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-hover) 100%);
    color: white;
    padding: 2rem 1rem;
    text-align: center;
}

.header-content {
    max-width: 800px;
    margin: 0 auto;
}

.logo-section {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.logo {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
}

.header h1 {
    font-size: 2rem;
    font-weight: 700;
    margin: 0;
}

.tagline {
    font-size: 1.1rem;
    opacity: 0.9;
    margin-top: 0.5rem;
}

/* Main Content */
.main-content {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    padding: 1.5rem;
    max-width: 1600px;
    margin: 0 auto;
    width: 100%;
}

/* Cards */
.card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
}

.card h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.card h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: var(--text-secondary);
}

/* Form Elements */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.375rem;
    color: var(--text-secondary);
}

.form-group input[type="text"],
.form-group input[type="date"],
.form-group select {
    width: 100%;
    padding: 0.625rem 0.875rem;
    font-size: 0.9375rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--card-bg);
    color: var(--text-primary);
    transition: var(--transition);
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

/* Version Input */
.version-input-group {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.version-part {
    width: 60px !important;
    text-align: center;
    padding: 0.625rem 0.5rem !important;
}

.version-dot {
    font-size: 1.25rem;
    font-weight: bold;
    color: var(--text-secondary);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    font-size: 0.9375rem;
    font-weight: 500;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
}

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

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-secondary {
    background: var(--bg-color);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--border-color);
}

.btn-icon {
    padding: 0.5rem;
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
}

.btn-icon:hover {
    background: var(--bg-color);
    color: var(--primary-color);
}

.btn-add {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
}

.btn-add:hover {
    background: var(--primary-hover);
}

.version-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

/* Change Categories */
.change-categories {
    display: grid;
    gap: 1rem;
}

.category-group {
    padding: 1rem;
    background: var(--bg-color);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.category-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.category-header label {
    font-weight: 600;
    font-size: 0.9375rem;
}

.category-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: bold;
}

.category-icon.added { background: rgba(34, 197, 94, 0.15); color: var(--added-color); }
.category-icon.changed { background: rgba(59, 130, 246, 0.15); color: var(--changed-color); }
.category-icon.deprecated { background: rgba(245, 158, 11, 0.15); color: var(--deprecated-color); }
.category-icon.removed { background: rgba(239, 68, 68, 0.15); color: var(--removed-color); }
.category-icon.fixed { background: rgba(139, 92, 246, 0.15); color: var(--fixed-color); }
.category-icon.security { background: rgba(236, 72, 153, 0.15); color: var(--security-color); }

.change-items {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.change-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0.75rem;
    background: var(--card-bg);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
}

.change-item button {
    background: none;
    border: none;
    color: var(--danger-color);
    cursor: pointer;
    padding: 0.25rem;
    opacity: 0.7;
    transition: var(--transition);
}

.change-item button:hover {
    opacity: 1;
}

.add-item-row {
    display: flex;
    gap: 0.5rem;
}

.add-item-row input {
    flex: 1;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
}

.add-item-row input:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* Versions List */
.versions-container {
    max-height: 300px;
    overflow-y: auto;
}

.version-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    background: var(--bg-color);
    border-radius: var(--radius-md);
    margin-bottom: 0.5rem;
    border: 1px solid var(--border-color);
}

.version-info h4 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.version-info span {
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

.version-item-actions {
    display: flex;
    gap: 0.5rem;
}

.version-item-actions button {
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
}

.btn-edit {
    background: var(--info-color);
    color: white;
    border: none;
}

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

/* Editor Section */
.editor-section {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Preview Section */
.preview-section {
    position: sticky;
    top: 1.5rem;
    height: fit-content;
}

.preview-card {
    height: calc(100vh - 180px);
    display: flex;
    flex-direction: column;
    max-height: 800px;
}

.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.preview-header h2 {
    margin-bottom: 0;
}

.preview-actions {
    display: flex;
    gap: 0.5rem;
}

.preview-toggle {
    display: flex;
    gap: 0.25rem;
    margin-bottom: 1rem;
    padding: 0.25rem;
    background: var(--bg-color);
    border-radius: var(--radius-md);
}

.toggle-btn {
    flex: 1;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--text-secondary);
    transition: var(--transition);
}

.toggle-btn.active {
    background: var(--card-bg);
    color: var(--primary-color);
    box-shadow: var(--shadow-sm);
}

.preview-content {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    background: var(--bg-color);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.raw-preview {
    font-family: 'Fira Code', 'Monaco', 'Consolas', monospace;
    font-size: 0.8125rem;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
}

.raw-preview code {
    display: block;
}

/* Rendered Preview Styles */
.rendered-preview h1 {
    font-size: 1.75rem;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 0.5rem;
    margin-bottom: 1.5rem;
}

.rendered-preview h2 {
    font-size: 1.375rem;
    color: var(--primary-color);
    margin: 1.5rem 0 1rem;
}

.rendered-preview h3 {
    font-size: 1rem;
    color: var(--text-secondary);
    margin: 1rem 0 0.5rem;
}

.rendered-preview ul {
    list-style: disc;
    padding-left: 1.5rem;
    margin-bottom: 1rem;
}

.rendered-preview li {
    margin-bottom: 0.25rem;
}

.rendered-preview p {
    margin-bottom: 1rem;
}

/* Empty State */
.empty-state {
    text-align: center;
    color: var(--text-secondary);
    padding: 2rem;
    font-style: italic;
}

/* Footer */
.footer {
    background: var(--text-primary);
    color: white;
    text-align: center;
    padding: 1.5rem;
    margin-top: auto;
}

.footer a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
    transition: var(--transition);
}

.footer a:hover {
    color: #818cf8;
    text-decoration: underline;
}

/* Toast Notification */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--text-primary);
    color: white;
    padding: 0.875rem 1.5rem;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 1000;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

/* Responsive Design */
@media (max-width: 1200px) {
    .main-content {
        grid-template-columns: 1fr;
    }

    .preview-section {
        position: static;
    }

    .preview-card {
        height: auto;
        max-height: none;
    }

    .preview-content {
        min-height: 300px;
    }
}

@media (max-width: 768px) {
    .header {
        padding: 1.5rem 1rem;
    }

    .header h1 {
        font-size: 1.5rem;
    }

    .tagline {
        font-size: 0.9375rem;
    }

    .main-content {
        padding: 1rem;
        gap: 1rem;
    }

    .card {
        padding: 1rem;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .version-actions {
        flex-direction: column;
    }

    .version-actions .btn {
        width: 100%;
    }

    .version-input-group {
        justify-content: flex-start;
    }

    .version-part {
        width: 50px !important;
    }
}

@media (max-width: 480px) {
    .logo-section {
        flex-direction: column;
        gap: 0.5rem;
    }

    .preview-header {
        flex-direction: column;
        gap: 0.75rem;
        align-items: flex-start;
    }

    .preview-actions {
        width: 100%;
        justify-content: flex-end;
    }

    .version-item {
        flex-direction: column;
        gap: 0.75rem;
        align-items: flex-start;
    }

    .version-item-actions {
        width: 100%;
    }

    .version-item-actions button {
        flex: 1;
    }
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--secondary-color);
}

/* Focus Visible for Accessibility */
:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Print Styles */
@media print {
    .header,
    .editor-section,
    .preview-header,
    .preview-toggle,
    .footer {
        display: none;
    }

    .preview-section {
        position: static;
    }

    .preview-card {
        box-shadow: none;
        border: none;
    }

    .preview-content {
        border: none;
        background: white;
    }
}
