:root {
    /* Indigo / Violet Palette */
    --primary: #6366F1;
    --primary-hover: #4F46E5;
    --secondary: #818CF8;
    --accent: #C7D2FE;
    --bg-dark: #1E1B4B;
    --bg-panel: rgba(49, 46, 129, 0.4);
    --bg-panel-hover: rgba(67, 56, 202, 0.5);

    --success: #10B981;
    --success-bg: rgba(16, 185, 129, 0.15);
    --danger: #EF4444;
    --danger-bg: rgba(239, 68, 68, 0.15);
    --warning: #F59E0B;

    --text-main: #F8FAFC;
    --text-muted: #94A3B8;
    --border-color: rgba(199, 210, 254, 0.15);

    --diff-add-bg: rgba(16, 185, 129, 0.2);
    --diff-add-text: #34D399;
    --diff-del-bg: rgba(239, 68, 68, 0.2);
    --diff-del-text: #F87171;
    --diff-hdr-bg: rgba(99, 102, 241, 0.2);
    --diff-ctx-text: #94A3B8;

    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.4);
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.light-theme {
    --bg-dark: #F8FAFC;
    --bg-panel: rgba(255, 255, 255, 0.7);
    --bg-panel-hover: rgba(255, 255, 255, 0.9);
    --text-main: #0F172A;
    --text-muted: #64748B;
    --border-color: rgba(99, 102, 241, 0.2);
    --shadow: 0 8px 32px 0 rgba(99, 102, 241, 0.1);

    --diff-add-bg: rgba(16, 185, 129, 0.1);
    --diff-add-text: #059669;
    --diff-del-bg: rgba(239, 68, 68, 0.1);
    --diff-del-text: #DC2626;
}

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

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    height: 100vh;
    overflow: hidden;
    transition: background-color 0.3s;
}

/* Background Mesh */
.background-mesh {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    background-image:
        radial-gradient(at 0% 0%, rgba(99, 102, 241, 0.15) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(129, 140, 248, 0.15) 0px, transparent 50%);
}

.light-theme .background-mesh {
    background-image:
        radial-gradient(at 0% 0%, rgba(99, 102, 241, 0.05) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(129, 140, 248, 0.05) 0px, transparent 50%);
}

/* Layout */
.app-container {
    display: flex;
    height: 100vh;
}

.sidebar {
    width: 300px;
    background: rgba(0, 0, 0, 0.2);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.light-theme .sidebar {
    background: rgba(255, 255, 255, 0.5);
}

.main-content {
    flex: 1;
    position: relative;
    overflow: hidden;
}

/* Typography & Utils */
.text-primary {
    color: var(--primary);
}

.text-success {
    color: var(--success);
}

.text-danger {
    color: var(--danger);
}

.text-warning {
    color: var(--warning);
}

.text-muted {
    color: var(--text-muted);
}

.text-xs {
    font-size: 0.75rem;
}

.text-center {
    text-align: center;
}

.font-mono {
    font-family: 'Fira Code', monospace;
}

.flex {
    display: flex;
}

.flex-grow {
    flex-grow: 1;
}

.gap-2 {
    gap: 0.5rem;
}

.mt-2 {
    margin-top: 0.5rem;
}

.mt-4 {
    margin-top: 1rem;
}

.mt-6 {
    margin-top: 1.5rem;
}

.mb-2 {
    margin-bottom: 0.5rem;
}

.mb-4 {
    margin-bottom: 1rem;
}

.w-full {
    width: 100%;
}

.px-lg {
    padding-left: 2rem;
    padding-right: 2rem;
}

.shadow-lg {
    box-shadow: 0 10px 25px -5px rgba(99, 102, 241, 0.4);
}

.hidden {
    display: none !important;
}

/* Sidebar Components */
.sidebar-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 2rem;
}

.sidebar-header h2 {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.search-box {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
}

.search-box input {
    background: transparent;
    border: none;
    color: var(--text-main);
    width: 100%;
    outline: none;
    font-size: 0.9rem;
}

.search-box input::placeholder {
    color: var(--text-muted);
}

.history-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-right: -0.5rem;
    padding-right: 0.5rem;
}

.history-list::-webkit-scrollbar {
    width: 4px;
}

.history-list::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 2px;
}

.history-item {
    padding: 0.75rem;
    border-radius: var(--radius-sm);
    background: transparent;
    border: 1px solid transparent;
    cursor: pointer;
    transition: var(--transition);
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.history-item:hover {
    background: var(--bg-panel);
    border-color: var(--border-color);
}

.history-item.active {
    background: var(--bg-panel-hover);
    border-color: var(--primary);
}

.history-title {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: flex;
    justify-content: space-between;
}

.sidebar-footer {
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
    margin-top: 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.6rem 1.2rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-family: inherit;
    font-size: 0.9rem;
    cursor: pointer;
    transition: var(--transition);
    border: 1px solid transparent;
}

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

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.btn-outline {
    background: transparent;
    border-color: var(--border-color);
    color: var(--text-main);
}

.btn-outline:hover {
    background: var(--bg-panel);
}

.btn-icon {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 6px;
    transition: var(--transition);
}

.btn-icon:hover {
    color: var(--text-main);
    background: var(--bg-panel);
}

/* Main Content Views */
.view-section {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    opacity: 0;
    pointer-events: none;
    transform: translateY(10px);
    transition: opacity 0.3s, transform 0.3s;
    overflow-y: auto;
}

.view-section.active {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.header-content {
    margin-bottom: 2rem;
}

.header-content h1 {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

/* Glass Panels */
.glass-panel {
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1.5rem;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: var(--shadow);
}

.panel-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Editor */
.editor-container {
    display: flex;
    flex-direction: column;
    padding: 0;
    overflow: hidden;
}

#diff-input {
    flex: 1;
    width: 100%;
    background: transparent;
    border: none;
    color: var(--text-main);
    padding: 1.5rem;
    font-family: 'Fira Code', monospace;
    font-size: 0.9rem;
    line-height: 1.5;
    resize: none;
    outline: none;
    white-space: pre;
    overflow-wrap: normal;
    overflow-x: auto;
}

#diff-input::placeholder {
    color: rgba(148, 163, 184, 0.4);
}

.action-bar {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
}

/* Results View */
.results-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 2rem;
}

