:root {
    /* Base Variables - Light Mode (Clean & Neutral) */
    --primary: #007acc;
    --primary-hover: #0062a3;
    --bg-body: #f3f4f6;
    --bg-sidebar: #ffffff;
    --bg-card: #ffffff;
    --text-main: #1e1e1e;
    --text-muted: #6b7280;
    --border: #e5e7eb;
    --shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    --radius: 4px;
    --font-sans: 'Segoe UI', 'Inter', system-ui, sans-serif;
    --header-height: 50px;
}

[data-theme="dark"] {
    /* VS Code Dark Theme Colors */
    --primary: #007acc;
    /* VS Code Blue */
    --primary-hover: #0063a5;
    --bg-body: #1e1e1e;
    /* Editor bg */
    --bg-sidebar: #252526;
    /* Sidebar bg */
    --bg-card: #2d2d2d;
    /* Slightly lighter than body for cards */
    --bg-input: #3c3c3c;
    --text-main: #d4d4d4;
    /* Standard text */
    --text-muted: #858585;
    /* Comments/Muted */
    --border: #454545;
    /* Borders */
    --shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    --accent-green: #4ec9b0;
    /* Classes/Types */
    --accent-orange: #ce9178;
    /* Strings */
}

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

body {
    font-family: var(--font-sans);
    background-color: var(--bg-body);
    color: var(--text-main);
    height: 100vh;
    overflow: hidden;
    transition: background-color 0.2s, color 0.2s;
    font-size: 14px;
    /* VS Code default size */
}

#app {
    display: flex;
    height: 100%;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 0;
}

.brand {
    padding: 1rem;
    background-color: var(--bg-sidebar);
    border-bottom: 1px solid var(--border);
}

.brand h1 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin: 0;
}

.user-profile {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
}

#userInfo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

#userAvatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
}

.categories-nav {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem 0;
}

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

.nav-header h2 {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-muted);
}

.categories-list {
    list-style: none;
}

.category-item {
    padding: 0.4rem 1rem;
    cursor: pointer;
    color: var(--text-muted);
    transition: all 0.1s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    border-left: 3px solid transparent;
}

.category-item:hover {
    background-color: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
}

.category-item.active {
    background-color: rgba(255, 255, 255, 0.08);
    color: var(--text-main);
    border-left-color: var(--primary);
}

.sidebar-footer {
    border-top: 1px solid var(--border);
    padding: 0.5rem;
    display: flex;
    flex-direction: column;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.top-bar {
    height: var(--header-height);
    background-color: var(--bg-body);
    /* Blend with body */
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
}

.search-bar input {
    width: 350px;
    padding: 0.4rem 0.8rem;
    border-radius: 2px;
    border: 1px solid var(--border);
    background-color: var(--bg-input, #fff);
    color: var(--text-main);
    outline: none;
    font-size: 0.9rem;
}

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

.content-area {
    flex: 1;
    padding: 1.5rem;
    overflow-y: auto;
}

.filters-bar {
    display: flex;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    align-items: center;
}

#sortSelect {
    padding: 0.3rem 0.5rem;
    border-radius: 2px;
    border: 1px solid var(--border);
    background-color: var(--bg-input, #fff);
    color: var(--text-main);
    outline: none;
}

/* Grid */
.items-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1.5rem;
}

.item-card {
    background-color: var(--bg-card);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: transform 0.2s, box-shadow 0.2s;
    cursor: pointer;
    position: relative;
    border: 1px solid transparent;
}

.item-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.4);
    border-color: var(--primary);
}

.item-image {
    width: 100%;
    aspect-ratio: 2/3;
    object-fit: cover;
    background-color: var(--border);
}

.item-info {
    padding: 0.8rem;
}

.item-title {
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 0.3rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-main);
}

.item-rating {
    color: #ffd700;
    font-size: 0.85rem;
}

/* Buttons */
.btn {
    padding: 0.4rem 1rem;
    border-radius: 2px;
    border: none;
    cursor: pointer;
    font-weight: 500;
    font-size: 0.9rem;
    transition: background 0.2s;
}

.btn-primary {
    background-color: var(--primary);
    color: white;
}

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

