/* ============================================
   GENZFLOW — CONTENT LIBRARY MODAL
   Media gallery modal for Create Post
   ============================================ */

/* Modal overlay */
.library-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s ease;
    pointer-events: none;
}

.library-modal-overlay.open {
    opacity: 1;
    pointer-events: all;
}

/* Modal card */
.library-modal {
    background: var(--card-bg, #1a1a24);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    width: 90vw;
    max-width: 720px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
    animation: libModalIn 0.25s ease;
}

@keyframes libModalIn {
    from {
        opacity: 0;
        transform: translateY(16px) scale(0.97);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Header */
.library-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.library-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary, #f0f0f5);
}

.library-close {
    background: none;
    border: none;
    color: var(--text-muted, #55556a);
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    transition: background 0.15s ease;
}

.library-close:hover {
    background: rgba(255, 255, 255, 0.08);
}

/* Tabs */
.library-tabs {
    display: flex;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    padding: 0 20px;
}

.library-tab {
    padding: 10px 16px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary, #8a8a9a);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.2s ease;
    background: none;
    border-top: none;
    border-left: none;
    border-right: none;
    font-family: inherit;
}

.library-tab:hover {
    color: var(--text-primary, #f0f0f5);
}

.library-tab.active {
    color: hsl(245, 70%, 62%);
    border-bottom-color: hsl(245, 70%, 62%);
}

/* Body */
.library-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
}

/* Filter bar */
.library-filter {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.library-filter-btn {
    padding: 5px 12px;
    font-size: 12px;
    font-weight: 500;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: transparent;
    color: var(--text-secondary, #8a8a9a);
    cursor: pointer;
    transition: all 0.15s ease;
    font-family: inherit;
}

.library-filter-btn:hover {
    background: rgba(255, 255, 255, 0.06);
}

.library-filter-btn.active {
    background: rgba(110, 86, 207, 0.15);
    color: hsl(245, 70%, 62%);
    border-color: hsl(245, 70%, 62%);
}

/* Media grid */
.library-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
}

.library-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: 10px;
    overflow: hidden;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.2s ease;
    background: rgba(255, 255, 255, 0.03);
}

.library-item:hover {
    border-color: hsl(245, 70%, 62%);
}

.library-item.selected {
    border-color: hsl(245, 70%, 62%);
    box-shadow: 0 0 0 3px rgba(110, 86, 207, 0.25);
}

.library-item img,
.library-item video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.library-item-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.library-item:hover .library-item-overlay {
    opacity: 1;
}

.library-item-overlay button {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: none;
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease;
}

.library-item-overlay button:hover {
    background: rgba(255, 255, 255, 0.35);
}

.library-item-type {
    position: absolute;
    top: 6px;
    right: 6px;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
}

/* Upload area */
.library-upload-area {
    border: 2px dashed rgba(255, 255, 255, 0.12);
    border-radius: 12px;
    padding: 48px 24px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.library-upload-area:hover {
    border-color: hsl(245, 70%, 62%);
    background: rgba(110, 86, 207, 0.04);
}

.library-upload-area i {
    color: var(--text-muted, #55556a);
    margin-bottom: 12px;
}

.library-upload-area .upload-text {
    font-size: 14px;
    color: var(--text-secondary, #8a8a9a);
    margin-bottom: 4px;
}

.library-upload-area .upload-hint {
    font-size: 12px;
    color: var(--text-muted, #55556a);
}

/* Empty state */
.library-empty {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-muted, #55556a);
}

.library-empty i {
    opacity: 0.4;
    margin-bottom: 12px;
}

/* Footer (Use Selected button) */
.library-footer {
    padding: 12px 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* Light mode */
[data-theme="light"] .library-modal {
    background: #fff;
    border-color: rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .library-upload-area {
    border-color: rgba(0, 0, 0, 0.12);
}