/* ========================================================================
   Dependency License Audit — Styles
   Premium glassmorphism dark-first design with responsive layout
   ======================================================================== */

/* ----- Design Tokens ----- */
:root {
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

    /* Dark theme (default) */
    --bg-primary: #0B0D17;
    --bg-secondary: #111427;
    --bg-card: rgba(17, 20, 39, 0.7);
    --bg-glass: rgba(255, 255, 255, 0.04);
    --bg-glass-hover: rgba(255, 255, 255, 0.08);
    --bg-input: rgba(255, 255, 255, 0.05);
    --border: rgba(255, 255, 255, 0.08);
    --border-focus: rgba(108, 99, 255, 0.5);
    --text-primary: #F0F0F5;
    --text-secondary: #8B8FA3;
    --text-muted: #5A5E72;
    --accent-primary: #6C63FF;
    --accent-primary-hover: #7B73FF;
    --accent-secondary: #00D4AA;
    --accent-gradient: linear-gradient(135deg, #6C63FF 0%, #00D4AA 100%);
    --risk-low: #00D4AA;
    --risk-medium: #FFB547;
    --risk-high: #FF5C5C;
    --risk-unknown: #8B8FA3;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 8px 32px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.4);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="light"] {
    --bg-primary: #F5F6FA;
    --bg-secondary: #FFFFFF;
    --bg-card: rgba(255, 255, 255, 0.85);
    --bg-glass: rgba(255, 255, 255, 0.6);
    --bg-glass-hover: rgba(255, 255, 255, 0.8);
    --bg-input: rgba(0, 0, 0, 0.04);
    --border: rgba(0, 0, 0, 0.08);
    --border-focus: rgba(108, 99, 255, 0.4);
    --text-primary: #1A1D2E;
    --text-secondary: #5A5E72;
    --text-muted: #8B8FA3;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 8px 32px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.1);
}

/* ----- Reset & Base ----- */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

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

/* Background gradient flare */
body::before {
    content: '';
    position: fixed;
    top: -50%;
    left: -30%;
    width: 80%;
    height: 80%;
    background: radial-gradient(ellipse, rgba(108, 99, 255, 0.08) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
}

body::after {
    content: '';
    position: fixed;
    bottom: -40%;
    right: -20%;
    width: 60%;
    height: 60%;
    background: radial-gradient(ellipse, rgba(0, 212, 170, 0.06) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
}

.app {
    position: relative;
    z-index: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ----- Header ----- */
.header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0.75rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

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

.logo-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    background: var(--bg-glass);
    border: 1px solid var(--border);
}

.logo-title {
    font-size: 1.125rem;
    font-weight: 700;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.logo-subtitle {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 400;
}

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

/* ----- Buttons ----- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    border: none;
    cursor: pointer;
    font-family: var(--font);
    font-weight: 500;
    text-decoration: none;
    transition: all var(--transition);
    border-radius: var(--radius-sm);
    white-space: nowrap;
}

.btn:focus-visible {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
}

.btn-primary {
    background: var(--accent-gradient);
    color: #fff;
    padding: 0.625rem 1.5rem;
    font-size: 0.875rem;
    box-shadow: 0 4px 16px rgba(108, 99, 255, 0.3);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 24px rgba(108, 99, 255, 0.4);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    padding: 0.5rem;
    border: 1px solid transparent;
}

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

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
}

.btn-lg {
    padding: 0.875rem 2rem;
    font-size: 1rem;
    border-radius: var(--radius-md);
}

.btn-icon {
    padding: 0.5rem;
    border-radius: var(--radius-sm);
}

/* ----- Main Content ----- */
.main {
    flex: 1;
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
    width: 100%;
}

/* ----- Input Section ----- */
.input-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    animation: fadeInUp 0.5s ease-out;
}

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

.section-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.375rem;
}

.section-desc {
    color: var(--text-secondary);
    font-size: 0.9375rem;
}

.editor-wrapper {
    width: 100%;
    max-width: 800px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    overflow: hidden;
    box-shadow: var(--shadow-md);
    transition: border-color var(--transition), box-shadow var(--transition);
}

.editor-wrapper:focus-within {
    border-color: var(--border-focus);
    box-shadow: var(--shadow-md), 0 0 0 3px rgba(108, 99, 255, 0.1);
}

.editor-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.625rem 1rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg-glass);
}

.editor-label {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-muted);
    font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
}

.editor-actions {
    display: flex;
    gap: 0.25rem;
}

.editor-textarea {
    width: 100%;
    padding: 1rem 1.25rem;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', 'Consolas', monospace;
    font-size: 0.875rem;
    line-height: 1.7;
    resize: vertical;
    min-height: 200px;
    tab-size: 2;
}

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

