/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #3b82f6;
    --primary-dark: #2563eb;
    --primary-light: #60a5fa;
    --secondary: #64748b;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --bg: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-tertiary: #f1f5f9;
    --border: #e2e8f0;
    --border-light: #f1f5f9;
    --text: #0f172a;
    --text-secondary: #334155;
    --text-muted: #64748b;
    --shadow-sm: rgba(0, 0, 0, 0.05);
    --shadow: rgba(0, 0, 0, 0.1);
    --shadow-md: rgba(0, 0, 0, 0.15);
    --shadow-lg: rgba(0, 0, 0, 0.2);
    --radius-sm: 6px;
    --radius: 8px;
    --radius-lg: 12px;
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: var(--text);
    background: linear-gradient(180deg, var(--bg-secondary) 0%, var(--bg-tertiary) 100%);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

/* Header */
header {
    text-align: center;
    margin-bottom: var(--spacing-xl);
    padding: var(--spacing-xl) 0;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    border-radius: var(--radius-lg);
    box-shadow: 0 10px 25px var(--shadow-md);
    position: relative;
    overflow: hidden;
}

header::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 70%);
    animation: pulse 8s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: translate(0, 0); }
    50% { transform: translate(5%, 5%); }
}

header h1 {
    font-size: 3rem;
    font-weight: 800;
    margin-bottom: var(--spacing-sm);
    position: relative;
    letter-spacing: -0.02em;
}

.tagline {
    font-size: 1.125rem;
    opacity: 0.95;
    position: relative;
    font-weight: 400;
    letter-spacing: 0.01em;
}

/* Statistics Summary */
.stats-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-xl);
    padding: var(--spacing-lg);
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.05) 0%, rgba(37, 99, 235, 0.05) 100%);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
}

.stat-summary-card {
    background: var(--bg);
    padding: var(--spacing-lg);
    border-radius: var(--radius);
    text-align: center;
    box-shadow: 0 2px 8px var(--shadow-sm);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stat-summary-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--shadow);
}

.stat-summary-value {
    display: block;
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: var(--spacing-xs);
    line-height: 1;
}

.stat-summary-label {
    display: block;
    font-size: 0.875rem;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 2rem;
    border-bottom: 2px solid var(--border);
}

.tab-button {
    padding: 0.75rem 1.5rem;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-muted);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: -2px;
}

.tab-button:hover {
    color: var(--primary);
}

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

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Filters */
.filters {
    background: var(--bg);
    padding: 1.5rem;
    border-radius: var(--radius);
    box-shadow: 0 1px 3px var(--shadow);
    margin-bottom: 2rem;
}

.filters h2 {
    font-size: 1.25rem;
    margin-bottom: 1rem;
    color: var(--text);
}

.filter-group {
    display: inline-block;
    margin-right: 1.5rem;
    margin-bottom: 0.5rem;
}

.filter-group label {
    display: inline-block;
    margin-right: 0.5rem;
    font-weight: 500;
    color: var(--text);
}

.filter-group select {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
    color: var(--text);
    font-size: 0.875rem;
    cursor: pointer;
    transition: border-color 0.2s;
}

.filter-group select:hover {
    border-color: var(--primary);
}

.filter-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Dimensions */
.dimensions {
    margin-bottom: 2rem;
}

.dimensions h2 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
    color: var(--text);
}

.dimensions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

.dimension-card {
    background: var(--bg);
    padding: var(--spacing-lg);
    border-radius: var(--radius-lg);
    box-shadow: 0 1px 3px var(--shadow-sm);
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    border: 2px solid var(--border-light);
    position: relative;
    overflow: hidden;
}

.dimension-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--primary);
    transform: scaleY(0);
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.dimension-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 16px var(--shadow);
    border-color: var(--primary-light);
}

.dimension-card:hover::before {
    transform: scaleY(1);
}