.badges {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.badge {
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.badge-feature {
    color: #a855f7;
    border-color: rgba(168, 85, 247, 0.3);
}

.badge-bugfix {
    color: var(--danger);
    border-color: var(--danger-bg);
}

.badge-refactor {
    color: var(--warning);
    border-color: rgba(245, 158, 11, 0.3);
}

.badge-style {
    color: #3b82f6;
    border-color: rgba(59, 130, 246, 0.3);
}

.badge-docs {
    color: #10b981;
    border-color: rgba(16, 185, 129, 0.3);
}

.results-grid {
    display: grid;
    grid-template-columns: 2.5fr 1fr;
    gap: 1.5rem;
    align-items: start;
}

@media (max-width: 1024px) {
    .results-grid {
        grid-template-columns: 1fr;
    }
}

/* Markdown Explanation */
.markdown-body {
    font-size: 0.95rem;
    line-height: 1.6;
}

.markdown-body p {
    margin-bottom: 1rem;
}

.markdown-body p:last-child {
    margin-bottom: 0;
}

.markdown-body ul {
    padding-left: 1.5rem;
    margin-bottom: 1rem;
}

.markdown-body li {
    margin-bottom: 0.5rem;
}

.markdown-body strong {
    color: var(--primary);
}

.markdown-body code {
    background: rgba(0, 0, 0, 0.3);
    padding: 0.2em 0.4em;
    border-radius: 4px;
    font-family: 'Fira Code', monospace;
    font-size: 0.85em;
    color: var(--accent);
}

/* File Accordion */
.section-heading {
    font-size: 1.25rem;
    font-weight: 600;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

.file-item {
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    margin-bottom: 0.75rem;
    overflow: hidden;
}

.file-header {
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    user-select: none;
    background: rgba(0, 0, 0, 0.1);
}

.file-header:hover {
    background: rgba(0, 0, 0, 0.2);
}

.file-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-family: 'Fira Code', monospace;
    font-size: 0.9rem;
}

.file-stats {
    display: flex;
    gap: 0.5rem;
    font-size: 0.8rem;
    font-family: 'Fira Code', monospace;
}

.file-content {
    padding: 0;
    display: none;
    border-top: 1px solid var(--border-color);
}

.file-item.expanded .file-content {
    display: block;
}

/* Diff Viewer */
.diff-viewer {
    font-family: 'Fira Code', monospace;
    font-size: 0.85rem;
    line-height: 1.5;
    overflow-x: auto;
    background: #0D1117;
    color: #C9D1D9;
}

.diff-line {
    display: flex;
    white-space: pre-wrap;
    padding: 0 1rem;
}

.diff-line.add {
    background-color: var(--diff-add-bg);
    color: var(--diff-add-text);
}

.diff-line.del {
    background-color: var(--diff-del-bg);
    color: var(--diff-del-text);
}

.diff-line.hdr {
    background-color: var(--diff-hdr-bg);
    color: #818CF8;
    font-weight: 600;
    padding: 0.5rem 1rem;
}

.diff-line.ctx {
    color: var(--diff-ctx-text);
    opacity: 0.7;
}

/* Stats & Impact */
.impact-meter {
    margin-top: 1rem;
}

.meter-bar {
    height: 8px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.meter-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--success), var(--warning), var(--danger));
    border-radius: 4px;
}

.meter-label {
    text-align: right;
    font-size: 0.8rem;
    font-weight: 600;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
}

.stat-box {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0.75rem;
    text-align: center;
    display: flex;
    flex-direction: column;
}

.stat-num {
    font-size: 1.25rem;
    font-weight: 700;
    font-family: 'Fira Code', monospace;
}

.stat-lbl {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 0.25rem;
}

/* File List Simple */
.file-list-simple {
    list-style: none;
    font-family: 'Fira Code', monospace;
    font-size: 0.8rem;
}

.file-list-simple li {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    word-break: break-all;
}

.file-list-simple li:last-child {
    border-bottom: none;
}

.status-icon {
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

.status-M {
    background: var(--warning);
}

.status-A {
    background: var(--success);
}

.status-D {
    background: var(--danger);
}

/* Toast */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    background: var(--success);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 30px;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
    z-index: 1000;
    opacity: 1;
    transition: opacity 0.3s, transform 0.3s;
}

.toast.hidden {
    opacity: 0;
    transform: translateX(-50%) translateY(20px);
    pointer-events: none;
}