/**
 * Motion Library - Core Stylesheet
 * Premium Dark Theme inspired by Linear, Vercel, Stripe, and Notion
 */

:root {
    --bg-base: #090a10;
    --bg-surface: #0f1118;
    --bg-surface-elevated: #151824;
    --bg-card: #12141e;
    --bg-card-hover: #181b28;
    --bg-sidebar: #0b0d14;
    --bg-input: #111420;
    --bg-modal: #10131d;

    --border-subtle: rgba(255, 255, 255, 0.06);
    --border-medium: rgba(255, 255, 255, 0.12);
    --border-highlight: rgba(255, 255, 255, 0.22);

    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --text-faint: #475569;

    --accent-purple: #8b5cf6;
    --accent-purple-glow: rgba(139, 92, 246, 0.25);
    --accent-cyan: #06b6d4;
    --accent-cyan-glow: rgba(6, 182, 212, 0.25);
    --accent-emerald: #10b981;
    --accent-emerald-glow: rgba(16, 185, 129, 0.25);
    --accent-amber: #f59e0b;
    --accent-amber-glow: rgba(245, 158, 11, 0.25);
    --accent-rose: #f43f5e;
    --accent-rose-glow: rgba(244, 63, 94, 0.25);

    --sw-ae: #9d4edd;
    --sw-ae-bg: rgba(157, 78, 221, 0.12);
    --sw-pr: #bd53ed;
    --sw-pr-bg: rgba(189, 83, 237, 0.12);
    --sw-mogrt: #6366f1;
    --sw-mogrt-bg: rgba(99, 102, 241, 0.12);
    --sw-ps: #3b82f6;
    --sw-ps-bg: rgba(59, 130, 246, 0.12);
    --sw-ai: #f97316;
    --sw-ai-bg: rgba(249, 115, 22, 0.12);
    --sw-video: #06b6d4;
    --sw-video-bg: rgba(6, 182, 212, 0.12);

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 20px;

    --shadow-card: 0 4px 20px -2px rgba(0, 0, 0, 0.5), 0 0 0 1px var(--border-subtle);
    --shadow-elevated: 0 12px 40px -4px rgba(0, 0, 0, 0.7), 0 0 0 1px var(--border-medium);
    --shadow-glow: 0 0 25px -5px var(--accent-purple-glow);

    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

    --sidebar-width: 270px;
    --header-height: 64px;
    --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-smooth: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html, body {
    height: 100%;
    background-color: var(--bg-base);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow: hidden;
}

/* App Layout */
.app-container {
    display: flex;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
}

/* Sidebar */
.app-sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    height: 100%;
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    z-index: 40;
    transition: transform var(--transition-smooth);
}

.sidebar-header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 18px;
    border-bottom: 1px solid var(--border-subtle);
}

.brand-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--text-primary);
    font-weight: 700;
    font-size: 16px;
    letter-spacing: -0.3px;
}

.brand-icon {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--accent-purple), var(--accent-cyan));
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 16px var(--accent-purple-glow);
}

.brand-badge {
    font-size: 10px;
    text-transform: uppercase;
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-secondary);
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: 6px;
    font-weight: 600;
}

.sidebar-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 14px 10px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}

.sidebar-scroll::-webkit-scrollbar {
    width: 5px;
}
.sidebar-scroll::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

.nav-group {
    margin-bottom: 20px;
}

.nav-group-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
    padding: 6px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.nav-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    margin-bottom: 2px;
    border: 1px solid transparent;
}

.nav-item:hover {
    color: var(--text-primary);
    background-color: var(--bg-surface-elevated);
}

.nav-item.active {
    color: var(--text-primary);
    background-color: rgba(139, 92, 246, 0.12);
    border-color: rgba(139, 92, 246, 0.3);
    font-weight: 600;
}

.nav-item-left {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.nav-item-left span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nav-item-icon {
    width: 16px;
    height: 16px;
    opacity: 0.7;
    flex-shrink: 0;
}

.nav-item.active .nav-item-icon {
    opacity: 1;
    color: var(--accent-purple);
}

.nav-count {
    font-size: 11px;
    font-weight: 600;
    padding: 1px 7px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

.nav-item.active .nav-count {
    background: rgba(139, 92, 246, 0.25);
    color: #e2d9fc;
}

.sidebar-footer {
    padding: 14px 16px;
    border-top: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-surface);
}

.sidebar-lib-info {
    min-width: 0;
}

.lib-label {
    font-size: 10px;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.5px;
}

.lib-name {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Main Content Area */
.app-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    background-color: var(--bg-base);
}

/* Header */
.app-header {
    height: var(--header-height);
    min-height: var(--header-height);
    background-color: rgba(11, 13, 20, 0.8);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    z-index: 30;
}

.header-search-wrap {
    position: relative;
    width: 380px;
}

.header-search-input {
    width: 100%;
    height: 38px;
    padding: 0 14px 0 38px;
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 13px;
    outline: none;
    transition: all var(--transition-fast);
}

.header-search-input:focus {
    border-color: var(--accent-purple);
    box-shadow: 0 0 0 2px var(--accent-purple-glow);
    background: var(--bg-surface-elevated);
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    color: var(--text-muted);
    pointer-events: none;
}

.search-clear-btn {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    display: none;
    padding: 2px;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Content Body */
.app-body {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}

.app-body::-webkit-scrollbar {
    width: 8px;
}
.app-body::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

/* Hero Stats Section */
.hero-stats-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 16px;
    position: relative;
    overflow: hidden;
    transition: transform var(--transition-fast), border-color var(--transition-fast);
}

.stat-card:hover {
    transform: translateY(-2px);
    border-color: var(--border-medium);
}

.stat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.stat-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
}

.stat-icon {
    width: 18px;
    height: 18px;
    color: var(--text-muted);
}

.stat-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.5px;
}

.stat-sub {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.stat-card.accent-purple .stat-value { color: #c4b5fd; }
.stat-card.accent-cyan .stat-value { color: #67e8f9; }
.stat-card.accent-emerald .stat-value { color: #6ee7b7; }
.stat-card.accent-amber .stat-value { color: #fde047; }

/* Filter Bar */
.filter-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 12px 16px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.filter-group-left {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.filter-group-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.software-pills {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--bg-base);
    padding: 3px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
}

.sw-pill {
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    background: none;
    border: none;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    gap: 6px;
}

.sw-pill:hover {
    color: var(--text-primary);
}

.sw-pill.active {
    background: var(--bg-surface-elevated);
    color: var(--text-primary);
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.select-custom {
    height: 34px;
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 12px;
    padding: 0 10px;
    outline: none;
    cursor: pointer;
}

.select-custom:focus {
    border-color: var(--accent-purple);
}

/* View Mode Switcher */
.view-switch {
    display: flex;
    align-items: center;
    background: var(--bg-base);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 3px;
}

.view-btn {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.view-btn:hover {
    color: var(--text-primary);
}

.view-btn.active {
    background: var(--bg-surface-elevated);
    color: var(--text-primary);
}

/* Responsive */
@media (max-width: 1400px) {
    .hero-stats-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 900px) {
    .app-sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        transform: translateX(-100%);
    }
    .app-sidebar.open {
        transform: translateX(0);
    }
    .hero-stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}