.dimension-card.selected {
    border-color: var(--primary);
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.05) 0%, rgba(37, 99, 235, 0.08) 100%);
    box-shadow: 0 4px 12px var(--shadow);
}

.dimension-card.selected::before {
    transform: scaleY(1);
}

.dimension-title {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text);
}

.dimension-meta {
    display: flex;
    gap: 1rem;
    font-size: 0.875rem;
    color: var(--text-muted);
}

.dimension-badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    background: var(--bg-secondary);
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--secondary);
}

/* Repositories */
.repositories {
    margin-bottom: 2rem;
}

.repositories h2 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
    color: var(--text);
}

.repos-grid {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

/* Repository Bar Chart */
.repo-bar-item {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: var(--spacing-md);
    cursor: pointer;
    transition: all 0.2s ease;
}

.repo-bar-item:hover {
    border-color: var(--primary);
    box-shadow: 0 4px 12px var(--shadow);
    transform: translateX(4px);
}

.repo-bar-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-sm);
    gap: var(--spacing-md);
    flex-wrap: wrap;
}

.repo-bar-name {
    font-weight: 600;
    color: var(--text);
    font-size: 0.95rem;
    flex: 1 1 auto;
    min-width: 200px;
}

.repo-bar-meta {
    display: flex;
    gap: var(--spacing-sm);
    align-items: center;
    flex-shrink: 0;
}

.lang-badge {
    background: var(--bg-tertiary);
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
}

.loc-badge {
    background: var(--bg-secondary);
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 600;
}

.repo-bar-chart {
    display: flex;
    height: 32px;
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--bg-tertiary);
    margin-bottom: var(--spacing-sm);
}

.repo-bar-segment {
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 0.75rem;
    font-weight: 600;
}

.repo-bar-local {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
}

.repo-bar-deps {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

.repo-bar-legend {
    display: flex;
    gap: var(--spacing-md);
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
}

.legend-local::before {
    content: '■ ';
    color: #3b82f6;
    font-size: 1rem;
}

.legend-deps::before {
    content: '■ ';
    color: #10b981;
    font-size: 1rem;
}

.legend-no-deps {
    color: var(--text-muted);
    font-style: italic;
}

.legend-not-analyzed {
    color: var(--warning);
    font-style: italic;
    font-size: 0.75rem;
}

/* Legacy Repo Cards (keeping for backward compatibility) */
.repo-card {
    background: var(--bg);
    padding: var(--spacing-lg);
    border-radius: var(--radius-lg);
    box-shadow: 0 1px 3px var(--shadow-sm);
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    border-left: 4px solid var(--border);
    position: relative;
}

.repo-card::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--primary) 0%, var(--primary-light) 100%);
    transform: scaleX(0);
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.repo-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 16px var(--shadow);
    border-left-color: var(--primary);
}

.repo-card:hover::after {
    transform: scaleX(1);
}

.repo-card.analyzed {
    border-left-color: var(--success);
}

.repo-card.analyzed:hover {
    border-left-color: var(--success);
}

.repo-card.analyzed::after {
    background: linear-gradient(90deg, var(--success) 0%, #34d399 100%);
}

.repo-name {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text);
}

