/* ===== Design Tokens ===== */
:root {
    /* Colors */
    --primary: #00B894;
    --primary-hover: #009376;
    --secondary: #55EFC4;
    --accent: #FDCB6E;

    --bg-deep: #050d0a;
    --bg-base: #0A1A14;
    --bg-card: rgba(15, 35, 27, 0.65);
    --bg-input: rgba(5, 13, 10, 0.4);
    --bg-hover: rgba(85, 239, 196, 0.1);

    --border: rgba(85, 239, 196, 0.15);
    --border-focus: rgba(0, 184, 148, 0.5);

    --text-main: #E2E8F0;
    --text-muted: #94A3B8;
    --text-dim: #475569;

    /* Status Colors */
    --status-vendored: #FF7675;
    --status-generated: #74B9FF;
    --status-docs: #A29BFE;

    /* Typography */
    --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
    --font-mono: 'Fira Code', 'Courier New', monospace;

    /* Metrics */
    --radius-lg: 16px;
    --radius-md: 12px;
    --radius-sm: 8px;
    --transition: 250ms cubic-bezier(0.4, 0, 0.2, 1);
    --shadow-card: 0 8px 32px rgba(0, 0, 0, 0.4);
    --shadow-glow: 0 0 20px rgba(0, 184, 148, 0.15);
}

/* ===== Resets & Base ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-sans);
    background-color: var(--bg-deep);
    color: var(--text-main);
    line-height: 1.5;
    min-height: 100vh;
    background-image:
        radial-gradient(circle at 15% 50%, rgba(0, 184, 148, 0.05), transparent 25%),
        radial-gradient(circle at 85% 30%, rgba(253, 203, 110, 0.03), transparent 25%);
}

.code-font {
    font-family: var(--font-mono);
}

/* ===== App Layout ===== */
.app-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.header {
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--primary);
}

.header-logo h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
    letter-spacing: -0.02em;
}

.header-subtitle {
    color: var(--text-muted);
    font-size: 0.95rem;
    border-left: 1px solid var(--border);
    padding-left: 16px;
}

.main-content {
    flex: 1;
    min-height: 0;
}

.split-pane {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    height: 100%;
}

@media (max-width: 900px) {
    .split-pane {
        grid-template-columns: 1fr;
        height: auto;
    }

    .app-container {
        height: auto;
    }
}

.pane {
    display: flex;
    flex-direction: column;
    gap: 24px;
    min-height: 0;
}

/* ===== Cards (Glassmorphism) ===== */
.card {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-card);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.editor-card {
    flex: 1;
    min-height: 250px;
}

.stats-card {
    flex-shrink: 0;
    padding: 20px;
}

.analysis-card {
    flex: 1;
    min-height: 300px;
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(0, 0, 0, 0.2);
}

.card-header h2 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--secondary);
}

/* ===== Form Controls ===== */
.input-wrap {
    flex: 1;
    position: relative;
    display: flex;
    flex-direction: column;
}

textarea {
    flex: 1;
    width: 100%;
    resize: none;
    background: var(--bg-input);
    border: none;
    color: var(--text-main);
    padding: 16px 20px;
    font-size: 0.9rem;
    line-height: 1.6;
    outline: none;
    transition: box-shadow var(--transition);
}

textarea:focus {
    box-shadow: inset 0 0 0 1px var(--border-focus);
}

textarea::placeholder {
    color: var(--text-dim);
}

.help-text {
    font-size: 0.75rem;
    color: var(--text-muted);
    padding: 8px 20px;
    background: rgba(0, 0, 0, 0.2);
    border-top: 1px solid var(--border);
}

.badge {
    background: var(--bg-input);
    color: var(--text-muted);
    font-size: 0.75rem;
    padding: 4px 10px;
    border-radius: 99px;
    border: 1px solid var(--border);
}

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
    border: none;
    background: transparent;
}

.btn-sm {
    padding: 6px 12px;
}

.btn-outline {
    border: 1px solid var(--border);
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.02);
}

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

/* ===== Statistics Visuals ===== */
.stats-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.progress-bar-container {
    height: 16px;
    background: var(--bg-deep);
    border-radius: 99px;
    overflow: hidden;
    display: flex;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.5);
}

.progress-bar-segment {
    height: 100%;
    transition: width 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Hover effect on segments highlights corresponding legend */
.progress-bar-segment:hover {
    filter: brightness(1.2);
}

.language-legend {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
    max-height: 160px;
    overflow-y: auto;
}

.language-legend::-webkit-scrollbar {
    width: 6px;
}

.language-legend::-webkit-scrollbar-track {
    background: transparent;
}

.language-legend::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 6px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.85rem;
}

.legend-color {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 0 8px currentColor;
}

.legend-name {
    color: var(--text-main);
    font-weight: 500;
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
}

.legend-percent {
    color: var(--text-muted);
    margin-left: auto;
}

.empty-state {
    color: var(--text-dim);
    font-size: 0.9rem;
    text-align: center;
    padding: 20px 0;
    grid-column: 1 / -1;
}

/* ===== File List ===== */
.file-list-container {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}

.file-list-container::-webkit-scrollbar {
    width: 8px;
}

.file-list-container::-webkit-scrollbar-track {
    background: var(--bg-deep);
}

.file-list-container::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

.file-list {
    list-style: none;
}

.file-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    transition: background var(--transition);
}

.file-item:hover {
    background: rgba(255, 255, 255, 0.02);
}

.file-item-left {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.file-path {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-rule-match {
    font-size: 0.7rem;
    color: var(--accent);
    display: flex;
    align-items: center;
    gap: 4px;
}

.file-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.file-lang {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.lang-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.status-badge {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 600;
}

.status-vendored {
    background: rgba(255, 118, 117, 0.15);
    color: var(--status-vendored);
}

.status-generated {
    background: rgba(116, 185, 255, 0.15);
    color: var(--status-generated);
}

.status-docs {
    background: rgba(162, 155, 254, 0.15);
    color: var(--status-docs);
}

.file-item.excluded {
    opacity: 0.6;
}

/* Custom Checkbox */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    color: var(--text-muted);
    cursor: pointer;
    user-select: none;
}

.checkbox-label input {
    display: none;
}

.checkbox-custom {
    width: 16px;
    height: 16px;
    border: 1px solid var(--border);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}

.checkbox-label input:checked+.checkbox-custom {
    background: var(--primary);
    border-color: var(--primary);
}

.checkbox-label input:checked+.checkbox-custom::after {
    content: '';
    width: 4px;
    height: 8px;
    border-right: 2px solid var(--bg-deep);
    border-bottom: 2px solid var(--bg-deep);
    transform: rotate(45deg) translateY(-1px);
}

/* ===== Toast ===== */
.toast {
    position: fixed;
    bottom: 32px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--secondary);
    color: var(--bg-deep);
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.9rem;
    opacity: 0;
    pointer-events: none;
    transition: all var(--transition);
    box-shadow: 0 4px 12px rgba(85, 239, 196, 0.3);
    z-index: 1000;
}

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