:root {
    --bg-app: #050505;
    --bg-panel: #0a0a0a;
    --bg-input: #121212;
    --border: #27272a;
    --text-main: #ffffff;
    --text-muted: #a1a1aa;
    --primary: #ffffff;
    --primary-fg: #000000;
    --danger: #ef4444;

    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;

    --font-sans: 'Inter', sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-app);
    color: var(--text-main);
    font-family: var(--font-sans);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* Layout */
.app-container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 2rem;
}

/* Header */
.main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.main-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
}

.theme-toggle {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-main);
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s;
}

.theme-toggle:hover {
    background: var(--border);
}

/* Controls Bar */
.controls-bar {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
}

.btn-icon-primary {
    background: var(--primary);
    color: var(--primary-fg);
    border: none;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    cursor: pointer;
    transition: opacity 0.2s;
    flex-shrink: 0;
}

.btn-icon-primary:hover {
    opacity: 0.9;
}

.search-wrapper {
    flex: 1;
    position: relative;
}

.search-wrapper i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.search-wrapper input {
    width: 100%;
    height: 40px;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-main);
    padding: 0 1rem 0 2.5rem;
    font-family: inherit;
    font-size: 0.9rem;
    transition: border-color 0.2s;
}

.search-wrapper input:focus {
    outline: none;
    border-color: var(--text-muted);
}

.filter-wrapper select {
    height: 40px;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-main);
    padding: 0 2rem 0 1rem;
    font-family: inherit;
    font-size: 0.9rem;
    cursor: pointer;
    appearance: none;
    /* We'll just stick to native simple style or custom wrap if needed, but native is fine */
    /* Add a custom arrow if we really want, but let's keep it simple first */
    min-width: 120px;
}

/* Manga List */
.manga-list-container {
    background: transparent;
}

.list-header {
    display: grid;
    grid-template-columns: 80px 2fr 1fr 1.5fr 100px;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
}

.manga-item {
    display: grid;
    grid-template-columns: 80px 2fr 1fr 1.5fr 100px;
    padding: 1rem;
    align-items: center;
    border-bottom: 1px solid var(--border);
    transition: background 0.2s;
}

.manga-item:hover {
    background: rgba(255, 255, 255, 0.02);
}

.manga-cover {
    width: 48px;
    height: 72px;
    object-fit: cover;
    border-radius: 4px;
    background: var(--border);
}

.manga-name {
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

.manga-name a {
    color: var(--text-main);
    text-decoration: none;
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
}

.manga-name a:hover {
    text-decoration: underline;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .app-container {
        padding: 1rem;
    }

    .list-header {
        display: none;
    }

    .manga-item {
        display: block;
        padding: 0;
        border-bottom: 1px solid var(--border);
    }

    .manga-item-header {
        display: flex;
        align-items: center;
        gap: 0.75rem;
        padding: 0.75rem;
        cursor: pointer;
        user-select: none;
    }

    .manga-item-header:active {
        background: rgba(255, 255, 255, 0.05);
    }

    .manga-item-content {
        flex: 1;
        min-width: 0;
    }

    .manga-item-toggle {
        color: var(--text-muted);
        font-size: 1.2rem;
        transition: transform 0.2s;
        flex-shrink: 0;
    }

    .manga-item.expanded .manga-item-toggle {
        transform: rotate(180deg);
    }

    .manga-item-details {
        display: none;
        padding: 0 0.75rem 0.75rem 0.75rem;
        gap: 0.75rem;
    }

    .manga-item.expanded .manga-item-details {
        display: flex;
        flex-direction: column;
    }

    .manga-detail-row {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0.5rem 0;
        border-top: 1px solid rgba(255, 255, 255, 0.05);
    }

    .manga-detail-label {
        color: var(--text-muted);
        font-size: 0.85rem;
    }

    .manga-name {
        white-space: normal;
        overflow: visible;
        text-overflow: clip;
        font-size: 0.95rem;
    }

    .actions-cell {
        justify-content: flex-start;
        padding-top: 0.5rem;
    }
}

.status-badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: capitalize;
}

/* Status Colors */
.status-reading {
    background: rgba(59, 130, 246, 0.15);
    color: #60a5fa;
}

.status-completed {
    background: rgba(34, 197, 94, 0.15);
    color: #4ade80;
}

.status-planned {
    background: rgba(161, 161, 170, 0.15);
    color: #d4d4d8;
}

.status-dropped {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
}

.status-on_hold {
    background: rgba(234, 179, 8, 0.15);
    color: #facc15;
}

.actions-cell {
    display: flex;
    gap: 0.5rem;
}

.btn-icon-sm {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    font-size: 1.1rem;
    transition: color 0.2s, background 0.2s;
}

.btn-icon-sm:hover {
    color: var(--text-main);
    background: var(--border);
}

.btn-delete:hover {
    color: var(--danger);
}

.btn-icon-sm:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* Empty State */
.empty-state {
    padding: 4rem 1rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(2px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: #09090b;
    /* Match screenshot dark */
    width: 100%;
    max-width: 480px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.modal-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
}

.close-modal {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.25rem;
}

.close-modal:hover {
    color: var(--text-main);
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 0.75rem;
    background: var(--bg-app);
    /* Slightly darker/lighter than modal? Or just transparent/bordered */
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.95rem;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--text-main);
}

.select-wrapper {
    position: relative;
}

.select-wrapper select {
    appearance: none;
}

.select-icon {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    color: var(--text-muted);
}

.file-input-wrapper {
    display: flex;
    align-items: center;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-app);
    padding: 4px;
    position: relative;
    overflow: hidden;
}

.file-input-wrapper input[type="file"] {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
}

.file-input-wrapper.drag-over {
    background: #27272a;
    border-color: var(--primary);
}

.file-label {
    background: #27272a;
    color: #dedede;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 0.85rem;
    cursor: pointer;
    margin-right: 10px;
    white-space: nowrap;
}

.file-label:hover {
    background: #3f3f46;
}

#filePlaceholder {
    color: var(--text-muted);
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-right: 30px;
}

.upload-icon {
    margin-left: auto;
    margin-right: 10px;
    color: var(--text-muted);
}

small {
    display: block;
    margin-top: 0.5rem;
    color: #52525b;
    font-size: 0.8rem;
}

.btn-submit {
    width: 100%;
    padding: 0.85rem;
    background: var(--primary);
    color: var(--primary-fg);
    border: none;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    margin-top: 0.5rem;
    transition: opacity 0.2s;
}

.btn-submit:hover {
    opacity: 0.9;
}