.btn-secondary {
    background-color: var(--bg-input, #ddd);
    color: var(--text-main);
    border: 1px solid var(--border);
}

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

.btn-ghost {
    background: none;
    text-align: left;
    color: var(--text-muted);
    padding: 0.5rem 1rem;
    border-radius: 0;
}

.btn-ghost:hover {
    background-color: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
}

.btn-icon,
.btn-icon-small {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon-small {
    width: 24px;
    height: 24px;
    border-radius: 2px;
}

.btn-icon-small:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(2px);
}

.hidden {
    display: none !important;
}

.modal-content {
    background-color: var(--bg-sidebar);
    /* Use sidebar color for modals */
    padding: 1.5rem;
    border-radius: var(--radius);
    width: 100%;
    max-width: 450px;
    position: relative;
    max-height: 90vh;
    overflow-y: auto;
    border: 1px solid var(--border);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
}

.modal-content h2 {
    margin-bottom: 1.5rem;
    font-weight: 600;
    color: var(--primary);
}

.close-modal {
    position: absolute;
    top: 1rem;
    right: 1rem;
    font-size: 1.2rem;
    cursor: pointer;
    color: var(--text-muted);
}

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

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.4rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.5rem;
    border-radius: 2px;
    border: 1px solid var(--border);
    background-color: var(--bg-input, #fff);
    color: var(--text-main);
    font-family: inherit;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: 1px solid var(--primary);
    border-color: var(--primary);
}

.input-with-action {
    display: flex;
    gap: 0.5rem;
}

.rating-input span {
    cursor: pointer;
    font-size: 1.5rem;
    color: var(--border);
    transition: color 0.1s;
}

.rating-input span.active {
    color: #ffd700;
}

/* Drag and Drop */
.dragging {
    opacity: 0.5;
}

.drag-over {
    border: 2px dashed var(--primary);
}

/* Additions for Edit/Delete actions */
.cat-content {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.cat-actions {
    display: none;
    gap: 0.25rem;
}

.category-item:hover .cat-actions {
    display: flex;
}

.card-actions {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    display: flex;
    gap: 0.25rem;
    opacity: 0;
    transition: opacity 0.2s;
    background: rgba(30, 30, 30, 0.8);
    padding: 0.25rem;
    border-radius: 4px;
    z-index: 10;
}

.item-card:hover .card-actions {
    opacity: 1;
}

.card-actions button {
    color: #d4d4d4;
}

.card-actions button:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: white;
}

/* Icon Picker */
.icon-picker-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(32px, 1fr));
    gap: 0.5rem;
    max-height: 150px;
    overflow-y: auto;
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: 2px;
    background-color: var(--bg-input, #fff);
}

.icon-option {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 2px;
    transition: background-color 0.2s;
}

.icon-option:hover {
    background-color: var(--border);
}

.icon-option.selected {
    background-color: var(--primary);
    color: white;
}

/* Scrollbar styling for Webkit */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}
/* Mobile Responsiveness */
.mobile-only {
    display: none;
}

.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 900;
    backdrop-filter: blur(2px);
}

@media (max-width: 768px) {
    .mobile-only {
        display: flex;
    }

    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        height: 100%;
        z-index: 1000;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        box-shadow: 2px 0 10px rgba(0,0,0,0.5);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .brand {
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    .search-bar input {
        width: 100%; /* Full width on mobile */
    }

    .top-bar {
        padding: 0 1rem;
    }
    
    .filters-bar {
        flex-direction: column;
        gap: 1rem;
        align-items: stretch;
    }
    
    .view-toggle {
        align-self: flex-end;
    }
}

/* Cover Search Grid */
.covers-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 0.5rem;
    padding: 0.5rem;
}

.cover-item {
    cursor: pointer;
    border-radius: var(--radius);
    overflow: hidden;
    border: 2px solid transparent;
    aspect-ratio: 2/3;
}

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

.cover-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Item Description */
.item-description {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* List View */
.items-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.items-list .item-card {
    display: flex;
    flex-direction: row;
    height: 80px; /* Fixed height for compactness */
    align-items: center;
}

.items-list .item-image {
    width: 60px;
    height: 100%;
    aspect-ratio: auto; /* Override aspect-ratio from grid */
    object-fit: cover;
    flex-shrink: 0;
}

.items-list .item-info {
    flex: 1;
    padding: 0.5rem 1rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    overflow: hidden;
}

.items-list .item-title {
    font-size: 1rem;
    margin-bottom: 0.2rem;
}

.items-list .item-rating {
    font-size: 0.8rem;
}

.items-list .item-description {
    display: none; /* Hide description in compact list view to save space */
}

.items-list .card-actions {
    position: static;
    opacity: 0;
    background: none;
    padding: 0 1rem;
}

.items-list .item-card:hover .card-actions {
    opacity: 1;
}
