/* ==================================================================
   Bundle Size Treemap — Styles
   Theme: Royal Purple dark
   Primary: #9B59B6 | Secondary: #8E44AD | BG: #1A0D24
   ================================================================== */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #9B59B6;
    --primary-rgb: 155, 89, 182;
    --secondary: #8E44AD;
    --accent: #D2B4DE;
    --bg: #1A0D24;
    --bg-card: rgba(26, 13, 36, 0.85);
    --bg-elevated: rgba(40, 22, 56, 0.6);
    --text: #EDE7F6;
    --text-muted: #B39DCC;
    --text-dim: #7E6A93;
    --border: rgba(155, 89, 182, 0.12);
    --border-hover: rgba(155, 89, 182, 0.3);
    --danger: #EF4444;
    --radius: 12px;
    --radius-sm: 8px;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --mono: 'JetBrains Mono', monospace;
    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.6;
    overflow-x: hidden;
}

.ambient-glow {
    position: fixed;
    border-radius: 50%;
    filter: blur(130px);
    opacity: 0.08;
    pointer-events: none;
    z-index: 0;
}

.glow-1 {
    width: 500px;
    height: 500px;
    background: var(--primary);
    top: -200px;
    right: -100px;
}

.glow-2 {
    width: 400px;
    height: 400px;
    background: var(--secondary);
    bottom: -150px;
    left: -100px;
}

.glass-card {
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    transition: border-color var(--transition);
}

.glass-card:hover {
    border-color: var(--border-hover);
}

.app-container {
    max-width: 900px;
    margin: 0 auto;
    padding: 1.5rem 1rem;
    position: relative;
    z-index: 1;
}

.app-header {
    text-align: center;
    margin-bottom: 1.5rem;
}

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

.logo-icon {
    font-size: 1.75rem;
}

.logo h1 {
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.tagline {
    font-size: 0.8rem;
    color: var(--text-dim);
}

/* ── Drop Zone ────────────────────────────────────────────── */
.drop-zone {
    text-align: center;
    padding: 3rem 2rem;
    border: 2px dashed var(--border);
    transition: border-color var(--transition), box-shadow var(--transition);
    cursor: pointer;
}

.drop-zone.drag-over {
    border-color: var(--primary);
    box-shadow: 0 0 40px rgba(var(--primary-rgb), 0.2);
}

.drop-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
}

.drop-icon {
    font-size: 2.5rem;
}

.drop-zone h2 {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--primary);
}

.drop-zone p {
    font-size: 0.8rem;
    color: var(--text-dim);
    max-width: 400px;
}

.drop-zone code {
    background: var(--bg-elevated);
    padding: 0.1rem 0.35rem;
    border-radius: 4px;
    font-family: var(--mono);
    font-size: 0.75rem;
}

.drop-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: center;
    margin-top: 0.5rem;
}

.upload-btn {
    padding: 0.5rem 1.25rem;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border: none;
    border-radius: var(--radius-sm);
    color: #fff;
    font-family: var(--font);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: box-shadow var(--transition);
}

.upload-btn:hover {
    box-shadow: 0 4px 20px rgba(var(--primary-rgb), 0.3);
}

.upload-btn.secondary {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-weight: 500;
}

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

/* ── Modal ────────────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.modal {
    width: 90%;
    max-width: 550px;
    padding: 1.5rem;
}

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

.modal-header h2 {
    font-size: 1.1rem;
}

.icon-btn {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.3rem 0.5rem;
    cursor: pointer;
    color: var(--text);
    font-size: 0.9rem;
}

.paste-textarea {
    width: 100%;
    min-height: 200px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: var(--mono);
    font-size: 0.8rem;
    padding: 0.75rem;
    resize: vertical;
    margin-bottom: 0.75rem;
}

.paste-textarea:focus {
    outline: none;
    border-color: var(--primary);
}

/* ── Stats Bar ────────────────────────────────────────────── */
.stats-bar {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.stat-card {
    text-align: center;
    padding: 0.75rem;
}

.stat-label {
    display: block;
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-dim);
    margin-bottom: 0.125rem;
}

