.category-group {
    margin-bottom: 1rem;
    position: relative;
    transition: box-shadow 0.2s;
}
.category-group-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    user-select: none;
    outline: none;
    background: linear-gradient(90deg, #c7d2fe 0%, #e0e7ff 100%);
    border-radius: 0.5rem;
    padding: 1rem 0.5rem 0.5rem;
    font-size: 0.92rem;
    font-weight: 700;
    color: #1e40af;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.2rem;
    border: none;
    transition: background 0.2s, box-shadow 0.2s;
}
.category-group-header:focus {
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.18);
}
.collapse-icon {
    display: flex;
    align-items: center;
    margin-right: 0.5rem;
    transition: transform 0.2s;
}
.category-group.collapsed .collapse-icon {
    transform: rotate(-90deg);
}
.category-group-content {
    transition: max-height 0.2s, opacity 0.2s;
    overflow: hidden;
    max-height: 2000px;
    opacity: 1;
}
.category-group.collapsed .category-group-content {
    max-height: 0;
    opacity: 0;
    pointer-events: none;
}
/* Ensure recently viewed app badges fit within the sidebar */
.recent-app-item {
    max-width: 100%;
    box-sizing: border-box;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
/* Category Panel Styles */
.sidebar {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.05);
    border-radius: 16px;
    min-width: 0;
    max-width: none;
    width: 100%;
    flex-basis: 100%;
    flex: none !important;
    position: relative;
    transition: width 0.1s ease-out;
    overflow-x: hidden !important;
    overflow-y: auto;
    user-select: none;
    z-index: 2;
}

.main-content {
    flex: 1 1 0% !important;
    min-width: 0;
}
body.resizing-sidebar {
    cursor: ew-resize !important;
    user-select: none !important;
}
.recently-viewed {
    padding: 0.1rem 0 0.1rem 0.1rem;
    background: rgba(59, 130, 246, 0.02);
    border-top: 1px solid rgba(100, 116, 139, 0.1);
    margin-top: auto;
}

.recently-viewed h3 {
    font-size: 0.85rem;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.75rem;
}

.recent-apps {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    width: 100%;
    box-sizing: border-box;
    background: none;
    box-shadow: none;
    border-radius: 0;
    min-width: 0;
    max-width: 100%;
    flex: none;
    position: static;
    transition: none;
    user-select: none;
    z-index: 1;
/* Ensure recently viewed app badges fit within the sidebar */
.recent-app-item {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding: 0.35rem 0.75rem;
    border: none;
    background: rgba(59, 130, 246, 0.07);
    border-radius: 0.7rem;
    font-size: 0.97rem;
    color: #1e293b;
    margin: 0;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}
.recent-app-item:hover {
    background: rgba(59, 130, 246, 0.15);
    color: #2563eb;
}
}

.sidebar-resize-edge {
    position: absolute;
    right: 0;
    top: 0;
    width: 8px;
    height: 100%;
    cursor: ew-resize;
    background: transparent;
    z-index: 1000;
    transition: background-color 0.18s;
    border-top-right-radius: 16px;
    border-bottom-right-radius: 16px;
}

.main-content {
    flex: 1 1 0% !important;
    min-width: 0 !important;
}
.category-search input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.category-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.1rem 0 0.1rem 0.1rem;
    overflow-y: auto;
    overflow-x: hidden !important;
    max-height: calc(100vh - 200px);
    position: relative;
}

.category-group {
    margin-bottom: 1rem;
    position: relative;
}

.category-group-header {
    font-size: 0.92rem;
    font-weight: 700;
    color: #1e40af;
    background: linear-gradient(90deg, #c7d2fe 0%, #e0e7ff 100%);
    padding: 1rem 0.5rem 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-radius: 0.5rem;
    margin-bottom: 0.2rem;
}

.category-group-count {
    font-size: 0.75rem;
    color: #94a3b8;
    font-weight: normal;
}

.category-list-item {
    list-style: none;
    position: relative;
    z-index: 1;
}

.category-list-item:hover {
    z-index: 100;
}

.category-badge {
    display: flex;
    align-items: center;
    width: 100%;
    max-width: 100%;
    min-height: 38px;
    padding: 0.35rem 1rem;
    border: none;
    border-radius: 0.85rem;
    background: transparent;
    color: #1e293b;
    font-size: 0.97rem;
    font-weight: 500;
    letter-spacing: 0.01em;
    cursor: pointer;
    transition: background 0.2s, color 0.2s, box-shadow 0.2s, border-radius 0.2s;
    position: relative;
    box-shadow: 0 1px 2px rgba(59,130,246,0.03);
    margin: 0.12rem 0;
    gap: 0.5rem;
    box-sizing: border-box;
    overflow: hidden;
}

.category-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    gap: 0.75rem;
}

.category-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1;
    min-width: 0;
}

.category-name {
    flex: 1 1 0%;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.category-content {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
}

.category-badge:hover {
    background: rgba(59, 130, 246, 0.10);
    color: #2563eb;
    box-shadow: 0 2px 6px rgba(59,130,246,0.08);
    border-radius: 1.1rem;
    transform: none;
}

.category-badge::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 3px;
    background: #3b82f6;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.category-badge:hover::before {
    opacity: 1;
}

