:root {
    --bg-dark: #0f111a;
    --bg-panel: #1a1d27;
    --bg-element: #232736;
    --border-color: #2f354a;
    --bg-hover: rgba(255, 255, 255, 0.05);

    --text-main: #f8fafc;
    --text-muted: #94a3b8;

    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;

    --font-sans: 'Inter', system-ui, sans-serif;
    --font-mono: 'Fira Code', monospace;
}

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

body {
    font-family: var(--font-sans);
    background-color: var(--bg-dark);
    color: var(--text-main);
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Utilities */
.text-primary {
    color: var(--primary);
}

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

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

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

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

.w-full {
    width: 100%;
}

.hidden {
    display: none !important;
}

/* Navbar */
.navbar {
    height: 60px;
    background-color: var(--bg-panel);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 1.5rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.brand h1 {
    font-size: 1.1rem;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.badge {
    background: rgba(99, 102, 241, 0.2);
    color: #818cf8;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    border: 1px solid rgba(99, 102, 241, 0.5);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.score-display {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-muted);
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.score-value {
    font-size: 1.25rem;
    font-weight: 700;
    font-family: var(--font-mono);
    color: var(--text-main);
}

.score-value.good {
    color: var(--success);
}

.score-value.mix {
    color: var(--warning);
}

.score-value.bad {
    color: var(--danger);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-weight: 500;
    font-family: var(--font-sans);
    font-size: 0.9rem;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
}

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

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

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

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

.btn-secondary:hover:not(:disabled) {
    background-color: var(--bg-hover);
}

.btn-text {
    background: transparent;
    color: var(--primary);
    border: none;
    font-size: 0.8rem;
    cursor: pointer;
    font-weight: 500;
}

.btn-text:hover {
    filter: brightness(1.2);
    text-decoration: underline;
}

/* Layout */
.app-layout {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

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

/* Left Panel: Analysis Tree */
.analysis-panel {
    flex: 1;
    min-width: 400px;
    background-color: var(--bg-dark);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
}

.panel-header {
    height: 50px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 1.5rem;
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border-color);
}

.panel-header h2 {
    font-size: 0.9rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.stats-bar {
    display: flex;
    padding: 0.75rem 1.5rem;
    gap: 1.5rem;
    background: var(--bg-element);
    border-bottom: 1px solid var(--border-color);
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-muted);
}

.stat-num {
    font-weight: 700;
    font-family: var(--font-mono);
    font-size: 1rem;
    margin-right: 0.25rem;
}

.tree-container {
    flex: 1;
    padding: 1.5rem;
    overflow-y: auto;
    font-family: var(--font-mono);
    font-size: 0.9rem;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    gap: 1rem;
    color: var(--text-muted);
}

/* Tree Nodes */
.tree-node {
    margin-left: 1rem;
    padding-left: 0.5rem;
    border-left: 1px dashed var(--border-color);
    margin-bottom: 0.25rem;
    position: relative;
}

.tree-node::before {
    content: '';
    position: absolute;
    left: 0;
    top: 12px;
    width: 0.5rem;
    height: 1px;
    border-top: 1px dashed var(--border-color);
}

/* No lines for root children */
.tree-root>.tree-node {
    margin-left: 0;
    border-left: none;
    padding-left: 0;
}

.tree-root>.tree-node::before {
    display: none;
}

.node-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.02);
    transition: background 0.2s;
}

.node-content:hover {
    background: var(--bg-hover);
}

.node-tag {
    color: var(--text-main);
    font-weight: bold;
}

.node-tag.tag-div {
    color: var(--danger);
    font-weight: normal;
}

.node-tag.tag-semantic {
    color: var(--success);
}

.node-classes {
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-left: 0.5rem;
    opacity: 0.7;
}

.node-suggestion {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.3);
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    color: var(--warning);
}

.btn-apply-suggestion {
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--warning);
    display: flex;
    align-items: center;
    padding: 2px;
}

.btn-apply-suggestion:hover {
    color: #fff;
    background: var(--warning);
    border-radius: 2px;
}

/* Right Panel: Editor */
.editor-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-panel);
}

.tabs {
    display: flex;
    height: 100%;
    margin-top: auto;
}

.tab {
    background: transparent;
    border: none;
    padding: 0 1rem;
    height: 100%;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    font-family: var(--font-sans);
}

.tab:hover:not(:disabled) {
    color: white;
    background: rgba(255, 255, 255, 0.05);
}

.tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.tab:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.code-container {
    flex: 1;
    position: relative;
}

.code-editor {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    padding: 1.5rem;
    border: none;
    resize: none;
    outline: none;
    background-color: #1e1e1e;
    color: #d4d4d4;
    font-family: var(--font-mono);
    font-size: 14px;
    line-height: 1.5;
}

.editor-footer {
    padding: 1rem;
    background: var(--bg-panel);
    border-top: 1px solid var(--border-color);
}

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

::-webkit-scrollbar-track {
    background: transparent;
}

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

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