.repo-description {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.repo-meta {
    display: flex;
    gap: 1rem;
    font-size: 0.875rem;
    color: var(--text-muted);
    flex-wrap: wrap;
}

.repo-meta span {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: var(--bg);
    padding: 2rem;
    border-radius: var(--radius);
    max-width: 800px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

.close {
    position: absolute;
    top: 1rem;
    right: 1.5rem;
    font-size: 2rem;
    font-weight: 300;
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.2s;
}

.close:hover {
    color: var(--text);
}

/* Repository Detail */
.repo-detail-header {
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--border);
}

.repo-detail-title {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.repo-detail-url {
    color: var(--primary);
    text-decoration: none;
    font-size: 0.875rem;
}

.repo-detail-url:hover {
    text-decoration: underline;
}

.iceberg-chart {
    margin: 2rem 0;
    text-align: center;
}

.chart-container {
    position: relative;
    width: 300px;
    height: 300px;
    margin: 0 auto;
}

.chart-canvas {
    max-width: 100%;
    height: auto;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin: 2rem 0;
}

.stat-card {
    background: var(--bg-secondary);
    padding: 1rem;
    border-radius: var(--radius);
    text-align: center;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--primary);
    display: block;
}

.stat-label {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

/* Rankings */
.rankings {
    background: var(--bg);
    padding: 2rem;
    border-radius: var(--radius);
    box-shadow: 0 1px 3px var(--shadow);
}

.rankings h2 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.rankings .description {
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

.rankings-grid {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.ranking-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    transition: all 0.2s;
}

.ranking-item:hover {
    background: var(--bg);
    box-shadow: 0 2px 4px var(--shadow);
}

.ranking-position {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-muted);
    min-width: 3rem;
    text-align: center;
}

.ranking-position.top-3 {
    color: var(--primary);
}

.ranking-info {
    flex: 1;
}

.ranking-name {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.25rem;
}

.ranking-system {
    font-size: 0.875rem;
    color: var(--text-muted);
}

.ranking-count {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--primary);
}

/* About */
.about {
    background: var(--bg);
    padding: 2rem;
    border-radius: var(--radius);
    box-shadow: 0 1px 3px var(--shadow);
}

.about h2 {
    font-size: 1.75rem;
    margin-bottom: 1rem;
}

.about h3 {
    font-size: 1.25rem;
    margin-top: 2rem;
    margin-bottom: 0.75rem;
    color: var(--primary);
}

.about p {
    margin-bottom: 1rem;
    line-height: 1.7;
}

.about ul, .about ol {
    margin-left: 2rem;
    margin-bottom: 1rem;
}

.about li {
    margin-bottom: 0.5rem;
    line-height: 1.7;
}

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

.about a:hover {
    text-decoration: underline;
}

/* Footer */
footer {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
    font-size: 0.875rem;
}

footer a {
    color: var(--primary);
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
}

/* Empty States */
.empty-state {
    text-align: center;
    padding: var(--spacing-xl);
    background: var(--bg);
    border-radius: var(--radius-lg);
    box-shadow: 0 1px 3px var(--shadow-sm);
    margin: var(--spacing-lg) 0;
}

.empty-state-icon {
    font-size: 4rem;
    margin-bottom: var(--spacing-md);
    opacity: 0.5;
}

.empty-state-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: var(--spacing-sm);
}

.empty-state-message {
    color: var(--text-muted);
    font-size: 1rem;
    line-height: 1.6;
    max-width: 500px;
    margin: 0 auto;
}