.category-badge.active {
    background: linear-gradient(90deg, #3b82f6 60%, #60a5fa 100%);
    color: #fff;
    font-weight: 600;
    box-shadow: 0 2px 10px rgba(59,130,246,0.13);
    border-radius: 1.2rem;
}

.category-badge.active::before {
    opacity: 0;
}

.category-icon {
    width: 1.5rem;
    height: 1.5rem;
    opacity: 0.7;
    transition: transform 0.2s ease;
}

.category-badge:hover .category-icon {
    transform: scale(1.1);
}

.category-badge.active .category-icon {
    opacity: 1;
}

.category-name {
    flex: 1;
    text-align: left;
    font-weight: 500;
}

.category-count {
    background: rgba(100, 116, 139, 0.1);
    padding: 0.2rem 0.6rem;
    border-radius: 1rem;
    font-size: 0.8rem;
    font-weight: 600;
    color: #64748b;
    transition: all 0.2s ease;
}

.category-badge:hover .category-count {
    background: rgba(59, 130, 246, 0.2);
    color: #3b82f6;
}

.category-badge.active .category-count {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

/* Recent Categories Section */
.recent-categories {
    padding: 1rem;
    border-bottom: 1px solid rgba(100, 116, 139, 0.1);
}

.recent-categories-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: #64748b;
    margin-bottom: 0.75rem;
}

.recent-categories-list {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    padding-bottom: 0.5rem;
}

.recent-category-chip {
    padding: 0.5rem 1rem;
    background: rgba(59, 130, 246, 0.08);
    border-radius: 2rem;
    font-size: 0.85rem;
    color: #3b82f6;
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.2s ease;
}

.recent-category-chip:hover {
    background: rgba(59, 130, 246, 0.15);
    transform: translateY(-1px);
}

/* Category Preview Tooltip */
.category-preview {
    position: absolute;
    left: 100%;
    top: 0;
    transform: translateY(-25%);
    min-width: 280px;
    max-width: 320px;
    background: white;
    border-radius: 0.5rem;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    padding: 1rem;
    margin-left: 1rem;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: all 0.15s ease-in-out;
    z-index: 1000;
}

.category-preview::before {
    content: '';
    position: absolute;
    top: calc(25% + 1rem);
    left: -6px;
    width: 12px;
        border-radius: 12px;
    background: white;
    transform: rotate(45deg);
    box-shadow: -2px 2px 4px -2px rgba(0, 0, 0, 0.1);
    z-index: 0;
}

.category-badge:hover .category-preview {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.category-badge:hover {
    background-color: rgba(59, 130, 246, 0.08);
}

.category-list-item {
    position: relative;
}

.category-preview::before {
    content: "";
    position: absolute;
    left: -6px;
    top: calc(50% - 6px);
    width: 12px;
    height: 12px;
    background: white;
    transform: rotate(45deg);
    box-shadow: -2px 2px 2px rgba(0, 0, 0, 0.025);
}

.category-preview .preview-content {
    position: relative;
    background: white;
    border-radius: 7px;
    z-index: 2;
}

.category-list-item {
    position: relative;
}

.category-badge:hover {
    background-color: rgba(59, 130, 246, 0.08);
}

.category-badge:hover .category-preview {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

/* Ensure the preview stays visible when hovering over it */
.category-preview:hover {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.category-badge[aria-expanded="true"] .category-preview {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.preview-header {
    margin-bottom: 0.75rem;
}

.preview-title {
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 0.25rem;
}

.preview-description {
    font-size: 0.85rem;
    color: #64748b;
    margin-bottom: 0.75rem;
}

.preview-apps {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.preview-app-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    border-radius: 0.25rem;
    background: rgba(100, 116, 139, 0.05);
}

.preview-app-icon {
    width: 1.25rem;
    height: 1.25rem;
    object-fit: contain;
}

.preview-app-name {
    font-size: 0.85rem;
    color: #334155;
}

/* Scrollbar styling */
.category-list::-webkit-scrollbar {
    width: 6px;
}

.category-list::-webkit-scrollbar-track {
    background: transparent;
}

.category-list::-webkit-scrollbar-thumb {
    background-color: rgba(100, 116, 139, 0.2);
    border-radius: 3px;
}

/* Custom scrollbar for sidebar (outer edge) */
.sidebar {
    scrollbar-width: thin;
    scrollbar-color: transparent transparent;
    transition: scrollbar-color 0.2s;
    margin-right: 0;
    border-right: 0.5px solid #f3f4f6;
}
.sidebar:hover {
    scrollbar-color: #cbd5e1 #f1f5f9;
}
.sidebar::-webkit-scrollbar {
    width: 1px;
    background: transparent;
    opacity: 0;
    transition: opacity 0.18s;
}

/* Match sidebar scrollbar to app panel (main-content) style */
.sidebar::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
.sidebar::-webkit-scrollbar-track {
    background: transparent;
}
.sidebar::-webkit-scrollbar-thumb {
    background-color: rgba(115, 128, 165, 0.2);
    border-radius: 3px;
}


.category-list-item {
    animation: slideIn 0.3s ease;
}

/* Focus styles */
.category-badge:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.3);
}

/* Loading state */
.category-badge.loading {
    position: relative;
    overflow: hidden;
}

.category-badge.loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.2),
        transparent
    );
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(100%);
    }
}
