/* ===== BACKGROUND SELECTOR - iOS Style ===== */

/* Background Grid (Admin) */
.bg-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: var(--space-xl);
    margin-top: var(--space-xl);
}

.bg-item {
    position: relative;
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    height: 120px;
    transition: all var(--transition-base);
}

.bg-item:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

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

.bg-item .admin-delete-btn {
    position: absolute;
    top: var(--space-sm);
    right: var(--space-sm);
    padding: var(--space-xs) var(--space-sm);
    font-size: var(--font-size-xs);
    border-radius: var(--radius-sm);
}

.bg-name {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.7), transparent);
    color: white;
    padding: var(--space-sm) var(--space-md);
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-medium);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Floating Background Selector Button */
.bg-select {
    position: fixed;
    bottom: var(--space-2xl);
    right: var(--space-2xl);
    background: var(--glass-bg-strong);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border-radius: var(--radius-full);
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: var(--z-fixed);
    box-shadow: 
        0 8px 24px rgba(0, 0, 0, 0.15),
        inset 0 1px 0 rgba(255, 255, 255, 0.8);
    border: 1px solid var(--glass-border);
    cursor: pointer;
    transition: all var(--transition-base);
    color: var(--primary-color);
    font-size: var(--font-size-xl);
}

.bg-select:hover {
    transform: scale(1.1);
    box-shadow: 
        0 12px 32px rgba(0, 0, 0, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 1);
}

.bg-select:active {
    transform: scale(1.05);
}

/* Background Options Popup */
.bg-options {
    position: fixed;
    bottom: 90px;
    right: var(--space-2xl);
    background: var(--glass-bg-strong);
    backdrop-filter: var(--glass-blur-strong);
    -webkit-backdrop-filter: var(--glass-blur-strong);
    border-radius: var(--radius-xl);
    padding: var(--space-lg);
    z-index: var(--z-fixed);
    display: none;
    flex-direction: column;
    gap: var(--space-md);
    max-height: 400px;
    overflow-y: auto;
    box-shadow: 
        0 12px 40px rgba(0, 0, 0, 0.18),
        inset 0 1px 0 rgba(255, 255, 255, 0.9);
    border: 1px solid var(--glass-border);
    min-width: 80px;
}

.bg-option {
    width: 72px;
    height: 72px;
    border-radius: var(--radius-md);
    overflow: hidden;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all var(--transition-base);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-xs);
}

.bg-option:hover {
    transform: scale(1.08);
    box-shadow: var(--shadow-md);
}

.bg-option.active {
    border-color: var(--primary-color);
    box-shadow: 
        var(--shadow-md),
        0 0 0 1px var(--primary-color);
}

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

.bg-option div {
    background: rgba(245, 245, 247, 0.8);
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.bg-option div i {
    color: var(--primary-color);
    font-size: var(--font-size-2xl);
}

/* Background Selection in Settings Modal */
.backgrounds-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: var(--space-lg);
    max-height: 450px;
    overflow-y: auto;
    padding: var(--space-sm);
}

.background-item {
    position: relative;
    cursor: pointer;
    border-radius: var(--radius-md);
    overflow: hidden;
    transition: all var(--transition-base);
    box-shadow: var(--shadow-sm);
    border: 2px solid transparent;
}

.background-item:hover {
    transform: scale(1.05);
    box-shadow: var(--shadow-md);
}

.background-item img {
    width: 100%;
    height: 100px;
    object-fit: cover;
    display: block;
}

.background-item.active {
    border-color: var(--primary-color);
    box-shadow: 
        var(--shadow-lg),
        0 0 0 1px var(--primary-color);
}

.background-item.active::after {
    content: '\f00c';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    position: absolute;
    top: var(--space-sm);
    right: var(--space-sm);
    background: var(--primary-color);
    color: white;
    width: 24px;
    height: 24px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--font-size-xs);
    box-shadow: var(--shadow-md);
}

/* Responsive */
@media (max-width: 768px) {
    .bg-select {
        width: 48px;
        height: 48px;
        bottom: var(--space-xl);
        right: var(--space-xl);
        font-size: var(--font-size-lg);
    }
    
    .bg-options {
        bottom: 70px;
        right: var(--space-xl);
        left: var(--space-xl);
        max-width: calc(100vw - 2 * var(--space-xl));
    }
    
    .backgrounds-list {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: var(--space-md);
    }
    
    .background-item img {
        height: 80px;
    }
}