/* Loading States */
.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-xl);
    min-height: 300px;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-text {
    margin-top: var(--spacing-md);
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* Utility Classes */
.loading, .placeholder {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
    font-style: italic;
}

.hidden {
    display: none !important;
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }

    header h1 {
        font-size: 2rem;
    }

    .tagline {
        font-size: 1rem;
    }

    .dimensions-grid,
    .repos-grid {
        grid-template-columns: 1fr;
    }

    .filter-group {
        display: block;
        margin-right: 0;
        margin-bottom: 1rem;
    }

    .filter-group label {
        display: block;
        margin-bottom: 0.25rem;
    }

    .filter-group select,
    .filter-group input {
        width: 100%;
    }

    /* Mobile responsive repository header */
    section.repositories > div[style] {
        flex-direction: column !important;
        align-items: stretch !important;
    }

    section.repositories > div[style] > div[style] {
        flex-direction: column !important;
        width: 100% !important;
    }

    section.repositories h2 {
        margin-bottom: 1rem !important;
    }

    /* Filters section mobile */
    .filters {
        display: flex;
        flex-direction: column;
    }

    .filter-group {
        width: 100%;
        flex: 1 1 auto !important;
    }

    /* Tabs */
    .tabs {
        flex-direction: row;
        gap: 0.5rem;
        overflow-x: auto;
    }

    .tab-button {
        flex: 1;
        min-width: fit-content;
        padding: 0.75rem 1rem;
        font-size: 0.875rem;
    }

    /* Modal improvements */
    .modal-content {
        margin: 0.5rem;
        padding: 1rem;
        max-height: 90vh;
        overflow-y: auto;
    }

    .close {
        font-size: 2rem;
        top: 0.5rem;
        right: 0.5rem;
    }

    /* Stats grid */
    .stats-grid {
        grid-template-columns: 1fr !important;
        gap: 0.75rem !important;
    }

    /* Repo cards */
    .repo-card {
        padding: 1rem;
    }

    .repo-name {
        font-size: 0.95rem;
        word-break: break-word;
    }

    .repo-description {
        font-size: 0.875rem;
    }

    .repo-meta {
        flex-wrap: wrap;
        gap: 0.5rem;
        font-size: 0.8rem;
    }

    /* Dimension cards */
    .dimension-card {
        padding: 1rem;
    }

    .dimension-title {
        font-size: 1rem;
    }

    /* Chart container */
    .chart-container {
        max-width: 100%;
        overflow-x: auto;
    }

    #pie-chart {
        max-width: 280px;
        height: auto;
    }

    /* Ranking items */
    .ranking-item {
        padding: 0.75rem;
    }

    .ranking-position {
        width: 35px;
        height: 35px;
        font-size: 1rem;
    }

    .ranking-name {
        font-size: 0.95rem;
    }

    .ranking-count {
        font-size: 0.8rem;
    }

    /* Statistics summary */
    .stats-summary {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
        padding: 1rem;
    }

    .stat-summary-card {
        padding: 1rem;
    }

    .stat-summary-value {
        font-size: 1.5rem;
    }

    .stat-summary-label {
        font-size: 0.75rem;
    }

    /* Repository bars */
    .repo-bar-label {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--spacing-sm);
    }

    .repo-bar-name {
        font-size: 0.875rem;
        min-width: unset;
        width: 100%;
    }

    .repo-bar-meta {
        width: 100%;
        justify-content: flex-start;
    }

    .repo-bar-chart {
        height: 28px;
    }

    .repo-bar-legend {
        font-size: 0.75rem;
    }
}

/* Multiselect Dropdown Styles */
.multiselect-filters {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.multiselect-dropdown {
    position: relative;
    min-width: 250px;
}

.multiselect-button {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    color: var(--text);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.2s;
}

.multiselect-button:hover {
    border-color: var(--primary);
    background: var(--bg-secondary);
}

.multiselect-button:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.multiselect-label {
    color: var(--text-secondary);
}

.multiselect-arrow {
    color: var(--text-muted);
    transition: transform 0.2s;
}

.multiselect-menu.open + .multiselect-button .multiselect-arrow {
    transform: rotate(180deg);
}

.multiselect-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 0.25rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: 0 4px 6px -1px var(--shadow-md), 0 2px 4px -1px var(--shadow-sm);
    z-index: 1000;
    max-height: 300px;
    overflow-y: auto;
}

.multiselect-menu.open {
    display: block;
}

.multiselect-option {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    cursor: pointer;
    transition: background 0.15s;
    gap: 0.75rem;
}

.multiselect-option:hover {
    background: var(--bg-secondary);
}

.multiselect-option input[type="checkbox"] {
    cursor: pointer;
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
}

.multiselect-option span {
    font-size: 0.875rem;
    color: var(--text-secondary);
    user-select: none;
}

.multiselect-option:hover span {
    color: var(--text);
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .multiselect-filters {
        flex-direction: column;
    }

    .multiselect-dropdown {
        width: 100%;
    }
}