.editor-textarea:focus {
    outline: none;
}

.editor-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 1rem;
    border-top: 1px solid var(--border);
    background: var(--bg-glass);
}

.char-count {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.validation-status {
    font-size: 0.75rem;
    font-weight: 500;
}

.validation-status.valid {
    color: var(--risk-low);
}

.validation-status.invalid {
    color: var(--risk-high);
}

/* ----- Loading Section ----- */
.loading-section {
    display: flex;
    justify-content: center;
    padding: 3rem 0;
    animation: fadeInUp 0.4s ease-out;
}

.loading-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.25rem;
    padding: 2.5rem;
    border-radius: var(--radius-lg);
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-md);
    min-width: 320px;
}

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

.loading-text {
    font-weight: 600;
    font-size: 1.0625rem;
}

.loading-detail {
    font-size: 0.8125rem;
    color: var(--text-muted);
}

.progress-bar {
    width: 100%;
    height: 4px;
    background: var(--bg-input);
    border-radius: 2px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--accent-gradient);
    border-radius: 2px;
    width: 0%;
    transition: width 0.3s ease;
}

/* ----- Results Section ----- */
.results-section {
    animation: fadeInUp 0.5s ease-out;
}

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

.summary-actions {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    flex-wrap: wrap;
}

.summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.summary-card {
    padding: 1.25rem;
    border-radius: var(--radius-md);
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    transition: transform var(--transition), box-shadow var(--transition);
    animation: fadeInUp 0.5s ease-out backwards;
}

.summary-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.summary-card .card-value {
    font-size: 2rem;
    font-weight: 800;
    line-height: 1;
    margin-bottom: 0.375rem;
}

.summary-card .card-label {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.summary-card .card-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0.75rem;
    font-size: 1.125rem;
}

.card-total .card-value {
    color: var(--accent-primary);
}

.card-total .card-icon {
    background: rgba(108, 99, 255, 0.15);
}

.card-low .card-value {
    color: var(--risk-low);
}

.card-low .card-icon {
    background: rgba(0, 212, 170, 0.15);
}

.card-medium .card-value {
    color: var(--risk-medium);
}

.card-medium .card-icon {
    background: rgba(255, 181, 71, 0.15);
}

.card-high .card-value {
    color: var(--risk-high);
}

.card-high .card-icon {
    background: rgba(255, 92, 92, 0.15);
}

.card-unknown .card-value {
    color: var(--risk-unknown);
}

.card-unknown .card-icon {
    background: rgba(139, 143, 163, 0.15);
}

/* ----- Filter Bar ----- */
.filter-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1rem;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border);
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    flex-wrap: wrap;
}

.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.75rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-secondary);
    font-family: var(--font);
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
}

.filter-chip:hover {
    background: var(--bg-glass-hover);
    color: var(--text-primary);
}

.filter-chip.active {
    background: var(--accent-primary);
    color: #fff;
    border-color: var(--accent-primary);
}

.filter-chip:focus-visible {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
}

.risk-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.risk-dot.risk-low {
    background: var(--risk-low);
}

.risk-dot.risk-medium {
    background: var(--risk-medium);
}

.risk-dot.risk-high {
    background: var(--risk-high);
}

.risk-dot.risk-unknown {
    background: var(--risk-unknown);
}

.search-wrapper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem 0.75rem;
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    border: 1px solid var(--border);
    transition: border-color var(--transition);
    min-width: 200px;
}

.search-wrapper:focus-within {
    border-color: var(--border-focus);
}

.search-wrapper svg {
    color: var(--text-muted);
    flex-shrink: 0;
}

.search-input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 0.8125rem;
    outline: none;
}

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

/* ----- Table ----- */
.table-wrapper {
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    overflow-x: auto;
}

.results-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.results-table thead {
    border-bottom: 1px solid var(--border);
}

.results-table th {
    text-align: left;
    padding: 0.875rem 1rem;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    white-space: nowrap;
    user-select: none;
}

.results-table th.sortable {
    cursor: pointer;
    transition: color var(--transition);
}

.results-table th.sortable:hover {
    color: var(--text-primary);
}

.sort-icon {
    margin-left: 0.25rem;
    opacity: 0.4;
}

.results-table th[aria-sort="ascending"] .sort-icon,
.results-table th[aria-sort="descending"] .sort-icon {
    opacity: 1;
    color: var(--accent-primary);
}

.results-table td {
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--border);
    vertical-align: middle;
}

