/* ============================================
   MEIN HORUM – Dashboard Sektion
   ============================================ */

/* ---- Container & Sektion ---- */
#section-my-horum .library-section {
    margin-top: 32px;
}

/* ---- Bibliotheks-Header ---- */
.library-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.library-header h2 {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.library-count {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* ---- Steuerelemente (Suche, Filter, Sortierung) ---- */
.library-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    margin-bottom: 20px;
    padding: 12px 16px;
    background: var(--bg-card);
    border-radius: 12px;
    border: 1px solid rgba(139, 92, 246, 0.1);
}

/* Suche */
.search-wrapper {
    position: relative;
    flex: 1;
    min-width: 180px;
}

.search-wrapper .search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.5;
}

.search-wrapper .search-icon img {
    width: 18px;
    height: 18px;
}

.search-wrapper .search-input {
    width: 100%;
    padding: 8px 12px 8px 38px;
    background: var(--bg-secondary);
    border: 1px solid rgba(139, 92, 246, 0.15);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.9rem;
    outline: none;
    transition: 0.2s;
}

.search-wrapper .search-input:focus {
    border-color: var(--accent-violet);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
}

.search-wrapper .search-input::placeholder {
    color: var(--text-muted);
}

/* Filter-Buttons */
.filter-buttons {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.filter-buttons .filter-btn {
    padding: 6px 14px;
    background: transparent;
    border: 1px solid rgba(139, 92, 246, 0.15);
    border-radius: 8px;
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: 0.2s;
    white-space: nowrap;
}

.filter-buttons .filter-btn:hover {
    border-color: var(--accent-violet);
    color: var(--text-primary);
}

.filter-buttons .filter-btn.active {
    background: var(--accent-violet);
    border-color: var(--accent-violet);
    color: #fff;
}

/* ---- Custom Sort Dropdown ---- */
.custom-sort-dropdown {
    position: relative;
    min-width: 160px;
    cursor: pointer;
}

.custom-sort-dropdown .dropdown-trigger {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 12px;
    background: var(--bg-secondary);
    border: 1px solid rgba(139, 92, 246, 0.15);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.8rem;
    transition: 0.2s;
    user-select: none;
}

.custom-sort-dropdown .dropdown-trigger:hover {
    border-color: var(--accent-violet);
}

.custom-sort-dropdown .dropdown-arrow {
    font-size: 0.6rem;
    color: var(--text-muted);
    transition: 0.2s;
    margin-left: 8px;
}

.custom-sort-dropdown.open .dropdown-arrow {
    transform: rotate(180deg);
}

.custom-sort-dropdown .dropdown-list {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: var(--bg-card);
    border: 1px solid rgba(139, 92, 246, 0.15);
    border-radius: 8px;
    padding: 4px 0;
    z-index: 100;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
    max-height: 200px;
    overflow-y: auto;
}

.custom-sort-dropdown.open .dropdown-list {
    display: block;
}

.custom-sort-dropdown .dropdown-item {
    padding: 6px 12px;
    font-size: 0.8rem;
    color: var(--text-muted);
    transition: 0.15s;
    cursor: pointer;
}

.custom-sort-dropdown .dropdown-item:hover {
    background: rgba(139, 92, 246, 0.08);
    color: var(--text-primary);
}

.custom-sort-dropdown .dropdown-item.active {
    color: var(--accent-violet);
    font-weight: 500;
    background: rgba(139, 92, 246, 0.05);
}

/* Scrollbar für WebKit */
.custom-sort-dropdown .dropdown-list::-webkit-scrollbar {
    width: 4px;
}

.custom-sort-dropdown .dropdown-list::-webkit-scrollbar-track {
    background: transparent;
}

.custom-sort-dropdown .dropdown-list::-webkit-scrollbar-thumb {
    background: var(--accent-violet);
    border-radius: 2px;
}

.custom-sort-dropdown .dropdown-list {
    scrollbar-width: thin;
    scrollbar-color: var(--accent-violet) transparent;
}

/* ---- Paket-Grid ---- */
.library-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    margin-top: 8px;
}

/* ---- PAKET-KARTE ---- */
.library-card {
    background: var(--bg-card);
    border: 1px solid rgba(139, 92, 246, 0.08);
    border-radius: 14px;
    overflow: hidden;
    transition: 0.2s;
    display: flex;
    flex-direction: column;
}

.library-card:hover {
    border-color: rgba(139, 92, 246, 0.2);
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
}

/* ---- Bildbereich ---- */
.library-card-image {
    position: relative;
    aspect-ratio: 16 / 9;
    background: var(--bg-secondary);
    overflow: hidden;
}

.library-card-image .library-thumbnail {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Cloud-Badge */
.library-type-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: rgba(14, 14, 14, 0.5);
    border: 1px solid var(--accent-violet);
    backdrop-filter: blur(4px);
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 500;
    color: white;
}

.library-type-badge img {
    width: 14px;
    height: 14px;
}

/* ---- Inhaltsbereich ---- */
.library-card-content {
    padding: 14px 16px 16px;
    display: flex;
    flex-direction: column;
    flex: 1;
    gap: 8px;
}