.stat-value {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary);
    font-family: var(--mono);
}

/* ── Search Row ───────────────────────────────────────────── */
.search-row {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    align-items: center;
}

.search-input {
    flex: 1;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: var(--font);
    font-size: 0.85rem;
    padding: 0.5rem 0.75rem;
}

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

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

.action-btn {
    padding: 0.5rem 0.75rem;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-family: var(--font);
    font-size: 0.8rem;
    cursor: pointer;
    transition: border-color var(--transition), color var(--transition);
    white-space: nowrap;
}

.action-btn:hover {
    border-color: var(--border-hover);
    color: var(--text);
}

.action-btn.danger:hover {
    border-color: rgba(239, 68, 68, 0.4);
    color: var(--danger);
}

/* ── Treemap ──────────────────────────────────────────────── */
.treemap-wrap {
    padding: 0.75rem;
    position: relative;
}

.breadcrumb {
    display: flex;
    gap: 0.25rem;
    margin-bottom: 0.5rem;
    font-size: 0.75rem;
    flex-wrap: wrap;
}

.breadcrumb-item {
    color: var(--text-dim);
    cursor: pointer;
    transition: color var(--transition);
}

.breadcrumb-item:hover {
    color: var(--primary);
}

.breadcrumb-item.root {
    color: var(--text-muted);
    font-weight: 500;
}

.breadcrumb-item::after {
    content: '›';
    margin-left: 0.25rem;
}

.breadcrumb-item:last-child::after {
    content: '';
}

#treemap-canvas {
    width: 100%;
    height: 400px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: block;
}

.tooltip {
    position: absolute;
    background: rgba(26, 13, 36, 0.95);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.5rem 0.75rem;
    font-size: 0.75rem;
    pointer-events: none;
    z-index: 10;
    max-width: 280px;
    color: var(--text);
}

.tooltip .tt-name {
    font-weight: 600;
    color: var(--primary);
    display: block;
    margin-bottom: 0.25rem;
    font-family: var(--mono);
    font-size: 0.7rem;
    word-break: break-all;
}

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

/* ── Module List ──────────────────────────────────────────── */
.module-list-wrap {
    margin-top: 1rem;
}

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

.section-label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-dim);
}

.sort-select {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-muted);
    font-family: var(--font);
    font-size: 0.75rem;
    padding: 0.3rem 0.5rem;
    cursor: pointer;
    appearance: none;
}

.module-list {
    max-height: 300px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.module-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    transition: border-color var(--transition);
}

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

.module-item.highlighted {
    border-color: var(--primary);
    box-shadow: 0 0 10px rgba(var(--primary-rgb), 0.15);
}

.module-color {
    width: 10px;
    height: 10px;
    border-radius: 3px;
    flex-shrink: 0;
}

.module-name {
    flex: 1;
    font-family: var(--mono);
    font-size: 0.75rem;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.module-size {
    font-family: var(--mono);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--primary);
    white-space: nowrap;
}

.module-pct {
    font-size: 0.65rem;
    color: var(--text-dim);
    width: 40px;
    text-align: right;
}

/* ── Suggestions ──────────────────────────────────────────── */
.suggestions-wrap {
    margin-top: 1rem;
}

.suggestions-list {
    margin-top: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.suggestion {
    padding: 0.5rem 0.75rem;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    color: var(--text-muted);
}

.suggestion strong {
    color: var(--accent);
}

/* ── Toast ────────────────────────────────────────────────── */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--primary);
    color: #fff;
    padding: 0.6rem 1.25rem;
    border-radius: 30px;
    font-size: 0.85rem;
    font-weight: 600;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.3s ease;
    z-index: 200;
}

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

.app-footer {
    text-align: center;
    padding: 2rem 0 0.5rem;
    color: var(--text-dim);
    font-size: 0.7rem;
}

.hidden {
    display: none !important;
}

@media (max-width:600px) {
    .stats-bar {
        grid-template-columns: 1fr 1fr;
    }

    #treemap-canvas {
        height: 280px;
    }

    .search-row {
        flex-wrap: wrap;
    }

    .drop-zone {
        padding: 2rem 1rem;
    }
}