.results-table tbody tr {
    transition: background var(--transition);
}

.results-table tbody tr:hover {
    background: var(--bg-glass-hover);
}

.pkg-name {
    font-weight: 600;
    color: var(--text-primary);
}

.pkg-name a {
    color: inherit;
    text-decoration: none;
    transition: color var(--transition);
}

.pkg-name a:hover {
    color: var(--accent-primary);
}

.version-badge {
    display: inline-block;
    padding: 0.125rem 0.5rem;
    border-radius: 999px;
    background: var(--bg-input);
    font-family: 'SF Mono', monospace;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.license-badge {
    display: inline-block;
    padding: 0.1875rem 0.625rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.license-badge.risk-low {
    background: rgba(0, 212, 170, 0.12);
    color: var(--risk-low);
}

.license-badge.risk-medium {
    background: rgba(255, 181, 71, 0.12);
    color: var(--risk-medium);
}

.license-badge.risk-high {
    background: rgba(255, 92, 92, 0.12);
    color: var(--risk-high);
}

.license-badge.risk-unknown {
    background: rgba(139, 143, 163, 0.12);
    color: var(--risk-unknown);
}

.risk-indicator {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.8125rem;
    font-weight: 500;
}

.risk-indicator.low {
    color: var(--risk-low);
}

.risk-indicator.medium {
    color: var(--risk-medium);
}

.risk-indicator.high {
    color: var(--risk-high);
}

.risk-indicator.unknown {
    color: var(--risk-unknown);
}

.dep-type {
    display: inline-block;
    padding: 0.125rem 0.5rem;
    border-radius: 999px;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.dep-type.prod {
    background: rgba(108, 99, 255, 0.12);
    color: var(--accent-primary);
}

.dep-type.dev {
    background: rgba(139, 143, 163, 0.1);
    color: var(--text-muted);
}

.dep-type.peer {
    background: rgba(255, 181, 71, 0.1);
    color: var(--risk-medium);
}

.dep-type.optional {
    background: rgba(0, 212, 170, 0.1);
    color: var(--risk-low);
}

.note-text {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    max-width: 200px;
}

/* No results row */
.no-results td {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
    font-style: italic;
}

/* ----- Modal ----- */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    animation: fadeIn 0.2s ease-out;
}

.modal-card {
    width: 90%;
    max-width: 560px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    border-radius: var(--radius-xl);
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    animation: scaleIn 0.25s ease-out;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
}

.modal-title {
    font-size: 1.125rem;
    font-weight: 700;
}

.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 1.5rem;
}

.modal-footer {
    padding: 0.75rem 1.5rem;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
}

.history-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background var(--transition);
    border-radius: var(--radius-sm);
    padding-inline: 0.5rem;
}

.history-item:hover {
    background: var(--bg-glass-hover);
}

.history-item:last-child {
    border-bottom: none;
}

.history-info {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.history-name {
    font-weight: 600;
    font-size: 0.875rem;
}

.history-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.history-stats {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.history-risk-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.125rem 0.5rem;
    border-radius: 999px;
    font-size: 0.6875rem;
    font-weight: 600;
}

.empty-history {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
}

/* ----- Footer ----- */
.footer {
    text-align: center;
    padding: 1.5rem;
    font-size: 0.8125rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
}

/* ----- Utility ----- */
.hidden {
    display: none !important;
}

/* ----- Animations ----- */
@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(16px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

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

/* Staggered card animation delay */
.summary-card:nth-child(1) {
    animation-delay: 0s;
}

.summary-card:nth-child(2) {
    animation-delay: 0.06s;
}

.summary-card:nth-child(3) {
    animation-delay: 0.12s;
}

.summary-card:nth-child(4) {
    animation-delay: 0.18s;
}

.summary-card:nth-child(5) {
    animation-delay: 0.24s;
}

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

    .main {
        padding: 1.5rem 1rem;
    }

    .section-title {
        font-size: 1.25rem;
    }

    .summary-cards {
        grid-template-columns: repeat(2, 1fr);
    }

    .filter-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .search-wrapper {
        min-width: 0;
    }

    .summary-actions {
        justify-content: flex-start;
    }

    .results-table th,
    .results-table td {
        padding: 0.625rem 0.75rem;
    }

    .note-text {
        max-width: 140px;
    }
}

@media (max-width: 480px) {
    .summary-cards {
        grid-template-columns: 1fr;
    }

    .logo-subtitle {
        display: none;
    }

    .editor-textarea {
        min-height: 150px;
        font-size: 0.8125rem;
    }

    .summary-header {
        flex-direction: column;
        align-items: flex-start;
    }
}