/* Header (Titel + Typ) */
.library-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.library-card-header>div {
    flex: 1;
    min-width: 0;
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.library-card-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 2px 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.library-card-type {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--accent-violet);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* Kaufdatum */
.library-card-purchase {
    margin: 2px 0 0 0;
    display: flex;
    justify-content: center;
}

.library-card-date {
    font-size: 0.75rem;
    color: var(--text-muted);
    opacity: 0.7;
}

/* Status */
.library-card-status {
    margin: 2px 0 0 0;
    margin: 2px 0 0 0;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.status-badge {
    display: inline-flex !important;
    align-items: center;
    gap: 6px;
    padding: 3px 12px 3px 8px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
    background: var(--bg-secondary);
    color: var(--text-muted);
}

.status-badge .status-icon {
    width: 25px;
    height: 25px;
    flex-shrink: 0;
}

/* ---- Status-Varianten (je nach Backend-Daten) ---- */
.status-badge.status-available {
    background: rgba(104, 251, 36, 0.15);
    color: #2bfb24;
}

.status-badge.status-downloaded {
    background: rgba(96, 165, 250, 0.15);
    color: #60a5fa;
}

.status-badge.status-removed {
    background: rgba(248, 113, 113, 0.15);
    color: #f87171;
}

.status-badge.status-cloud {
    background: rgba(139, 92, 246, 0.15);
    color: var(--accent-violet);
}

.library-installed-dot {
    position: absolute;
    top: 12px;
    left: 12px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.library-installed-dot.installed {
    background: #22c55e;
}

.library-installed-dot.not-installed {
    background: #ef4444;
}

/* ---- Optionale Nachricht / Hinweis ---- */
.library-card-message {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: rgba(139, 92, 246, 0.06);
    border-radius: 8px;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.library-card-message-icon {
    width: 25px;
    height: 25px;
    flex-shrink: 0;
    opacity: 0.6;
}

.library-card-message-text {
    flex: 1;
}

/* ---- Aktions-Buttons ---- */
.library-card-actions {
    display: flex;
    gap: 8px;
    margin-top: 4px;
    justify-content: space-between;
}

.library-card-actions .btn-sm {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    font-size: 0.8rem;
    border-radius: 8px;
    border: none;
    font-weight: 500;
    cursor: pointer;
    transition: 0.2s;
    text-decoration: none;
}

.library-card-actions .btn-sm img {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.btn-review:disabled {
    cursor: not-allowed;
    opacity: 0.5;
    pointer-events: none;
}

/* Primary (Download) */
.library-card-actions .btn-primary {
    background: var(--accent-violet);
    color: #fff;
}

.library-card-actions .btn-primary:hover {
    opacity: 0.7;
}

/* Secondary (Details) */
.library-card-actions .btn-secondary {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid rgba(139, 92, 246, 0.15);
}

.library-card-actions .btn-secondary:hover {
    border-color: var(--accent-violet);
}

/* ---- Leer-Zustand ---- */
.library-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
}

.library-empty .empty-icon {
    margin-bottom: 16px;
    opacity: 0.3;
}

.library-empty .empty-icon img {
    width: 64px;
    height: 64px;
}

.library-empty h3 {
    font-size: 1.2rem;
    color: var(--text-primary);
    margin: 0 0 8px 0;
}

.library-empty p {
    font-size: 0.95rem;
    color: var(--text-muted);
    margin: 0 0 20px 0;
    max-width: 400px;
}

.library-empty .btn-primary {
    display: inline-block;
    padding: 10px 30px;
    background: var(--accent-violet);
    color: #fff;
    border-radius: 10px;
    font-weight: 600;
    text-decoration: none;
    transition: 0.2s;
}

.library-empty .btn-primary:hover {
    opacity: 0.9;
    transform: scale(1.02);
}

.my-horum-widget-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 768px) {
    .library-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .filter-buttons {
        justify-content: center;
    }

    .library-grid {
        grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
        gap: 14px;
    }

    .custom-sort-dropdown {
        min-width: 140px;
    }
}

@media (max-width: 480px) {
    .library-grid {
        grid-template-columns: 1fr;
    }

    .library-card-actions {
        flex-direction: column;
    }

    .library-card-actions .btn-sm {
        width: 100%;
        justify-content: center;
    }

    .library-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }

    .filter-buttons .filter-btn {
        padding: 4px 10px;
        font-size: 0.7rem;
    }

    .search-wrapper .search-input {
        font-size: 0.85rem;
    }

    .custom-sort-dropdown {
        min-width: 100%;
    }

    .custom-sort-dropdown .dropdown-trigger {
        padding: 8px 12px;
    }
}

/* ============================================
   DARK MODE (fallback)
   ============================================ */

@media (prefers-color-scheme: dark) {
    .library-card {
        background: var(--bg-secondary);
    }

    .library-controls {
        background: var(--bg-secondary);
    }

    .library-type-badge {
        background: rgba(0, 0, 0, 0.85);
    }
}